当前位置:编程学习 > Delphi >>

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

 

program Psysmenu; uses Forms, Sysmenu in '\SYSMENU.PAS' {Form1}; {$R *.RES} begin Application.CreateForm(TForm1, Form1); Application.Run; end. unit Sysmenu; inte易做图ce 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 ,则所有系统菜单都不能用。

补充:软件开发 , Delphi ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,