灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:2976回复:0

delphi添加系统菜单,点击新菜单没有反应的问题

楼主#
更多 发布于:2012-09-08 13:04



program Psysmenu; uses Forms, Sysmenu in '\SYSMENU.PAS' {Form1}; {$R *.RES} begin Application.CreateForm(TForm1, Form1); Application.Run; end. unit Sysmenu; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private procedure user_sysmenu(var msg:twmmenuselect); message wm_syscommand; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.user_sysmenu(var msg:TWMMENUSELECT); begin if msg.iditem=100 then showmessage(' 响应系统菜单!') { 也 可 以setwindowpos()来实现处于最前端功能} else inherited; { 作缺省处理,必须调用这一过程} end; procedure TForm1.FormCreate(Sender: TObject); var hmenu:integer; begin hmenu:=getsystemmenu(handle,false); {获取系统菜单句柄} appendmenu(hmenu,MF_SEPARATOR,0,nil); appendmenu(hmenu,MF_STRING,100,'加入系统菜单'); {加入用户菜单} end; end.

//出错的主要原因是:缺少一句代码message wm_syscommand;
//这句代码的主要作用是:A window receives this message when the user chooses a commond from the window menu.
//而如果注释了inherited ,则所有系统菜单都不能用。



喜欢0 评分0
游客

返回顶部