很简单的问题,请教大家!

xzhifei 2003-08-26 05:32:32
怎么设置当前程序窗口为系统的激活窗口,就象WINAMP一样,点击系统托盘就出来主窗口,而且是激活窗口.
...全文
63 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zdcnow 2003-08-26
  • 打赏
  • 举报
回复
procedure TMainForm.MyTrayIconOnClick(var Msg:TMessage);
var
pt:TPoint;
begin
case Msg.lParam of
WM_LBUTTONDOWN:
begin
MainForm.Visible:=true; //look here
Application.BringToFront; //look here
end;
WM_LBUTTONDBLCLK:
begin
end;
WM_RBUTTONDOWN:
begin
end;
end;
end;
IORILI 2003-08-26
  • 打赏
  • 举报
回复
功能多呀 呵呵 这是我就这么做的,我不知道共简单的方法了
FrameSniper 2003-08-26
  • 打赏
  • 举报
回复
没有楼上的这么复杂吧!
IORILI 2003-08-26
  • 打赏
  • 举报
回复
程序实现了在系统托盘区省城图标,最小化的时候任务栏没有图标,点右键,出现选项,双击
弹出主窗体
IORILI 2003-08-26
  • 打赏
  • 举报
回复
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, se_controls, KsSkinItems, KsSkinMenus, KsSkinForms, KsSkinEngine,
KsSkinSpeedButtons, KsSkinToolBars, Menus,shellapi,comobj,
ksskinstatusbar, ExtCtrls, jpeg, ImgList;

const
mousemsg=wm_user+1;
iid=100;
type
Tmain = class(TForm)
SeSkinEngine1: TSeSkinEngine;
SeSkinMenuBar1: TSeSkinMenuBar;
SeSkinToolBar1: TSeSkinToolBar;
SeSpeedDivider2: TSeSpeedDivider;
SeSkinPopupMenu1: TSeSkinPopupMenu;
SeSpeedDivider3: TSeSpeedDivider;
SeSkinSpeedButton8: TSeSkinSpeedButton;
SeSkinPopupMenu2: TSeSkinPopupMenu;
Imag: TImageList;
Img: TImageList;
CustomItem73: TSeSkinItem;
CustomItem74: TSeSkinItem;
SeSpeedDivider4: TSeSpeedDivider;
SeSpeedDivider5: TSeSpeedDivider;
SeSkinSpeedButton9: TSeSkinSpeedButton;
SeSkinSpeedButton1: TSeSkinSpeedButton;
SeSpeedDivider1: TSeSpeedDivider;
SeSpeedDivider6: TSeSpeedDivider;
CustomItem31: TSeSkinItem;
procedure CustomItem31Click(Sender: TObject);
private
procedure mousemessage(var message:tmessage);message mousemsg;
{ Private declarations }
public
{ Public declarations }
end;

var
main: Tmain;
ntida:tnotifyicondataa;
ss,exclname,frootpath:string;
flag:integer;

implementation
uses dayplan, login_u, huiz, zhixinglv, dbmod,pub_u, chayi_u, lookfor,
time_u, dbservcon, datawei, manager, huizong_u, Exfind, plan;

{$R *.dfm}

procedure Tmain.SeSkinSpeedButton7Click(Sender: TObject);
begin
if findmdiwindow=true then begin
showmessage('请关闭当前窗口');exit;end;
ntida.cbSize := sizeof(tnotifyicondataa);
ntida.wnd := handle;
ntida.uID := iid;
ntida.uFlags := nif_icon + nif_tip + nif_message;
ntida.uCallbackMessage := mousemsg;
ntida.hIcon := Application.Icon.handle;
ntida.szTip := 'Icon';
shell_notifyicona(NIM_DELETE, @ntida);
Application.Terminate;
end;

procedure tmain.mousemessage(var message:tmessage);
var
mousept:tpoint;
begin
inherited;
if message.LParam=wm_rbuttonup then begin
getcursorpos(mousept);
SeSkinPopupMenu1.Popup(mousept.X,mousept.Y);
end;
if message.LParam=wm_lbuttonup then begin
showwindow(handle,sw_show);
showwindow(application.Handle,sw_show);
setwindowlong(application.Handle,gwl_exstyle,not (getwindowlong(application.Handle,gwl_exstyle) or ws_ex_toolwindow and not ws_ex_appwindow));
end;
message.Result:=0;
end;

procedure Tmain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caNone; //不进行任何动作
ShowWindow(Handle, SW_HIDE); //隐藏窗口
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
end;

procedure Tmain.CustomItem53Click(Sender: TObject);
begin
ShowWindow(Handle, SW_show); //显示窗口
ShowWindow(Application.Handle, SW_show);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
end;

procedure Tmain.FormCreate(Sender: TObject);
begin
CustomItem5.Enabled:=false;
CustomItem7.Enabled:=false;
CustomItem8.Enabled:=false;
SeSkinSpeedButton8.enabled:=false;
SeSkinSpeedButton3.enabled:=false;
SeSkinSpeedButton4.enabled:=false;
SeSkinSpeedButton5.enabled:=false;
SeSkinSpeedButton9.enabled:=false;
FRootPath := ExtractFilePath(Application.ExeName);//得到系统路径
flag:=100;
CustomItem4.Enabled:=false;
CustomItem9.Enabled:=false;
CustomItem14.Enabled:=false;
CustomItem32.Enabled:=false;
CustomItem50.Enabled:=false;
CustomItem63.Enabled:=false;
ntida.cbSize:=sizeof(tnotifyicondataa);
ntida.Wnd:=handle;
ntida.uID:=iid;
ntida.uFlags:=nif_icon+nif_tip+nif_message;
ntida.uCallbackMessage:=mousemsg;
ntida.hIcon:=application.Icon.Handle;
ntida.szTip:='海尔洗衣机生产报表处理软件';
shell_notifyicona(nim_add,@ntida);
end;
FrameSniper 2003-08-26
  • 打赏
  • 举报
回复
BringToFront函数
cgh1970 2003-08-26
  • 打赏
  • 举报
回复
up

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧