Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EnumWindows & EnumWindowsProc

1 view
Skip to first unread message

EYutz

unread,
Nov 8, 2001, 12:46:12 PM11/8/01
to
Well, I was able to figure it out on my own. The code is not pretty, but it
works. :)

BOOL CALLBACK EnumFunc(HWND hMywnd, LPARAM lParam );

HWND hWnd;

BOOL CALLBACK EnumFunc(HWND hMywnd, LPARAM lParam )

{

char szBuffer[_MAX_PATH];

::GetWindowText(hMywnd,szBuffer,_MAX_PATH - 1);

if(strstr(szBuffer,(char *)lParam)) {

CWnd *pFacilityWnd;

pFacilityWnd = CWnd::FindWindow(NULL,szBuffer);

if (pFacilityWnd != NULL) {

pFacilityWnd->SendMessage(WM_CLOSE);

}

}

return true;

}

char * szTitle ="myapp";

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])

{

int nRetCode = 0;

if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))

{

cerr << _T("Fatal Error: MFC initialization failed") << endl;

nRetCode = 1;

}

else

{

::EnumWindows(EnumFunc, (LPARAM)szTitle);

}

return nRetCode;

}

"EYutz" <ejyutz@_NOTSO_hotmail.com> wrote in message
news:qpBF7.16669$jP3.4...@e3500-atl1.usenetserver.com...
> Greetings,
> I need a simple example of the use of EnumWindows and EnumWindowsProc.
I
> have used FindWindow and SendMessage to close a window, but this does not
> work when I dont know the whole "name" of the window (they are all
> basically: myapp 123456789; myapp 212345678; ect. Everything I have found
is
> either a function definition or the code is part of a large program as
part
> of different classes or functions.
>
> Any hints would be greatly appreciated.
>
> Ed Yutz
>
>
>

0 new messages