Tuesday, 15 November 2011
Home »
Tips and Trick Delphi
» Refresh Desktop with Delphi
Refresh Desktop with Delphi
To Share | Tuesday, 15 November 2011
Tricks refresh Windows desktop.
Declaration procedure:
RefreshDesktop procedure;
var
desktopHwnd: hWnd;
s: String;
begin
/ / Handle Desktop
desktopHwnd: = FindWindow ('ProgMan', nil);
desktopHwnd: = GetWindow (desktopHwnd, GW_CHILD);
desktopHwnd: = GetWindow (desktopHwnd, GW_CHILD);
SetLength (s, 40);
GetClassName (desktopHwnd, PChar (S), 39);
if PChar (S) <> 'SysListView32' then desktopHwnd: = 0;
/ / Refresh
PostMessage (desktopHwnd, WM_KEYDOWN, VK_F5, 0);
PostMessage (desktopHwnd, WM_KEYUP, VK_F5, 1 SHL 31);
SendMessage (desktopHwnd, WM_COMMAND, $ A065, 0);
InvalidateRect (desktopHwnd, nil, True);
end;
Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
RefreshDesktop;
end;
No comments:
Post a Comment