Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Oct : Taskbar - Hooking messages
| Subject: | Taskbar - Hooking messages |
| Posted by: | "Andrew Jameson" (softspotsoftwareno@spamgmail.com) |
| Date: | Thu, 19 Oct 2006 15:18:57 |
Hi,
I thought we'd got this right ...
The problem - to permanently kill the windows taskbar while our application
is running and all associated mouse click activity that can bring up the
start menu. The standard approach to do a
ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_HIDE) is no good : it
doesn't stop access to the start menu and lots of applications seem to like
sending ShowWindow messages to the TaskBar to turn it back on again -
especially stuff like Sygate's firewall. The only way that we found to
prevent the start menu popping up was to reparent the start button to 0.
I guess that we could keep polling the taskbar with a timer to keep turning
it off but we thought it better to hook the taskbar and kill all its
messages and we thought that we'd got it with the following code snippet.
It all worked fine ... until ... there's a screen resolution change ... at
that moment, explorer.exe reports 100% cpu activity and after that it's all
downhill as the machine then plunges into cpu exhaustion !
OK ... is there a better approach that doesn't involve a DLL hook ? ... or
does anyone know how we should modify our message handling for the taskbar
to avoid this problem ?
Many thanks,
Andrew
function TaskbarHide : boolean; stdcall;
var
TaskbarPID : DWORD;
begin
if (fTaskbarHookHandle = 0) then begin
ShowWindow(fTaskbarHandle, SW_HIDE);
TaskbarPID := GetWindowThreadProcessID(fTaskbarHandle, nil);
if (TaskbarPID <> 0) then
fTaskbarHookHandle:= SetWindowsHookEx(WH_GETMESSAGE, TaskbarMsgFunc,
hInstance, TaskbarPID);
end; {if}
Result := (fTaskbarHookHandle <> 0);
end;
function TaskbarMsgFunc(Code : integer; wParam, lParam : integer) : integer;
begin
if (Code = HC_ACTION) and (wParam <> PM_NOREMOVE) then begin
if IsWindowVisible(fTaskbarHandle) then
ShowWindow(fTaskbarHandle, SW_HIDE);
PMsg(lParam)^.message := WM_NULL;
end; {if}
Result := CallNextHookEx(fTaskbarHookHandle, Code, wParam, lParam);
end;
{--------------------------------------------------------------------------------------------------}
initialization
fTaskbarHandle := FindWindow('Shell_TrayWnd', nil);