Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Locked Missing controls in a modeless dialog

  • Monday, June 07, 2010 8:27 PM
     
     

    I have a dialog that I created with the resource editor. It has 3 IDC_STATIC controls, three static controls with unique IDs with variables defined, a bitmap in an Image control, a progress bar and a Cancel button. When I execute the dialog from code, the only visible control is the progress bar. If I use the Visual Studio Format>Test Dialog all controls appear. When I execute the dialog from code using DoModal all controls appear. I am doing a ShowWindow(SW_SHOW) right after the Create(IDD_PROGRESSDIALOG).

     

     

    From code, I'm issuing a SetPos and the progress bar works correctly and remains visible.

All Replies

  • Monday, June 07, 2010 8:30 PM
     
     Answered

    Do you have the properties for the controls set to hidden?  Or are you calling ShowWindow(SW_HIDE) on any of them at runtime?

    You should call any ShowWindow(SW_SHOW) calls for controls in the OnInitDialog() function for the dialog since the controls and window will have been created by then.

    Tom

    • Marked As Answer by Howard Hodson Monday, June 07, 2010 8:58 PM
    •  
  • Monday, June 07, 2010 8:32 PM
     
     
    Nope - checked that. Good question, though.
  • Monday, June 07, 2010 8:56 PM
     
     Answered

    Hey Tom. You were pretty close. I created a test dialog from scratch with the Class Wizard and noticed that the dialog is created with Visible as false. All the controls have a property of Visible true. I flipped the dialog property to true and now the modeless mode works fine.

    My next step was going to be an add control variable for every control in the dialog and echo WM_SHOW to them whenever the dialog receive the message. Sure glad I looked at the property of the dialog before I did that...

    I probably wouldn't have looked at the dialog properties if you handn't asked about the controls. Thanks again.

     

    • Marked As Answer by Howard Hodson Monday, June 07, 2010 8:58 PM
    •  
  • Monday, June 07, 2010 8:58 PM
     
     

    No problem.  It had to be something like that ...  Having the control variables is a great idea since then you could show or hide your controls based on whatever conditions you want at runtime.

    Tom