/GR- cl.exe option causes WM_INITDIALOG not to fire.

Project->Properties: Configuration Properties/C++/Language: Enable Run-Time Type Info = No (/GR-) causes WM_INITDIALOG not to fire when invoking DoModal() for a dialog instantiated from within OnInitialUpdate() of a single document MFC application (i.e., from within OnInitialUpdaet() for a subclass of CView). Compiling with /GR does not produce this problem. To reproduce this, use VS2005 to create a single document app, use the IDE to add OnInitialUpdate() to your CView subclass, create a test dialog, instantiate and invoke DoModal() for the test dialog from within OnInitialUpdate() for the CView subclass. Build using /GR- and invoke VS2005's debugger. Set the following break points: CWnd::CreateDlgIndirect() and line
line 26 of dlgcore.cpp:
        CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd));
 This line is inside AfxDlgProc() and is executed when WM_INITDIALOG is recieved. CWnd::CreateDlgIndirect() is what eventually causes the new dialog to become active and arranges for AfxDlgProc() to be invoked. See dlgcore.cpp, lines 441-441 (be sure that you are looking at the C:\Program Files\Microsoft Visual Studio 8\VC\ce\atlmfc\src\mfc\dlgcore.cpp version):
        hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
                pParentWnd->GetSafeHwnd(), AfxDlgProcEx);
When /GR- is present on the cl.exe command line, line 26 never fires. When /GR is present, it does.
This only happens with a CView app. It does not happen with a dialog-based app, as defined via VS2005's app wizard.

We would appreciate any insite anyone might have as to why this is happening, or if a fix is available for this issue. If someone from Microsoft would like a sample app, I'll be happy to send along a zipped set of solution/project files.

Thanks in advance.

p.s. I forgot to mention that although this option was No by default, /GR was still included in the cl.exe command line options list. We had to change from No to Yes, and back again to have /GR- appear on the cl.exe command line.



Answer this question

/GR- cl.exe option causes WM_INITDIALOG not to fire.

  • tim_baxter

    Yes, we are rebuilding the entire app each time a configuration change like this is made. I'll be glad to zip up an example and email to you. What is the best way to do this  I'll include a project file that has been set up and compiled with /GR-.


  • Glider

    Did you ever get a chance to look at the code that I sent you Thanks, Dave
  • MSatya

    Will do. I'm off today and have some running aroud to do. I'll send you a zip file a bit later today. Thanks in advance.
  • IgotRuns

    Hi,

    I debugged into the problem you are reporting, However in both the cases, with /GR and /GR-, I can see that OnInitDialog() gets called from the place, that is line 26 of the dlgcore.cpp. I just want to make a point here is when you change /GR to /GR-, ensure that you rebuild the project. However if you have a specific app that shows up this problem you can send it to me, I will have a look into the same.

    However I agree to your point where that changing /GR to /GR- is misleading and requires two times changing the same so that actual command line gets /GR-. This is already a known bug and being tracked in our database, thanks for pointing out.

    Thanks,

    Gangadhar


  • ToroLocoMex

    Also, what version of the compiler are you using We have the following installed. If you are using a different versoin of VS 2005 or the C++ compiler/libraries, this may explain why you don't see the problem. There may also be a difference in configuration of VS 2005, which is why I would like to send you a complete project configured with the problem (all you would need to do to see the difference in behavior is to change the Project->Properties: Configuration Properties/C++/Language: Enable Run-Time Type Info setting. Just let me know how to contact you. Thanks.

    Microsoft Visual Studio 2005
    Version 8.0.50727.42  (RTM.050727-4200)
    Microsoft .NET Framework
    Version 2.0.50727

    Installed Edition: Professional

    Microsoft Visual Basic 2005   77626-009-0000007-41178
    Microsoft Visual Basic 2005

    Microsoft Visual C# 2005   77626-009-0000007-41178
    Microsoft Visual C# 2005

    Microsoft Visual C++ 2005   77626-009-0000007-41178
    Microsoft Visual C++ 2005

    Microsoft Visual J# 2005   77626-009-0000007-41178
    Microsoft Visual J# 2005

    Microsoft Visual Web Developer 2005   77626-009-0000007-41178
    Microsoft Visual Web Developer 2005

    Crystal Reports    AAC60-G0CSA4B-V7000AY
    Crystal Reports for Visual Studio 2005


  • Anders Jensen

  • ArtT

    Hi Dave,

    Sorry for the delay in looking at the issue you reported. I was actually involved with other things.

    I did looked into the problem, and it looks like indeed is a problem inside one of the code in DoModal in MFC CDialog or one of the underlying operating system calls that it is using.

    I would suggest you open a bug from customer feedback (http://lab.msdn.microsoft.com/productfeedback) for this problem.

    Meanwhile as a workaround for this problem you can enable the RTTI and continue to use the application.

    [Details of Investigation: The application on running I could see that DoModal is never completed successfully with No RTTI support, it always returned -1, and the output window on VS shows up the error message indicating that an Invalid parameter has been passed, error code:0x00000057]

    Thanks for opening up this issue with us,

    Thanks,

    Gangadhar


  • adimasi

    you can send your project to gheralgi AT microsoft DOT com

    Thanks,

    Gangadhar


  • Wassup

    I'll open a bug report and refer to this MSDN posting.

    Thanks again,

    Dave


  • /GR- cl.exe option causes WM_INITDIALOG not to fire.