32平方公寓设计效果图:可以给讲一个VB和Delphi拖盘的简单例子么?

来源:百度文库 编辑:中科新闻网 时间:2024/05/03 10:18:01
谢谢拉~
越简单越好~

interface
uses ---------------------------------------------
const ICON_ID=1;
MI_ICONEVENT=WM_USER+1;
private
Normalicon, //---正常状态图标-----;
Disabledicon:Ticon; //---失效状态图标------;
Status:boolean; //----记录定义菜单标题---;
Procedure Iconclickon(var msg:Tmessage); Message MI_ICONEVENT; //---托盘点击事件消息-----;
procedure Changeico(ok:boolean); //----更改托盘图标-----;
procedure Installico; //----安装托盘图标-----;
Procedure Uninstallico;
-----------------------------------------------------
Procedure Tstartform.Iconclickon;
var
P:Tpoint;
begin
if ((msg.LParam=WM_LButtondown) and (status)) then
begin
POSjkmainform.BorderStyle:=Bsnone;
POSjkmainform.WindowState:=Wsmaximized;
POSjkmainform.show;
end;
if (msg.LParam=WM_RButtondown) then
begin
Getcursorpos(p);
Popmenu.Popup(p.x,p.y);
end;
if ok11.Tag=10 then
ok.Enabled:=false
else if ok11.Tag=5 then
ok.Enabled:=true;

//
end;
//---------------the procedure of icon of the Installation-----;
procedure Tstartform.Installico;
var
Icondata:TnotifyIcondata;
sPath:string;
begin
sPath:=ExtractFilePath(Application.ExeName);
Normalicon:=Ticon.Create;
Disabledicon:=Ticon.Create;
Normalicon.LoadFromFile(sPath+'ico\chartenable.ico');
Disabledicon.LoadFromFile(sPath+'ico\chartdisable.ico');
Icondata.cbSize:=Sizeof(Icondata);
Icondata.Wnd:=handle;
Icondata.uID:=Icon_id;
Icondata.uFlags:=NIF_icon or NIF_message or NIF_tip;
Icondata.uCallbackMessage:=MI_iconevent;
Icondata.hIcon:=Normalicon.Handle;
Icondata.szTip:='POS 实时监控程序!';
Shell_NotifyIcon(NIM_ADD,@Icondata);
//
end;
//---------------the procedure of the icon of the changeico-----;
procedure Tstartform.Changeico(ok:boolean);
var
Icondata:TNotifyIcondata;
begin
Icondata.cbSize:=Sizeof(Icondata);
Icondata.Wnd:=handle;
Icondata.uID:=Icon_id;
if not ok then
begin
Icondata.hIcon:=Disabledicon.Handle;
status:=false;
popmenu.Items.Enabled:=false;
end
else
begin
Icondata.hIcon:=Normalicon.Handle;
Status:=true;
Popmenu.Items.Enabled:=true;
end;

Icondata.uFlags:=NIF_icon;
Shell_notifyicon(NiM_Modify,@Icondata);
//
end;
//--------------the procedure of the icon of the Uninstallico----;
Procedure Tstartform.Uninstallico;
var
Icondata:TNotifyicondata;
begin
Icondata.cbSize:=Sizeof(Icondata);
Icondata.Wnd:=handle;
Icondata.uID:=Icon_id;
Shell_Notifyicon(NIM_delete,@Icondata);
//
end;
-------------------------------------------
procedure Tstartform.FormCreate(Sender: TObject);
begin
Readini;
setDatabase;
Status:=true;
Installico;
ChangeIco(true);
ShowWindow(Application.handle,SW_hide);
SetWindowLong(Application.handle,GWL_exstyle,WS_EX_ToolWindow);
CreateTempTable('temp_pos.db',true);
CreateTempTable('temp_splb.db',false);
end;-------------------------------------------------
procedure Tstartform.FormClose(Sender: TObject;
var Action: TCloseAction);
begin

DataModuleform.Database_Server.connected:=false;
Uninstallico;
Normalicon.Free;
Disabledicon.Free;
if DataModuleform.Table_DBchart.Active then
DataModuleform.Table_DBchart.Active:=false;

DeleteTempTable;
end;

procedure Tstartform.FormActivate(Sender: TObject);
begin
startform.Width:=0;
startform.Height:=0;
ShowWindow(Application.Handle,SW_hide);
end;

procedure Tstartform.okClick(Sender: TObject);
begin
with POSjkmainform do
begin
BorderStyle:=Bsnone;
WindowState:=WSmaximized;
Show;
end;

end;

procedure Tstartform.ok11Click(Sender: TObject);
begin
if status then
begin
changeico(false);
ok11.Caption:='激活监控(&A)';
POSjkmainform.Close;
ok11.Tag:=10;
end
else
begin
Changeico(true);
ok11.Caption:='停止监控(&S)';
ok11.Tag:=5;
end;
end;

procedure Tstartform.exit1Click(Sender: TObject);
begin
close;
end;
end.