Post by SteveD » 11.12.2010 18:17:47
It's really quite the hack. My utility runs in systray, and when activated, it (systray) steals focus. So, to find the app window that needs resizing, I re-acquire the desktop stack, and walk through the window z-order until I find the most recent one that has a name, is visible, etc. The handle that is returned is the one that I resize (see code below). It works quite nicely.
It is no doubt important for Dexpot Desktop Manager to do whatever it's doing. Obviously, controlling multiple desktops requires some amount of control over the z-order. That's cool. I was just hoping that I wouldn't have to revisit my 12 year old utility. Oh well - if it's that important to me, maybe I will...
Thank you very much for your reply Patrick! And just so you know, Dexpot is pretty nice - I really think it will replace my use of PerfectScreens.
HWND GetPriorTopWindow()
{
HWND hwnd;
char buff[2];
hwnd = GetDesktopWindow();
hwnd = GetTopWindow(hwnd);
while ((GetWindowText(hwnd, buff, 2) == 0) || (GetParent(hwnd) != NULL) || !IsWindowVisible(hwnd))
hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
OutputDebugString(GetWindowInfo(g_hprevwnd, g_buff, sizeof(g_buff)));
return hwnd;
}
It's really quite the hack. My utility runs in systray, and when activated, it (systray) steals focus. So, to find the app window that needs resizing, I re-acquire the desktop stack, and walk through the window z-order until I find the most recent one that has a name, is visible, etc. The handle that is returned is the one that I resize (see code below). It works quite nicely.
It is no doubt important for Dexpot Desktop Manager to do whatever it's doing. Obviously, controlling multiple desktops requires some amount of control over the z-order. That's cool. I was just hoping that I wouldn't have to revisit my 12 year old utility. Oh well - if it's that important to me, maybe I will...
Thank you very much for your reply Patrick! And just so you know, Dexpot is pretty nice - I really think it will replace my use of PerfectScreens.
HWND GetPriorTopWindow()
{
HWND hwnd;
char buff[2];
hwnd = GetDesktopWindow();
hwnd = GetTopWindow(hwnd);
while ((GetWindowText(hwnd, buff, 2) == 0) || (GetParent(hwnd) != NULL) || !IsWindowVisible(hwnd))
hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
OutputDebugString(GetWindowInfo(g_hprevwnd, g_buff, sizeof(g_buff)));
return hwnd;
}