Greying out dialog in popup dialog boxes

Say I have a pop up dialog box, and in the dialog box there are some dialogs that either are displayed or greyed out based on another dialog in that same box. When I click an "update" button in that same dialog box, the control variable gets evaluted and the original dialogs are either displayed or greyed out. I used something like this to accomplish this:

On_update_button:

if (m_int_radio_io==0)
GetDlgItem(IDC_COM_STORE_A_CYCLE) ->EnableWindow(TRUE);
else
GetDlgItem(IDC_COM_STORE_A_CYCLE) ->EnableWindow(FALSE);



My problem is that when I get this modal dialog box to popup from the parent dialog box. the IDC_COM_STORE_A_CYCLE dialog is always greyout independent of the state of m_int_radio_io. As soon as I hit the update button, IDC_COM_STORE_A_CYCLE either goes active or stays inactive based on the state of m_int_radio_io. What I think I need is an "oninit" type function for the pop up dialog box so that I can evalute m_int_radio_io and choose if i want to display IDC_COM_STORE_A_CYCLE or not.

What is the best way to do this ? I added an ON_MODAL function to the child, and I was able to get a message box to pop up before the child dialog popped up, but when I put real code in the routine I got an assertion failure.

Comments

  • The window initialization messages usually come in BEFORE a window is displayed and before child windows are even created. So, yeah, when you try to manipulate the window state you'll get an assertion error.

    You could try sending yourself a message from an init handler. Define your own message then use PostMessage to post it back to that window and put in a handler. Using PostMessage will put it at the end of the queue and return immediately. Hopefully by the time you process it all the child windows will be created. Just a quick stab at an answer. you'll have to test it all out
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion