i need to get the handle to the top window from any other app. GetActiveWindow needs my prog to be in the same thread so that doesnt work.
Any ideas? Please help.
Printable View
i need to get the handle to the top window from any other app. GetActiveWindow needs my prog to be in the same thread so that doesnt work.
Any ideas? Please help.
How about FindWindow()?
i know about that but i need to get the handle without knowing the window name or class name.
Here's some other window handle returning fns to look into - if you haven't already done so:
1. WindowFromPoint
2. WindowFromDC
3. GetWindow.
4. EnumChildWindows (wnd handle sent to EnumChildProc
)
5. EnumWindows (wnd handle sent to EnumWindowsProc
)
How can I use Enum windows for Win3.x app? And not crash...
What's the correct way to use it, when to put it? Loop is ideal for this application, is it?
According to the SDK you need 95 or NT3.1 AT LEAST........Quote:
Originally posted by _Unregistered_
How can I use Enum windows for Win3.x app? And not crash...
What's the correct way to use it, when to put it?
Why are you using such an outdated OS?
Nope....you need a callback....if you have an os that allows this fuction you would do something along the lines ofQuote:
Originally posted by _Unregistered_
Loop is ideal for this application, is it?
Code:#include <windows.h>
#include <iostream>
using namespace std;
BOOL CALLBACK EnumProc(HWND hwnd,LPARAM lParam);
int nNoWnd = 0;
int main(void)
{
cout << "Enumerating..." << endl;
EnumWindows((WNDENUMPROC) EnumProc,NULL);
cout << "Total of " << nNoWnd << " windows" << endl;
return 0;
}
BOOL CALLBACK EnumProc(HWND hwnd,LPARAM lParam)
{
char buff[MAX_PATH+1];
if(GetWindowText(hwnd,buff,MAX_PATH+1) <= 0)
cout << "\"No Title\"" << endl;
else
cout << buff << endl;
nNoWnd++;
return TRUE;
}
thanks for the code. outdated OS? just my outdated compiler. :)