CreateDialog Failed, but GetLastError return 0
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: CreateDialog Failed, but GetLastError return 0

  1. #1
    Join Date
    Dec 2005
    Posts
    2

    CreateDialog Failed, but GetLastError return 0

    I want to create a modeless dialog in WinXP using .net 2003

    code:

    ///////////////////////////////////////////////////////////////////////////
    HWND hwnd;
    hwnd = CreateDialog( ::g_hInstance, MAKEINTRESOURCE( IDD_CONTROL_PANEL ), NULL, ControlPanelProc );

    if( NULL == hwnd ){

    DWORD dwerr = GetLastError();
    }

    ///////////////////////////////////////////////////////////////////////////////
    when running the program, hwnd is NULL, and dwerr == 0 ( no error! ).
    the same code segment works in another program
    how to solve the problem, thanks for any help and advice.

  2. #2
    Join Date
    May 2005
    Posts
    4,951

    Re: CreateDialog Failed, but GetLastError return 0

    Quote Originally Posted by FatGarfield
    I want to create a modeless dialog in WinXP using .net 2003

    code:

    ///////////////////////////////////////////////////////////////////////////
    HWND hwnd;
    hwnd = CreateDialog( ::g_hInstance, MAKEINTRESOURCE( IDD_CONTROL_PANEL ), NULL, ControlPanelProc );

    if( NULL == hwnd ){

    DWORD dwerr = GetLastError();
    }

    ///////////////////////////////////////////////////////////////////////////////
    when running the program, hwnd is NULL, and dwerr == 0 ( no error! ).
    the same code segment works in another program
    how to solve the problem, thanks for any help and advice.
    are you sure that in the resource file there is IDD_CONTROL_PANEL template dialog? and its not just declared in resource.h ?

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Dec 2005
    Posts
    2

    Talking Re: CreateDialog Failed, but GetLastError return 0

    I found where the error comes from. If you forgot to link comctl32.lib, but in the dialog template List control or Tree control exists, you'll get NULL window handle, but with error code 0.

    thank you
    golanshahar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center