I am using MSVC .NET to create a C program. I am having trouble creating a
window. The createwindow returns NULL however no error is caught. The
GetLastError() returns "operation completed successfully". So I'm not sure
what the deal is. CreateWindow doesn't have to be called from the main
function does it?
WNDCLASSEX wc = { sizeof(WNDCLASS EX), CS_CLASSDC, MsgProc, 0, 0,
GetModuleHandle (NULL), NULL, NULL, NULL, NULL,
"TestWindow ", NULL };
RegisterClassEx (&wc);
if(NULL==(hWnd = CreateWindow("T estWindow", "Window",
WS_POPUP, 100, 100, 300, 300,
GetDesktopWindo w(), NULL,
wc.hInstance, NULL )));
{
FormatMessage(
FORMAT_MESSAGE_ ALLOCATE_BUFFER |
FORMAT_MESSAGE_ FROM_SYSTEM |
FORMAT_MESSAGE_ IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG _NEUTRAL,
SUBLANG_DEFAULT ), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
MessageBox( NULL, (LPCTSTR)lpMsgB uf, "Error", MB_OK |
MB_ICONINFORMAT ION );
LocalFree( lpMsgBuf );
}
window. The createwindow returns NULL however no error is caught. The
GetLastError() returns "operation completed successfully". So I'm not sure
what the deal is. CreateWindow doesn't have to be called from the main
function does it?
WNDCLASSEX wc = { sizeof(WNDCLASS EX), CS_CLASSDC, MsgProc, 0, 0,
GetModuleHandle (NULL), NULL, NULL, NULL, NULL,
"TestWindow ", NULL };
RegisterClassEx (&wc);
if(NULL==(hWnd = CreateWindow("T estWindow", "Window",
WS_POPUP, 100, 100, 300, 300,
GetDesktopWindo w(), NULL,
wc.hInstance, NULL )));
{
FormatMessage(
FORMAT_MESSAGE_ ALLOCATE_BUFFER |
FORMAT_MESSAGE_ FROM_SYSTEM |
FORMAT_MESSAGE_ IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG _NEUTRAL,
SUBLANG_DEFAULT ), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
MessageBox( NULL, (LPCTSTR)lpMsgB uf, "Error", MB_OK |
MB_ICONINFORMAT ION );
LocalFree( lpMsgBuf );
}
Comment