Accessing and inheriting Windows Message for other Windows Message in Delphi

Posted by HX_unbanned on Stack Overflow See other posts from Stack Overflow or by HX_unbanned
Published on 2010-06-14T13:02:38Z Indexed on 2010/06/14 14:02 UTC
Read the original article Hit count: 196

Filed under:
|
|
|
|

I am using WMSysCommand messages to modify Caption bar button ( Maximize / Minimize ) behaivor and recent update requiered to use WMNCHitTest, but I do not want to split these two related messages in multiplie procedures because of lengthy code.

Can I access private declaration ( message ) from other message? And if I can - How to do it?

  procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest) ;
  begin
    SendMessage(Handle, HTCAPTION, WM_NCHitTest, 0); // or other wParam or lParam ???? 
  end;

  procedure TForm1.WMSysCommand;
  begin
    if (Msg.CmdType = SC_MAXIMIZE or 61488) or (Msg.Result = htCaption or 2) then // if command is Maximize or reciever message of Caption Bar click
    begin
      if CheckWin32Version(6, 0) then
        Constraints.MaxHeight := 507
      else
        Constraints.MaxHeight := 499;
      Constraints.MaxWidth := 0;
    end
    else if (Msg.CmdType = SC_MINIMIZE or 61472) or (Msg.Result = htCaption or 2) then // if command is Minimize
    begin
      if (EnsureRange(Width, 252, 510) >= (510 / 2)) then
        PreviewOpn.Caption := '<'
      else
        PreviewOpn.Caption := '>';
    end;
    DefaultHandler(Msg); // reset Message handler to default ( Application )
  end;

Soo ... do I think correctly and sipmly do not know correct commands or I am thinking total bullsh*t?

Regards. Thanks for any help...

© Stack Overflow or respective owner

Related posts about delphi

Related posts about winapi