处理WM_SysCommand消息,没什么效果

解决方案 »

  1.   

    Mainfrm.Width := Screen.Width;
    Mainfrm.Height := Screen.Height;
    Mainfrm.top := 0;
    Mainfrm.left := 0;
      

  2.   

    设置BorderStyle为bsNone,然后设置WindowState为wsMaximized即可。————————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    ————————————————————————————————————
      

  3.   

    照 lxpbuaa(桂枝香在故国晚秋)说的当然可以,我一直就是这么做的。
      

  4.   

    哦?那就拦截最大化消息unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, AppEvnts, StdCtrls, Buttons;type
      TForm1 = class(TForm)
        BitBtn1: TBitBtn;
        procedure BitBtn1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        procedure MaxMessage(var Msg:TMessage);message WM_SYSCOMMAND;  end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.MaxMessage(var Msg:TMessage);
    begin
      if Msg.WParam =  SC_MAXIMIZE then
      begin
            form1.Width := screen.Width;
            form1.Height := screen.Height;
            form1.Top := 0;
            form1.Left := 0;
      end;
    end;procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
    form1.WindowState := wsMaximized;
    end;end.
      

  5.   

    就是像word全屏显示那样,听听高手发言
      

  6.   

    没有标题栏,就把formstyle 设为none啊!
      

  7.   

    to cnhgj :感谢你的热情现在的焦点不在怎么把窗体做成无边框,无标题栏上而是,什么时候做这个动作,不知道这么说你能不能理解?
    WM_SysCommand只能处理系统菜单事件, 不能处理窗体最大化按钮点击事件,这需要通过另外一个消息WM_NCHITTEST 来截取,我尝试过在这两个消息中处理,但没有成功
      

  8.   

    HI!半夜爬起来,你说WM_SYSCOMMAND无法拦截点击最大化按纽消息?那你错了,我自已试验的
    你新建一个PROJECT,然后什么都不要创建,直接把下面的代面替换掉unit1.pas的代码,然后F9
    运行后什么都没有,但当你点最大化按纽的时候,将会出现对话框,俺在d7+win2003下测试通过
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
        procedure MaxMessage(var Msg:TMessage);Message WM_SYSCOMMAND;
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure Tform1.MaxMessage(var Msg:TMessage);
    begin
            if Msg.WParam = SC_MAXIMIZE then
            begin
                    ShowMessage('dd');
            end;
    end;end.
      

  9.   

    procedure MaximizeMsg(var Msg:Tmessage);message WM_SYSCOMMAND;procedure TForm1.MaximizeMsg(var Msg:Tmessage);
    begin
      if Msg.wParam and $FFF0=SC_MAXIMIZE then
        BorderStyle:=bsNone;
     DefWindowProc(Handle,Msg.Msg,Msg.wParam,Msg.lParam);
    end;
      

  10.   

    en 感谢cnhgj(戏子) 的热心,问题已经搞定了,
    本来当天准备来结贴的,结果网络出了问题一个是在WndProc过程里处理
    if (MSG.WM_SYSCOMMAND) and (WParams=SC_MAXIMIZE) then
    ....
     
    另一个就是标题栏的双击消息
    WM_NCLBUTTONDBLCLK
    在这个消息里就写两句
    begin
      Inherited;
      SendMessage(Handle, WM_SYSCOMMAND,SC_MAXIMIZE ,0)
    end;我在新工程里这样写的,完全能够实现。可用在我现在开发的工程里,和我以前写的一个控件有冲突,
    所以放弃使用这个功能了