有关Windows的消息机制
我在本单元private部分写入
procedure WMSYSCommand(var Message:TMessage);message WM_SYSCOMMAND;
代码实现部分为
//如果用户按了登陆窗口在上角的关闭窗体的按钮,则认为按了“取消”按钮
if Message.WParam=SC_CLOSE Then Bitbtn2.OnClik(Self)
else inherited;
以上代码在运行时出错,请多多指教!解决立即送分!!!!

解决方案 »

  1.   

    代码没有错,delphi2 + pack 2 下
    是不是Bitbtn2.OnClik有错?
      

  2.   

    [Error] login.pas(39): Unknown directive: 'message'
    [Error] login.pas(41): Undeclared identifier: 'Bitbtn2'
    [Error] login.pas(41): Undeclared identifier: 'Self'
    [Error] login.pas(42): This form of method call only allowed in methods of derived types
    [Error] login.pas(25): Unsatisfied forward or external declaration: 'Tloginfrm.WMSysCommand'
    [Fatal Error] Leavemessage.dpr(7): Could not compile used unit 'login.pas'
    以上出错信息
      

  3.   

    if Message.WParam=SC_CLOSE Then Bitbtn2.click
    else inherited;不正确找我!
      

  4.   

    1、uses messages;
    2、在代码在实现部分
      procedure  Tloginfrm.WMSYSCommand(var Message:TMessage);//如果窗体是form1的话
      begin
      end;
    3、if Message.WParam=SC_CLOSE Then 
          Bitbtn2click(sender);
       else inherited;/////////try it!