Article View: borland.public.cppbuilder.nativeapi
Article #1240Re: Enumerating windows like ALT+TAB
From: Remy Lebeau (TeamB)
Date: Tue, 16 Oct 2007 16:52
Date: Tue, 16 Oct 2007 16:52
52 lines
2564 bytes
2564 bytes
"Patryk B." <pbobak@no.spam.o2.pl> wrote in message
news:op.t0algg2iwzezly@dune.intranet...
> EnumDesktopWindows(NULL,(WNDENUMPROC)EnumWindowsProc,(LPARAM)ListView1);
Since you are not specifying anything for the HDESK parameter, use
EnumWindows() instead.
> ListView->Items->Add();
> int i=ListView->Items->Count-1;
> ListView->Items->Item[i]->Caption=AnsiString(WindowName);
> ListView->Items->Item[i]->Update();
Rather than indexing into the Items[] property over and over, use the
TListItem that Add() returns instead:
TListItem *Item = ListView->Items->Add();
Item->Caption=AnsiString(WindowName);
Item->Update();
> But it show more window than alt+tab
That is because you are not doing any kind of filtering of the windows. Not
all windows appear in the Alt+Tab dialog, but you are not checking for the
same kind of conditions that the dialog looks for.
Try this instead:
void __fastcall TForm6::Button1Click(TObject *Sender)
{
ListView1->Items->Clear();
EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)ListView1);
}
bool CALLBACK EnumWindowsProc(HWND hWnd, TListView *ListView)
{
if( IsWindowVisible(hWnd) &&
(GetWindow(hWnd, GW_OWNER) == NULL) &&
((GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) == 0) )
{
char WindowName[256] = {0};
GetWindowText(hWnd, WindowName, 255);
ListView->Items->Add()->Caption = WindowName;
}
return TRUE;
}
Gambit
Technical Details
Message-ID:
<4714ec72$3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<op.t0algg2iwzezly@dune.intranet>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ce29f3644d77d8f6 X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <op.t0algg2iwzezly@dune.intranet> Subject: Re: Enumerating windows like ALT+TAB Date: Tue, 16 Oct 2007 09:52:19 -0700 Lines: 54 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 207.178.157.90 Message-ID: <4714ec72$3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1192553586 207.178.157.90 (16 Oct 2007 09:53:06 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail