Board index » delphi » Reset work area when user resizes desktop, OnResize

Reset work area when user resizes desktop, OnResize

    I have an app that puts itself on a small area above the taskbar,
and resizes the work area.  My current challenge is to handle when the
user resizes the desktop.  I'm having a bit of trouble getting it to
work via the OnResize event, since OnResize fires *after* the app is
resized (and at other times, like form creation).  Also, if the user
increases the desktop size the app window is not forcibly resized, so it
seems like I will have to capture the WM_SETTINGCHANGE message somehow.

    Before I struggle with what seems like should be a relatively easy
thing for too much longer, has anyone done this?  I tried searching the
web for GETWORKAREA and SETWORKAREA to no avail.

Thanks,

 - Steve Yates
 - Benji! Don't run out on the high@#%^&(* NO TERRIER

/ Taglines by Taglinator - www.srtware.com /

 

Re:Reset work area when user resizes desktop, OnResize


Quote
"Steve Yates" <st...@srtware.com> wrote in message

news:3c85c9ba_2@dnews...

Quote
>     I have an app that puts itself on a small area above the taskbar,
> and resizes the work area.  My current challenge is to handle when the
> user resizes the desktop.

    After some perseverence (and sleep <g>) I have figured it out.  As I
suspected it is rather simple.  I found WM_DISPLAYCHANGE with a bit
of help from WinSight, a tool I use so infrequently I keep forgetting
how
useful it can be!  Hope this helps someone...

{ declarations in form }
OrigWorkArea : TRect;
procedure WMDisplayChange(var message: TMessage);  message
WM_DISPLAYCHANGE;
{ WMDisplayChange triggers only when resolution changes }

procedure TMainForm.PlaceMainForm;  { also called once in Form's
OnCreate for initial sizing }
begin
  { the work area is reset by Windows when the resolution changes, so
recapture it }
  SystemParametersInfo(SPI_GETWORKAREA, 0, @OrigWorkArea, 0);
  { code to place app where I want it at bottom of screen }
  MainForm.SetWorkArea; { my proc, sets work area to (OrigWorkArea - app
height) }
end;

procedure TMainForm.WMDisplayChange(var message: TMessage);
begin
  inherited;
  PlaceMainForm;
end;

 - Steve Yates
 - Once we have all the bugs ironed out, we'll be running on flat bugs.

/ Taglines by Taglinator - www.srtware.com /

Other Threads