Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateWindow (for newbie)

Status
Not open for further replies.

hencox

Technical User
Sep 5, 2001
6
SE
Hi!

I'm trying to create an invisible window using CreateWindow(). Which is the easiest way to do this? I've had a look at the parameters of this call. I think some of them are cryptic (like lpClassName and hInstance). I've also tried calling this function, but I always get error #1407 (ERROR_CANNOT_FIND_WND_CLASS). Are there any #defines that would help me get past parameters like
Code:
lpClassName
and
Code:
hInstance
?

Thanks
Henrik
 
lpClassName is the name of a registered windows class ie...
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) CaliWndProc;
wc.hIcon = LoadIcon(hInst,IDI_CAL);
wc.cbClsExtra = 0;
wc.cbWndExtra = DLGWINDOWEXTRA;
wc.hInstance = hinstance;
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH) COLOR_WINDOW + 1;
wc.lpszMenuName = "myMenu";
wc.lpszClassName = "myWindowClass";

/* Register the window class and return success/failure code. */

if (!RegisterClass(&wc))
return FALSE ;

hinstance is the handle to the instance of the module to be associated with the window...the first parameter of WinMain or if using MFC..the m_hInstance member of your CWinApp.
 
Thanks! :)
Are there any pre-defined registered window classes I can use, so that I won't have to fill in that entire struct?

Currently my application is a console. Maybe I need to change its type to WinMain?

Regards
Henrik


 
yup...every window on the system has an associated registered class...combo boxed edit boxes and the like...
the predefined system ones are...as far as I remember...
COMBOBOX
EDIT
LISTBOX
MDICLIENT
RichEdit
RICHEDIT_CLASS
SCROLLBAR
STATIC
BUTTON

fix to the above...
I ripped the above from some old code...sould read...
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.lpfnWndProc = (WNDPROC) MainWndProc;
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top