📄 uiappimp.pas
字号:
unit uIAppImp;
interface
uses
Classes,uIAppInf,Forms,Controls,TB2Item,windows,TBX,SpTBXDkPanels,SpTBXItem,
TB2Dock,SysUtils,Dialogs,uPlugBasefrm,StdCtrls,ExtCtrls;
type
TApp=class(TInterfacedObject,IApp)
private
FApplication:TApplication;
protected
//Action
procedure AddFriend;stdcall;
//GUI
function GetAppMainForm:TForm;stdcall;
function GetApplication:TApplication;stdcall;
procedure SetApplication(const value:TApplication);stdcall;
function GetAppMainToolDock:TComponent;stdcall;
function CreateToolBar(Dock:TComponent;DockableTo:TToolBarDockableTo;Caption:string):TComponent;stdcall;
function CreateDock(Position:TToolBarDockPosition;Parent:TWinControl):TComponent;stdcall;
procedure LockTooBar(ToolBar:TComponent);stdcall;
procedure UnLockTooBar(ToolBar:TComponent);stdcall;
procedure ShowToolBar(ToolBar:TComponent);stdcall;
procedure FreeToolBar(ToolBar:TComponent);stdcall;
procedure SetToolBarClose(ToolBar: TComponent;OnClose:TNotifyEvent);stdcall;
procedure SetToolBarCaption(ToolBar:TComponent;const value:string);stdcall;
procedure SetToolBarDockMode(ToolBar:TComponent;const value:TToolBarDockMode);stdcall;
function CreateToolBarBtn(AOwner:TComponent):TComponent;stdcall;
function CreateSeparator(AOwner:TComponent):TComponent;stdcall;
function CreateProgressBar(AOwner:TComponent;Width:integer):TComponent;stdcall;
function CreateStatusBar(AOwner:TWinControl):TComponent;stdcall;
function CreateTextLabel(AOwner:TComponent):TComponent;stdcall;
procedure SetControlCaption(Control:TComponent;const value:string);stdcall;
procedure SetControlHint(Control:TComponent;const value:string);stdcall;
procedure SetControlImages(Control:TComponent;const value:TImageList;const ImageIndex:integer);stdcall;
procedure SetBtnClick(Btn: TComponent;OnClick:TNotifyEvent);stdcall;
procedure SetProgressBarPosition(Bar:TComponent;const value:Cardinal);stdcall;
function GetProgressBarPosition(Bar:TComponent):Cardinal;stdcall;
procedure SetProgressBarMax(Bar:TComponent;const value:Cardinal);stdcall;
function CreatePlugForm(ParentHandle:THandle;ShowOnTask:Boolean):TForm;stdcall;
procedure CreateSkinPanel(Parent:TWinControl);stdcall;
function CreateControl(ControlClass:TControlClass;Parent:TWinControl):TControl;stdcall;
//Data
procedure GetFilesPath(var val:widestring;ListType:TListType);stdcall;
procedure FreeObject(Obj:TObject);stdcall;
procedure ReadFileText(Text:TStream;FileType:TFileType;frm:TForm);stdcall;
procedure SaveFileText(Text:TStream;FileType:TFileType;frm:TForm);stdcall;
public
property AppMainForm:TForm read GetAppMainForm;
property AppMainToolDock:TComponent read GetAppMainToolDock;
property Application:TApplication read GetApplication write FApplication;
end;
var
App:IApp;
implementation
uses
uMain, uSECData;
{ TApp }
procedure TApp.AddFriend;
begin
mainfrm.ibAddFriend.Click;
end;
function TApp.CreateProgressBar(AOwner: TComponent;Width:integer): TComponent;
begin
result:=TSpTBXProgressBar.Create(AOwner);
TSpTBXProgressBar(result).Width:=Width;
TSpTBXProgressBar(result).Parent:=TTBXToolbar(AOwner);
TSpTBXProgressBar(result).ThemeType:=thtTBX;
TSpTBXProgressBar(result).Min:=0;
TSpTBXProgressBar(result).Smooth:=true;
TSpTBXProgressBar(result).CaptionType:=pctNone;
end;
function TApp.CreatePlugForm(ParentHandle:THandle;ShowOnTask:Boolean): TForm;
var
frm:TForm;
begin
frm:=TPlugBasefrm.Create(self.Application,ShowOnTask,ParentHandle);
result:=frm;
end;
function TApp.CreateSeparator(AOwner: TComponent): TComponent;
begin
result:=TSpTBXSeparatorItem.Create(AOwner);
(AOwner as ITBItems).GetItems.Add(TSpTBXSeparatorItem(result));
end;
function TApp.CreateToolBar(Dock:TComponent;DockableTo:TToolBarDockableTo;Caption:string): TComponent;
begin
TSpTBXDock(Dock).BeginUpdate;
result:=TTBXToolbar.Create(Dock);
TTBXToolbar(result).Parent:=TSpTBXDock(Dock);
TTBXToolbar(result).Caption:=Caption;
TTBXToolbar(result).DockRow:=1;
TTBXToolbar(result).Options:=TTBXToolbar(result).Options+[tboShowHint];
TTBXToolbar(result).ShowHint:=true;
TTBXToolbar(result).DockableTo:=TTBDockableTo(DockableTo);
TSpTBXDock(Dock).EndUpdate;
end;
function TApp.CreateToolBarBtn(AOwner: TComponent): TComponent;
begin
result:=TSpTBXItem.Create(AOwner);
(AOwner as ITBItems).GetItems.Add(TSpTBXItem(result));
end;
procedure TApp.FreeObject(Obj: TObject);
begin
freeandnil(Obj);
end;
procedure TApp.FreeToolBar(ToolBar: TComponent);
var
i:integer;
begin
for i:=TTBXToolbar(ToolBar).Items.Count-1 downto 0 do
TTBXToolbar(ToolBar).Items[i].Free;
TTBXToolbar(ToolBar).Free;
end;
function TApp.GetApplication: TApplication;
begin
result:=FApplication;
end;
function TApp.GetAppMainForm: TForm;
begin
result:=mainfrm;
end;
procedure TApp.GetFilesPath(var val:widestring;ListType:TListType);
var
s:string;
sql:string;
begin
s:='';
sql:='select Path from %s order by Name';
case ListType of
ltMp3:sql:=Format(sql,['Mp3List']);
ltPic:sql:=Format(sql,['PicList']);
ltWeb:sql:=Format(sql,['WebLink']);
ltApp:sql:=Format(sql,['PDAApp']);
end;
SecData.qryTmp.Close;
SecData.qryTmp.SQL.Clear;
SecData.qryTmp.SQL.Text:=sql;
SecData.qryTmp.Open;
while not SecData.qryTmp.Eof do
begin
s:=s+SecData.qryTmp.Fields[0].asstring+#13;
SecData.qryTmp.Next;
end;
SecData.qryTmp.Close;
val:=pchar(s);
end;
function TApp.GetProgressBarPosition(Bar: TComponent): Cardinal;
begin
result:=TSpTBXProgressBar(Bar).Position;
end;
procedure TApp.LockTooBar(ToolBar: TComponent);
begin
TTBXToolbar(ToolBar).BeginUpdate;
end;
procedure TApp.SetApplication(const value: TApplication);
begin
FApplication:=value;
end;
procedure TApp.SetControlCaption(Control: TComponent;const value:string);
begin
TSpTBXCustomItem(Control).Caption:=Value;
end;
procedure TApp.SetBtnClick(Btn: TComponent;OnClick: TNotifyEvent);
begin
TSpTBXItem(Btn).OnClick:=OnClick;
end;
procedure TApp.SetControlHint(Control: TComponent; const value: string);
begin
TSpTBXCustomItem(Control).Hint:=Value;
end;
procedure TApp.SetControlImages(Control: TComponent; const value: TImageList;const ImageIndex:integer);
begin
TSpTBXCustomItem(Control).Images:=value;
TSpTBXCustomItem(Control).ImageIndex:=ImageIndex;
end;
procedure TApp.SetProgressBarMax(Bar: TComponent; const value: Cardinal);
begin
TSpTBXProgressBar(Bar).Max:=value;
end;
procedure TApp.SetProgressBarPosition(Bar: TComponent; const value: Cardinal);
begin
TSpTBXProgressBar(Bar).Position:=value;
end;
procedure TApp.SetToolBarCaption(ToolBar: TComponent; const value: string);
begin
TTBXToolbar(ToolBar).Caption:=value;
end;
procedure TApp.SetToolBarClose(ToolBar: TComponent;OnClose: TNotifyEvent);
begin
TTBXToolbar(ToolBar).OnClose:=OnClose;
end;
procedure TApp.ShowToolBar(ToolBar: TComponent);
begin
TTBXToolbar(ToolBar).Show;
end;
procedure TApp.UnLockTooBar(ToolBar: TComponent);
begin
TTBXToolbar(ToolBar).EndUpdate;
end;
function TApp.GetAppMainToolDock: TComponent;
begin
result:=mainfrm.SpTBXDock1;
end;
function TApp.CreateDock(Position: TToolBarDockPosition;Parent:TWinControl): TComponent;
var
comp:TComponent;
begin
comp:=TSpTBXDock.Create(Parent);
TSpTBXDock(comp).Position:=TTBDockPosition(Position);
TSpTBXDock(comp).Parent:=Parent;
result:=comp;
end;
function TApp.CreateControl(
ControlClass: TControlClass;Parent:TWinControl): TControl;
var
Control:TControl;
CurControl:TControlClass;
begin
CurControl:=TControlClass(FindClass(ControlClass.ClassName));
Control:=CurControl.Create(Parent);
Control.Parent:=Parent;
result:=Control;
end;
procedure TApp.CreateSkinPanel(Parent:TWinControl);
var
TBXToolWindow1: TTBXToolWindow;
begin
TBXToolWindow1:=TTBXToolWindow.Create(Parent);
TBXToolWindow1.Align:=alClient;
TBXToolWindow1.Parent:=Parent;
end;
procedure TApp.ReadFileText(Text:TStream;FileType:TFileType;frm:TForm);
begin
mainfrm.OprList.FileType:=integer(FileType);
mainfrm.OprList.OperFrm('ExportDBFile',frm);
mainfrm.OprList.ReadFileTextFromDB(Text);
end;
procedure TApp.SaveFileText(Text:TStream;FileType:TFileType;frm:TForm);
begin
mainfrm.OprList.FileType:=integer(FileType);
mainfrm.OprList.SaveFileTextToDB(Text);
mainfrm.OprList.OperFrm('ImportDBFile',frm);
end;
procedure TApp.SetToolBarDockMode(ToolBar: TComponent;
const value: TToolBarDockMode);
begin
TTBXToolbar(ToolBar).DockMode:=TTBDockMode(value);
end;
function TApp.CreateStatusBar(AOwner: TWinControl): TComponent;
begin
result:=TSpTBXStatusBar.Create(AOwner);
TSpTBXStatusBar(result).Parent:=AOwner;
TSpTBXStatusBar(result).Align:=alBottom;
end;
function TApp.CreateTextLabel(AOwner: TComponent): TComponent;
begin
result:=TSpTBXLabelItem.Create(AOwner);
(AOwner as ITBItems).GetItems.Add(TSpTBXLabelItem(result));
end;
initialization
begin
RegisterClasses([TEdit,TPanel,TImage,TScrollBox,TStaticText]);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -