![]() |
| | #1 |
| Math wizard Join Date: Dec 2006 Location: Minot, ND, USA
Posts: 516
| Window class not found - why? Code: // Window definitions
HWND WindowHandle; // window handle
WNDCLASSEX WindowClass; // window class
// in the WinMain function, first thing
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.style = CS_HREDRAW | CS_VREDRAW;
WindowClass.lpfnWndProc = WndProc;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hInstance = hInstance;
WindowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WindowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WindowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
WindowClass.lpszMenuName = NULL;
WindowClass.lpszClassName = "MyClass";
WindowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
// Register the window class
if (!RegisterClassEx(&WindowClass);)
{
DebugTest[19] = (double)GetLastError();
return 1;
}
WindowHandle = CreateWindowW("MyClass",
"Platform Masters 1.0 (development version)",
WS_OVERLAPPEDWINDOW |
WS_VISIBLE |
WS_SYSMENU,
WindowPos.x, WindowPos.y,
WindowSize.x, WindowSize.y,
NULL,
NULL,
hInstance,
NULL);
DebugTest[19] = (double)GetLastError(); // returns 1407 - cannot find class
if (WindowHandle == 0)
{
return 0;
}
__________________ High elevation is the best elevation. The higher, the better the view! My computer: XP Pro SP3, 3.17 GHz C2D CPU, 4 GB DDRII800 RAM (3 GB effective), X-Fi Platinum sound, GeForce 7600 GT, 1920x1440 resolution, 250 GB HDD, Visual C++ 2008 Express |
| ulillillia is offline | |
| | #2 |
| Registered User Join Date: Dec 2007
Posts: 146
| The code you posted has errors. Code: if (!RegisterClassEx(&WindowClass);) <<------ ; shouldn't be there Last edited by DaveH; 05-08-2009 at 08:54 AM. |
| DaveH is offline | |
| | #3 |
| Registered User Join Date: Jan 2009
Posts: 31
| You're calling CreateWindowW, not CreateWindowA, so your class name parameter should be L"MyClass" (note the L prefix), not "MyClass". Also, although it may not be an issue depending on exactly how you're compiling the file, your "MyClass" in the context of WindowClass.lpszClassName = "MyClass" really should be _T("MyClass") (which expands to "MyClass" or L"MyClass", depending on the UNICODE preprocessor definition). Read up on CreateWindow. Any literal parameter that is LPTSTR or LPCTSTR should be written as "XXXX" if calling CreateWindowA, L"XXXX" if calling CreateWindowW, or _T("XXXX") if calling CreateWindow (which is just defined to be CreateWindowA or CreateWindowW, depending on UNICODE and/or _UNICODE). Last edited by tjb; 05-10-2009 at 01:09 AM. |
| tjb is offline | |
| | #4 | |
| int x = *((int *) NULL); Join Date: Jul 2003 Location: Banks of the River Styx
Posts: 891
| Quote:
LPTSTR, LPCTSTR - _T("XXXX") - Found in structures, mostly. LPSTR, LPCSTR - "XXXX" - Found in the A versions of the functions, ie, CreateWindowA LPWSTR, LPCWSTR - L"XXXX" - Found in the W versions of the functions, ie, CreateWindowW
__________________ long time; /* know C? */ Unprecedented performance: Nothing ever ran this slow before. Any sufficiently advanced bug is indistinguishable from a feature. Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31. The best way to accelerate an IBM is at 9.8 m/s/s. recursion (re - cur' - zhun) n. 1. (see recursion) | |
| Cactus_Hugger is offline | |
![]() |
| Tags |
| class, not found, window, wndclassex |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Message class ** Need help befor 12am tonight** | TransformedBG | C++ Programming | 1 | 11-29-2006 11:03 PM |
| Why only 32x32? (OpenGL) [Please help] | Queatrix | Game Programming | 2 | 01-23-2006 02:39 PM |
| Linking OpenGL in Dev-C++ | linkofazeroth | Game Programming | 4 | 09-13-2005 10:17 AM |
| Pong is completed!!! | Shamino | Game Programming | 11 | 05-26-2005 10:50 AM |
| OpenGL Window | Morgul | Game Programming | 1 | 05-15-2005 12:34 PM |