Link to home
Start Free TrialLog in
Avatar of voxel
voxel

asked on

Refreshing the desktop

I have an application that set the work area of the desktop (Windows API). So I would like to redraw all opened windows.

Did anybody know how to do that ?

Thanks

Gustavo
Avatar of Madshi
Madshi

I'm not sure what you want. Can you please say it again a bit more detailed?
Avatar of voxel

ASKER

Edited text of question.
Redraw or resize?

To enumerate all windows use "EnumWindows". To resize the windows use "SetWindowPos". To refresh them use "InvalidateRect".
Avatar of voxel

ASKER

and how I use the EnumWindows function ?
hi,
here a cpuple of waus to refresh desktop:

SendMessage(FindWindow('Progman', 'Program Manager'), WM_COMMAND, 106597,
0);

or:

procedure RefreshDesktop;
var
 c : cardinal;
begin
c:=FindWindowEx(FindWindowEx(FindWindow('Progman','Program Manager'),0,'SHELLDLL_DefView',''),0,'SysListView32','');
  PostMessage(c,WM_KEYDOWN,VK_F5,0); PostMessage(c,WM_KEYUP,VK_F5,1 shl 31);
end;
Avatar of voxel

ASKER

I think you didn't understand my question.
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of voxel

ASKER

I still didn't find how to resize windows to fit in the new work area set by my application.

But i'm giving you the points.

thanks
Avatar of voxel

ASKER

Do you know how to resize all windows to fit the new work area (desktop) set by my application ?
Well, for each window do this:

(1) Call "GetWindowRect(window)" to get the window position/size.
(2) See, whether this rectangle fits in your work area. If not, change the rectangle, so that it does fit. Then call "SetWindowPos(window, ...)" to realize the new rectangle.