J
Jeff Adams
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(WNDCLASSEX), CS_CLASSDC, MsgProc, 0, 0,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"TestWindow", NULL };
RegisterClassEx(&wc);
if(NULL==(hWnd = CreateWindow("TestWindow", "Window",
WS_POPUP, 100, 100, 300, 300,
GetDesktopWindow(), 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)lpMsgBuf, "Error", MB_OK |
MB_ICONINFORMATION );
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(WNDCLASSEX), CS_CLASSDC, MsgProc, 0, 0,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"TestWindow", NULL };
RegisterClassEx(&wc);
if(NULL==(hWnd = CreateWindow("TestWindow", "Window",
WS_POPUP, 100, 100, 300, 300,
GetDesktopWindow(), 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)lpMsgBuf, "Error", MB_OK |
MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
}