时间: 2021-07-31 作者:daque
干什么windows的体例菜单老是循规蹈矩?这个例子教你怎样往体例菜单增添一个菜单项如about或information等。 这个例子将一个菜单项加到体例菜单中去。咱们须要两个货色,一个是项名,这不妨是怎样平头;咱们还须要一个步调去收取windows对确认点击咱们创造的菜单项的消息。 unit ohyeah; interface uses sysutils, wintypes, winprocs, messages, classes, graphics, controls, forms, dialogs, menus; type tform1 = class (tform) procedure formcreate (sender : tobject); private {private declarations} public {public declarations} procedure winmsg (var msg : tmsg; var handled : boolean); procedure dowhateever; end; var form1 : tform1; implementation {$r *.dfm} const itemid = 99; // 这个id number代办你的菜单项,不妨是任何值。procedure tform1.winmsg (var msg : tmsg; var handled : boolean); begin if msg.message = wm_syscommand then if msg.wparam = itemid then dowhatever; end; procedure tform1.formcreate (sender : tobject); begin application.onmessage := winmsg; appendmenu (getsystemmenu (form1.handle, false), mf_separator, 0, ''); appendmenu (getsystemmenu (form1.handle, false), mf_byposition, itemid, '&my menu'); appendmenu (getsystemmenu (application.handle, false), mf_separator, 0, ''); appendmenu (getsystemmenu (application.handle, false), mf_byposition, itemid,'&my menu minimized'); end; procedure tform1.dowhatever; begin exit; //你不妨增添任何你想加的货色到这边end; end.