请问如何把窗体右上角的关闭(X)变灰色,也就相当于Enable := false一样(100分)

  • 主题发起人 主题发起人 telliu
  • 开始时间 开始时间
T

telliu

Unregistered / Unconfirmed
GUEST, unregistred user!
我记得有API函数的,朋友提示说是e?????window <br>哪位朋友能告诉一声吗?是哪个函数?怎样用的?谢谢
 
有三种方法:1,在设计期修改BorderIcns,把所有设为false;2,在运行期,bordericons:=[];3,api函数:EnableMenuItem(GetSystemMenu(Handle, FALSE),SC_CLOSE,MF_BYCOMMAND or MF_GRAYED); GetSystemMenu(Handle, FALSE)为返回一个HMenu,最后的两个参数为标志位,这个方法可以灰化掉关闭按钮,但是好像对最大化,最小化按钮无效。
 
首先谢谢Solid_Snake在这么晚了帮我解问题<br>下面是我发了贴后找到的,今早上起来一看Solid_Snake回答了我的问题,跟我找到的方法一至的,现结贴,谢谢<br><br><br>来自:Liu JZX, 时间:2000-3-13 9:53:00, ID:198830<br>1、<br>procedure TForm1.WMInit(var msg: TWMInitMenuPOPUP);<br>begin<br>&nbsp; inherited;<br>&nbsp; &nbsp; EnableMenuItem(msg.MenuPopup ,sc_Close,MF_BYCOMMAND or MF_GRAYED)<br><br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; PostMessage(handle, WM_INITMENUPOPUP, GetSystemMenu(handle, false), 0);<br>end;<br><br>2、<br><br>procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>&nbsp; Action := CaNone;<br>end;<br><br>3、<br>procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);<br>begin<br>&nbsp; CanClose:=false;<br>end;<br><br>4、<br>bordericons的bisystemmenu:=false;<br>&nbsp;<br>5、<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; private<br>&nbsp; &nbsp; &nbsp;procedure Sys(var msg: TMessage);message WM_SYSCOMMAND;<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>procedure TForm1.Sys(var msg: TMessage);<br>begin<br>&nbsp; if msg.WParam = SC_CLOSE then<br>&nbsp; &nbsp; msg.Result := 1;<br>end;<br><br>6、<br>&nbsp; &nbsp; procedure WMInit(var msg: TWMInitMenu);message WM_INITMENU;<br><br>procedure TForm1.WMInit(var msg: TWMInitMenu);<br>begin<br>&nbsp; inherited;<br>&nbsp; &nbsp; EnableMenuItem(msg.Menu,sc_Close,MF_BYCOMMAND or MF_GRAYED)<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; PostMessage(handle, WM_INITMENU, GetSystemMenu(handle, false), 0);<br>end;
 
接受答案了.
 

Similar threads

后退
顶部