469,643 Members | 1,514 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

CreateWindow returns NULL

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

}
Nov 14 '05 #1
2 3157
Jeff Adams <e@mail.com> scribbled the following:
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.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"We're women. We've got double standards to live up to."
- Ally McBeal
Nov 14 '05 #2
Jeff Adams wrote:
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.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Rene van Hoek | last post: by
5 posts views Thread by VBTricks.de.vu Webmaster | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.