CreateWindow returns NULL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Adams

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

    }


  • Joona I Palaste

    #2
    Re: CreateWindow returns NULL

    Jeff Adams <e@mail.com> scribbled the following:[color=blue]
    > 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,[/color]
    [color=blue]
    > GetModuleHandle (NULL), NULL, NULL, NULL, NULL,[/color]
    [color=blue]
    > "TestWindow ", NULL };[/color]

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

    --
    /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
    \-------------------------------------------------------- rules! --------/
    "We're women. We've got double standards to live up to."
    - Ally McBeal

    Comment

    • Flash Gordon

      #3
      Re: CreateWindow returns NULL

      Jeff Adams wrote:[color=blue]
      > 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?[/color]

      <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.

      Comment

      Working...