Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide window shadow

I made a program in Delphi that watches for a window and make it invisible when it is created. The window became invisible correctly but its shadow remains forever on the desktop (until next restart). The window I want to hide it is the today tooltip that you can see when holding the mouse on the time in systray in Windows 7 & 8. How can I hide the shadow?

This is the code:

h := FindWindow('ClockTooltipWindow', nil);
if (IsWindow(h)) then ShowWindow(h, SW_HIDE);

This is a picture of remaining shadows:
enter image description here

like image 748
Vahid Avatar asked Jul 22 '26 20:07

Vahid


1 Answers

It's an interesting/very sticking artifact, possibly the shadow gets some special treatment from the video driver. I don't know why/how it happens, maybe the tooltip just doesn't care removing its shadow when it is about to be destroyed once it is hidden.

As a workaround you can resize the tooltip before hiding to a size that it won't draw its shadow, like:

h := FindWindow('ClockTooltipWindow', nil);
if (IsWindow(h)) then begin
  SetWindowPos(h, 0, 0, 0, 1, 1, SWP_NOMOVE or SWP_NOACTIVATE);
  ShowWindow(h, SW_HIDE);
end;

However the better approach in my opinion would be to nicely ask it be gone:

h := FindWindow('ClockTooltipWindow', nil);
if (IsWindow(h)) then 
  PostMessage(h, WM_SYSCOMMAND, SC_CLOSE, 0);
like image 110
Sertac Akyuz Avatar answered Jul 25 '26 14:07

Sertac Akyuz