How to send WM_SIZE, WM_MOVE while handle to WM_WINDOWPOSCHANGED [Edit]

Giganews Newsgroups
Subject: How to send WM_SIZE, WM_MOVE while handle to WM_WINDOWPOSCHANGED [Edit]
Posted by:  Nguyen Duy Tuan
Date: Tue, 27 Jul 2010

I have code in WndProc with Window's message is WM_WINDOWPOSCHANGED. In this case I must change size and position of this window.

My code:
{code=delphicode}
procedure TMyObject.WndProc(var Message: TMessage);
begin
  with Message do
  begin
    case Msg of
      WM_SIZE:
        with TWMSize(Message) do
        begin
              //do something
        end;
      WM_WINDOWPOSCHANGED:
        with TWMWindowPosChanged(Message) do
        begin
          FMyFrm.Left :=  WindowPos^.x;
          FMyFrm.Top :=  WindowPos^.y;
          FMyFrm.Height := WindowPos^.cy;
          SendMessageW(FHwndWin, WM_SIZE, 0,
                    MakeLParam(WindowPos^.cx - FMyFrm.Width, WindowPos^.cy));
        end;
    end;
    Result := CallWindowProcW(FPrevWndProc, FHwndWin, msg, wParam, lParam);
  end;
end;
{code}

When code running, it is broken. I think, because I use [COLOR="Blue"]SendMessageW(FHwndWin, WM_SIZE, 0,
                    MakeLParam(WindowPos^.cx - FMyFrm.Width, WindowPos^.cy));[/COLOR]

In Microsoft's help:
[QUOTE]
[B]WM_WINDOWPOSCHANGED Notification[/B]
[B]Remarks[/B]

By default, the DefWindowProc function sends the WM_SIZE and WM_MOVE messages to the window. The WM_SIZE and WM_MOVE messages are not sent if an application handles the WM_WINDOWPOSCHANGED message without calling DefWindowProc. It is more efficient to perform any move or size change processing during the WM_WINDOWPOSCHANGED message without calling DefWindowProc. [/QUOTE]

Please help me do it success!

Thanks in advanced!

Edited by: Nguyen Duy Tuan on Jul 27, 2010 12:05 AM

Edited by: Nguyen Duy Tuan on Jul 27, 2010 12:06 AM

Replies