CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: DialogBox Error

  1. #1
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    DialogBox Error

    I'm getting an error 1421 "Control ID Not Found" when adding a TAB Control to my dialog. If I delete the TAB Control from my dialog it works fine. All the IDC's seems to be fine.

    I've tried to use SPY++ but the TAB Control never shows up there, all the other controls are fine.

    I'm using Visual C++ 2003.

  2. #2
    Join Date
    Apr 1999
    Posts
    3,585

    Re: DialogBox Error

    Are you adding it through the resource editor? If so, I'd try deleting the corresponding .res and .aps files. Then recompile the resource files. These files are rebuilt each time. If these files get out of sync, they may casue such a problem.
    Gort...Klaatu, Barada Nikto!

  3. #3
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    That didn't do it...I've searched everywhere for a solution. I found one entry in here about this issue from 2001, but no one could help there either.

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: DialogBox Error

    That appears to be a runtime error. What function are you calling that generates that error?

  5. #5
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    Code:
    	int result = DialogBox(m_hInstance, pstrTemplate, hwndParent, ScreenSettingsDlgProcStub );
    The result is -1, but the GetLastError() returns 1421.

    But it's probably this function that returns the 1421:
    Code:
    INT_PTR CD3DApplication::ScreenSettingsDlgProc( HWND hWnd, UINT uMsg, 
                                                    WPARAM wParam, LPARAM lParam )
    {
        HWND hwndTabs = GetDlgItem(hWnd, IDC_MONITORSTAB);
        ...
    Last edited by Johndc; December 15th, 2004 at 11:53 AM.

  6. #6
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    I did get most of this code from a DX9 Sample Framework, so I know it works. The difference between the Sample Framework and my code is that wrapped it inside a DLL.
    The wierd thing is that the Dialog seems to work fine without the TAB Control, but when I add the TAB Control it errors.

  7. #7
    Join Date
    Jan 2002
    Location
    Houston, TX
    Posts
    1,421

    Re: DialogBox Error

    Is your dialog box template stored in the resource file? Also, what is the content of the pstrTemplate?

    You may need to use MAKEINTRESOURCE to create your dialog box.

    According to MSDN (emphasis added)
    lpTemplate
    [in] Specifies the dialog box template. This parameter is either the pointer to a null-terminated character string that specifies the name of the dialog box template or an integer value that specifies the resource identifier of the dialog box template. If the parameter specifies a resource identifier, its high-order word must be zero and its low-order word must contain the identifier. You can use the MAKEINTRESOURCE macro to create this value.
    Hope that helps.
    Be sure to rate those who help!
    -------------------------------------------------------------
    Karl - WK5M
    PP-ASEL-IA (N43CS)
    PGP Key: 0xDB02E193
    PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

  8. #8
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    Yes I do that just before I call the DialogBox Function. I created the Dialog in the Resource Editor.

    Code:
        LPCTSTR pstrTemplate;
    
        pstrTemplate = MAKEINTRESOURCE( IDD_MULTIMONITORSETTINGS );
        int result = DialogBox(m_hInstance, pstrTemplate, hwndParent, ScreenSettingsDlgProcStub );

  9. #9
    Join Date
    Jan 2002
    Location
    Houston, TX
    Posts
    1,421

    Re: DialogBox Error

    You might look at your resource.h file. Search for IDD_MULTIMONITORSETTINGS in there and note the number.

    Then check to be sure that there is no other entry with the same number.

    Good luck.
    Be sure to rate those who help!
    -------------------------------------------------------------
    Karl - WK5M
    PP-ASEL-IA (N43CS)
    PGP Key: 0xDB02E193
    PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

  10. #10
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    I assigned all the numbers myself. I added the defines to d3dres.h, then re-used the same numbers in my resource.h file in the main exe project.

    Still no luck
    Last edited by Johndc; December 15th, 2004 at 04:32 PM.

  11. #11
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    I've attached a little sample app that illustrates my problem.
    Try compiling it and then run it. The app will not display a dialog, but if you edit the dialog and delete the TAB Control leaving all the other controls there and then compile and run it, the dialog pops up fine.

    Am I missing something?
    Attached Files Attached Files

  12. #12

    Re: DialogBox Error

    Tab Controls need to have InitCommonControls called (or InitCommonControlsEx with ICC_TAB_CLASSES flag set).

    Include this in your main.cpp after the other includes:

    #include <commctrl.h>
    #pragma comment( lib, "comctl32.lib" )

    And at the beginning of your LaunchDialog function call

    InitCommonControls();

    The dialog works. The content of the dialog looks a bit weird though (group boxes under the tab control are drawn on top).

  13. #13
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    Thanks Endurion,
    This seems to do the trick...

    The app was just an example, I didn't add all the functionality to the dialog. The original projects has many more controls and code to handle them.

    Anyway, I appreciate your time to look at my problem.

    Thanks,
    John
    Last edited by Johndc; December 16th, 2004 at 10:40 AM.

  14. #14
    Join Date
    Dec 2003
    Location
    Simi Valley, CA
    Posts
    24

    Re: DialogBox Error

    I guess I learned something new today ... I don't have to use InitCommonControlsEx(), I could add a manifest instead.

    From msdn:
    Windows XP: If a manifest is used, InitCommonControlsEx is not required

    This is a manifest from a DX sample framework:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity
    version="1.0.0.0"
    processorArchitecture="X86"
    name="Microsoft.DirectX SDK"
    type="win32"
    />
    <description>DirectX SDK Sample Program.</description>
    <dependency>
    <dependentAssembly>
    <assemblyIdentity
    type="win32"
    name="Microsoft.Windows.Common-Controls"
    version="6.0.0.0"
    processorArchitecture="X86"
    publicKeyToken="6595b64144ccf1df"
    language="*"
    />
    </dependentAssembly>
    </dependency>
    </assembly>

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured