Where is my dynamically created button????? 
Author Message
 Where is my dynamically created button?????

Hi there,

I have a dialog application which opens another dialog. The other dialog
creates it'S buttons dynamically.
I tried in the OnInitDialog() - method:

 CButton MyButton;
 CRect rect;
 rect.SetRect(100,100,150,175);
 MyButton.Create ("count",WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, rect,
this, 10000);

Why doesn't that work. I don't get any error, but I don't see the button
either if the dialog is opened.

Thx
Yomar



Sat, 15 Jan 2005 16:00:05 GMT  
 Where is my dynamically created button?????

Quote:

> Hi there,

> I have a dialog application which opens another dialog. The other dialog
> creates it'S buttons dynamically.
> I tried in the OnInitDialog() - method:

>  CButton MyButton;
>  CRect rect;
>  rect.SetRect(100,100,150,175);
>  MyButton.Create ("count",WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, rect,
> this, 10000);

> Why doesn't that work. I don't get any error, but I don't see the button
> either if the dialog is opened.

It looks like your MyButton object is function local which means it will be destroyed as soon as it
goes out of scope. Think about making it a member of the parent class.

--
Jeff Partch [MVP]



Sat, 15 Jan 2005 16:11:21 GMT  
 Where is my dynamically created button?????
    That is because your 'CButton MyButton' is local to OnInitDialog()
function and goes out of scope and gets destroyed once OnInitDialog() exits.

    Try adding it as a member variable of your class

        CButton MyButton;

    instead of declaring it locally.

--
Cheers
Check Abdoul
----------------


Quote:
> Hi there,

> I have a dialog application which opens another dialog. The other dialog
> creates it'S buttons dynamically.
> I tried in the OnInitDialog() - method:

>  CButton MyButton;
>  CRect rect;
>  rect.SetRect(100,100,150,175);
>  MyButton.Create ("count",WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON, rect,
> this, 10000);

> Why doesn't that work. I don't get any error, but I don't see the button
> either if the dialog is opened.

> Thx
> Yomar



Sat, 15 Jan 2005 16:23:36 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dynamically creating buttons and firing events

2. Different Font when creating buttons dynamically

3. URGENT - Dynamically creating radio buttons in Visual C++ 6.0 (MFC)

4. Dynamically Created Checkbox Button Does Not Appear on Dialog

5. Problems with default button on a dynamically created dialog

6. REQ::How Can I create A Button Dynamically

7. Creating a button dynamically

8. Dynamically Created Buttons and their Fonts

9. create dynamically a button in a FormView

10. Different Font when creating buttons dynamically

11. Dynamically Creating Buttons

12. Event handler for a Dynamically created button

 

 
Powered by phpBB® Forum Software