Add a button dynamically on the creation of a Dialog Box 
Author Message
 Add a button dynamically on the creation of a Dialog Box

I want to add a button in a dialog box but dynamically.  The problem I am
experiencing is that when I add the button the dialog box is not created
yet.

I am using  a modal dialog box.

If there is no way to do this maybe I can remove a button dynamically...
What I want to do is to use the same dialog in a property page and in a
modal dialog box but I don't want to have two set of "ok /cancel" button.

Thanks in advance,

Keaven



Mon, 31 Mar 2003 03:00:00 GMT  
 Add a button dynamically on the creation of a Dialog Box
Use a flag in your dialog class which you set according to your needs. In
OnInitDialog, after calling CDialog::OnInitDialog, check the flag and create
the buttons accordingly. At this moment in time, your dialog is already
created.

Dan


Quote:
> I want to add a button in a dialog box but dynamically.  The problem I am
> experiencing is that when I add the button the dialog box is not created
> yet.

> I am using  a modal dialog box.

> If there is no way to do this maybe I can remove a button dynamically...
> What I want to do is to use the same dialog in a property page and in a
> modal dialog box but I don't want to have two set of "ok /cancel" button.

> Thanks in advance,

> Keaven



Mon, 31 Mar 2003 03:00:00 GMT  
 Add a button dynamically on the creation of a Dialog Box
Other thoughts .. make the property page a sub-dialog (child dialog) of the
modal dialog (which only has OK and Cancel).

That way, you either put the property page in a property sheet (which has
its own OK and Cancel), or you put in as a child dialog of the (almost)
empty modal dialog that has its own OK and Cancel buttons.

Then the behavior (as far as the property page is concerned) is the same.
You can probably also have the same class for it as well.

--
Roger Onslow
Software Developer
See my articles at http://www.codeguru.com
See the product I am working on at http://www.swishzone.com

"Operator .. give me the number for 911" .. Homer Simpson


Quote:
> Use a flag in your dialog class which you set according to your needs. In
> OnInitDialog, after calling CDialog::OnInitDialog, check the flag and
create
> the buttons accordingly. At this moment in time, your dialog is already
> created.

> Dan



> > I want to add a button in a dialog box but dynamically.  The problem I
am
> > experiencing is that when I add the button the dialog box is not created
> > yet.

> > I am using  a modal dialog box.

> > If there is no way to do this maybe I can remove a button dynamically...
> > What I want to do is to use the same dialog in a property page and in a
> > modal dialog box but I don't want to have two set of "ok /cancel"
button.

> > Thanks in advance,

> > Keaven



Tue, 01 Apr 2003 10:15:51 GMT  
 Add a button dynamically on the creation of a Dialog Box

Quote:

> I want to add a button in a dialog box but dynamically.  The problem I am
> experiencing is that when I add the button the dialog box is not created
> yet.

> I am using  a modal dialog box.

You can add them in the dialog constructor after doing a Create().
If you pass a flag to the constructor you can handle both cases
i.e. form with and without the button.

- Keith



Tue, 01 Apr 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Adding buttons dynamically to a dialog

2. adding buttons dynamically to a dialog

3. add button to dialog dynamically

4. how to add button, edit control and spin button dynamically

5. add a minimize button on the top right corner of dialog box

6. activating a button on a dialog box from a dialog box

7. Problems with List box in dynamically created dialog box

8. Problems with List box in dynamically created dialog box

9. Toolbar:Dynamically adding a combo box

10. Dialog Box two OK buttons, two Cancel buttons and TODO still on it

11. i cannot add an item to my list box that is located within my dialog box

12. Add Combo Box to Dialog Box

 

 
Powered by phpBB® Forum Software