Jump to content
  • Advertisement
Sign in to follow this  
RenderTarget

CreateDialog fails, GLE() == 0

This topic is 5457 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Odd behavior in Windows: I'm calling CreateDialog() which returns NULL (failure), but calling GetLastError() returns 0 (success).
	m_winCtl = CreateDialog( hInstance, MAKEINTRESOURCE( ID_DIALOG ), hParent, DlgProcCtl );
	if( NULL == m_winCtl )
	{
		DWORD iErr = GetLastError();
		WCHAR sErr[ 256 ];
		wnsprintf( sErr, 255, L"WinCtl::CreateWin(): CreateDialog() failed: %d", iErr );
		throw CExDice( sErr );
	}
The .rc file looks fine too:
...
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

ID_DIALOG DIALOGEX 0, 0, 128, 314
style DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | 
    WS_SYSMENU | WS_BORDER
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    EDITTEXT        IDC_EDIT1,7,7,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN1,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,7,11,14
    EDITTEXT        IDC_EDIT2,7,26,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN2,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,26,11,14
    EDITTEXT        IDC_EDIT3,7,45,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN3,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,45,11,14
    EDITTEXT        IDC_EDIT4,7,64,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN4,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,64,11,14
    EDITTEXT        IDC_EDIT5,7,83,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN5,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,83,11,14
    EDITTEXT        IDC_EDIT6,7,102,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN6,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,102,11,14
    EDITTEXT        IDC_EDIT7,7,121,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN7,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,121,11,14
    EDITTEXT        IDC_EDIT8,7,140,31,14,ES_AUTOHSCROLL
    CONTROL         "",IDC_SPIN8,"msctls_updown32",UDS_AUTOBUDDY | 
                    UDS_ARROWKEYS,38,140,11,14
    LTEXT           "d4",IDC_STATIC,64,9,9,8
    LTEXT           "d6",IDC_STATIC,64,28,9,8
    LTEXT           "d8",IDC_STATIC,64,47,9,8
    LTEXT           "d10",IDC_STATIC,64,66,13,8
    LTEXT           "d12",IDC_STATIC,64,85,13,8
    LTEXT           "d20",IDC_STATIC,64,104,13,8
    LTEXT           "d30",IDC_STATIC,64,123,13,8
    LTEXT           "d100",IDC_STATIC,64,142,17,8
    COMBOBOX        IDC_COMBO_PROFILE,7,160,114,73,CBS_DROPDOWN | CBS_SORT | 
                    WS_VSCROLL | WS_TABSTOP
    EDITTEXT        IDC_EDIT_RESULTS,7,179,114,128,ES_MULTILINE | 
                    ES_AUTOHSCROLL | WS_VSCROLL
END
...

Anyone run into this?

Share this post


Link to post
Share on other sites
Advertisement
Check to make sure your hInstance isn't NULL first, I suppose.

If CreateDialog (or its cohorts) fails with nothing on GetLastError, it's usually because a child control failed, not because your dialog in genearl failed. You can either try getting rid of some controls temporarily to see if you can get the blank dialog up and work up from there, or you can use DS_NOFAILCREATE and, well, see where it crashes next ;)

That can usually help you find the errant child control.

-fel

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
make sure that you are calling InitCommonControlsEx before the dialog creation call, in your case using the ICC_UPDOWN_CLASS flag.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!