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
voxelAsked:
Who is Participating?
 
MadshiConnect With a Mentor Commented:
If you have D4 or D5 you can download my free unit "enumStuff" from my homepage

http://beam.to/madshi

Look at the function "GetWindowList".

If you have D2/D3, do something like this:

function EnumWindowsProc(window: dword; lParam: integer) : bool; stdcall;
begin
  result := true;
  // Windows calls this function one time for each top level window
  // so here use GetWindowPos/SetWindowPos with "window"
  // or/and InvalidateRect with "window"
end;
 
  EnumWindows(@EnumWindowsProc, 0);

Regards, Madshi.
0
 
MadshiCommented:
I'm not sure what you want. Can you please say it again a bit more detailed?
0
 
voxelAuthor Commented:
Edited text of question.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
MadshiCommented:
Redraw or resize?

To enumerate all windows use "EnumWindows". To resize the windows use "SetWindowPos". To refresh them use "InvalidateRect".
0
 
voxelAuthor Commented:
and how I use the EnumWindows function ?
0
 
intheCommented:
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;
0
 
voxelAuthor Commented:
I think you didn't understand my question.
0
 
voxelAuthor Commented:
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
0
 
voxelAuthor Commented:
Do you know how to resize all windows to fit the new work area (desktop) set by my application ?
0
 
MadshiCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.