Re: Register an App with windows
"David Lowndes" <DavidL@example.invalid> wrote in message
news:jur396pelp9tabis5a2tde6csu5c4ac8in@4ax.com...
I have never used Spy++ before - I'm just trying it out now. Not sure how
to
use it...
Persist with it - it's invaluable!
That was my actual code!!
Not quite, FindWindow has 2 parameters! :)
The
searching code in question is:
while (FindWindow(_T("CircaApp"), NULL) == 0)
Sleep(100);
That's more like it.
Have you managed to check what your top level window class name is
using Spy++?
Not sure! I have found my window, but it seems to report a class name of
"Afx:00400000:8:00010011:00000000:00700647", instead of "CircaApp", which
implies that my AfxRegisterClass(&wndcls) call isn't doing what I want it
to. The code I'm using was lifted from an online demo somewhere. It looks
like this:
// Register the class, so that FindWindow can find us.
WNDCLASS wndcls;
memset(&wndcls, 0, sizeof(WNDCLASS)); // start with NULL defaults
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.hInstance = AfxGetInstanceHandle();
wndcls.hIcon = LoadIcon(IDR_MAINFRAME); // or load a different icon
wndcls.hCursor = LoadCursor( IDC_ARROW );
wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndcls.lpszMenuName = NULL;
// Specify your own class name for using FindWindow later
wndcls.lpszClassName = _T("CircaApp");
// Register the new class and exit if it fails
if(!AfxRegisterClass(&wndcls))
{
TRACE("Circa Class Registration Failed\n");
return false;
}