Mirror

Hook into the WM_WindowPosChanging message (Views: 100)

Problem/Question/Abstract:

Is it somehow possible to "check" in the WM_WindowPosChanging message if the window is resized?

Answer:

In this message, Msg.WindowPos^.flags holds the flags which were originally used with the SetWindowPos, etc. functions. The window will change its size if SWP_NOSIZE is not contained in this flags, and either cx or cy are different, compared to Width and Height values of the form:

procedure TForm1.WMWindowPosChanging(var Msg: TWMWindowPosChanging);
begin
if (Msg.WindowPos^.flags and SWP_NOSIZE = 0) and ((Msg.WindowPos^.cx <> Width)
or (Msg.WindowPos^.cy <> Height)) then
Windows.Beep(1000, 20); {sizing}
end;


<< Back to main page