Board index » cppbuilder » Dual monitors. Minimize all window from one of them

Dual monitors. Minimize all window from one of them


2007-02-01 06:56:11 AM
cppbuilder38
Hi,
I'm trying to write a small program that can minimizes all the
tasks that are in the task manager but only for one of the monitors
that I have. (I have 2 monitors using extended desktop)
What I need basically is the what Show desktop does, but instead of
doing it for all the windows in every monitor, just for one.
Is that possible?
I have tried using Enumwindows, but I get a huge list of windows and
not the ones that are in the taskbar.
Thanks
 
 

Re:Dual monitors. Minimize all window from one of them

"Star" < XXXX@XXXXX.COM >wrote in message
Quote
I have tried using Enumwindows, but I get a huge list of
windows and not the ones that are in the taskbar.
You are not taking into account that EnumWindows() returns all
available top-level windows, including hidden windows, regardless of
monitor. If you only want windows that appear in the TaskBar, then
use GetWindowLong() to filter out the HWNDs that do not have the
WS_EX_APPWINDOW style. To filter out HWNDs by specific monitor, use
MonitorFromWindow() as well.
Gambit
 

Re:Dual monitors. Minimize all window from one of them

Hi Remy,
Thanks for your answer. Ok, I have tried this:
BOOL CALLBACK ewp(HWND hwnd, LPARAM lParam)
{
long exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
if(exstyle & WS_EX_APPWINDOW)
{
int length = GetWindowTextLength(hwnd);
char *ch = new char[length];
GetWindowText(hwnd, ch, length);
Form1->Memo1->Lines->Add(ch);
delete[] ch;
}
return true;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
EnumWindows((WNDENUMPROC)ewp, NULL);
}
For some reason it shows windows that were close sometime ago and it
doesn't show the tasks that I have currently in the taskbar.
Am I missing something?
Thanks
Remy Lebeau (TeamB) wrote:
Quote
"Star" < XXXX@XXXXX.COM >wrote in message
news:45c11e55$ XXXX@XXXXX.COM ...

>I have tried using Enumwindows, but I get a huge list of
>windows and not the ones that are in the taskbar.

You are not taking into account that EnumWindows() returns all
available top-level windows, including hidden windows, regardless of
monitor. If you only want windows that appear in the TaskBar, then
use GetWindowLong() to filter out the HWNDs that do not have the
WS_EX_APPWINDOW style. To filter out HWNDs by specific monitor, use
MonitorFromWindow() as well.


Gambit


 

{smallsort}

Re:Dual monitors. Minimize all window from one of them

"Star" < XXXX@XXXXX.COM >wrote in message
Quote
For some reason it shows windows that were close sometime ago
Then they are not fully closed.
Quote
it doesn't show the tasks that I have currently in the taskbar.
I never said that WS_EX_APPWINDOW by itself would tell you all of the
items that are actually in the TaskBar. Only windows with the
WS_EX_APPWINDOW style are allowed to appear in the TaskBar, but that
is not a guarantee that they actually will appear. One thing you can
do is query the window's Owner window. If an WS_EX_APPWINDOW window
has no owner, then it will appear in the TaskBar.
One thing to keep in mind is that a window's TaskBar button may be
managed by another window instead (and the VCL actually does this).
So it may be that a given window does not have the WS_EX_APPWINDOW
style, but it may have a hidden owner window that does.
Gambit