CreateWindow returns NULL

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 );

}
 
J

Joona I Palaste

Jeff Adams said:
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 };

Your question is about system-specific extensions to C and therefore
off-topic on comp.lang.c. Please ask on
comp.os.ms-windows.programmer.win32.
 
F

Flash Gordon

Jeff said:
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?

<snip>

This is windows specific stuff, so please ask on a Windows group. Here
we only deal with standard C, not system specifics.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top