--- In [email protected], "p.renfrew" <p.renf...@...> wrote:

> My bar has transparency 255. mainhandlefrompoint() returns the desktop handle 
> if that point within my bar is a transparent point. Can I dynamically figure 
> out what points are not transparent in my bar after moving it around?  (I was 
> just using win.left/top).


I am trying to avoid an endless timer loop since I really dislike them, so my 
latest attempt sets a hook on the system foreground event in my dummy test app. 
 The "WorkerW" class comes to the front on toggleDesktop() (there are many 
WorkerW's, but only one has a Client Size the same as my desktop -- I don't 
know what happens on multi monitors, so I just handle all WorkerW's in this 
test).

http://msdn.microsoft.com/en-us/library/dd373640%28VS.85%29.aspx

SetForegroundWindow doesn't work on Vista or Win7 (I guess it was abused and MS 
wanted to limit it), so I use the SetWindowPos workaround posted here:

http://www.codeguru.com/forum/showthread.php?t=417671

The goal was to make a toolbarWindow that was not set topmost stay visible 
after a Show Desktop call.  This worked for me on XP and Win7 in my quick 
tests.  Can I accomplish this inside of PowerPro on my Bar? (setting the hook, 
making the callback, and removing the hook when the bar closes?)
  

void CALLBACK HandleWinEvent(HWINEVENTHOOK hook, DWORD event, HWND hwnd, LONG 
idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime) {
if (event == EVENT_SYSTEM_FOREGROUND) {
 TCHAR tmp[255];
 int r = GetClassName(hwnd, tmp, 250);
 if (wcscmp(tmp, L"WorkerW")==0) {
 for (int i = 0; i < 10; ++i) { // usually works on first try, but sometimes 
needs 2 or 3 
  //SetForegroundWindow(myHandle); //doesn't work on Vista/Win7
  SetWindowPos(myHandle, (HWND) -1, 0,0,0,0,3);
  SetWindowPos(myHandle, (HWND) -2, 0,0,0,0,67);
  if (myHandle == GetForegroundWindow()) break;
 }
}
}

HWINEVENTHOOK g_hook;
g_hook = SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, 
NULL, HandleWinEvent,0,0,0);
...
UnhookWinEvent(g_hook);


Reply via email to