adding buttons dynamically to a dialog 
Author Message
 adding buttons dynamically to a dialog


Quote:
> How would I add buttons to a dialog dynamically? (i.e. at runtime as
> opposed to creating them with the resource editor at buildtime?)

> Thanks

Something like the following works for me. I have a handle to the device context which I use
to obtain a window handle, you could however use any of the window handle functions instead.
Simply call CWnd::CreateEx and pass the desired type eg. "BUTTON" or create the control from
CButton and use its Create method.

Note if you want to have edit controls which look 3D you must use the former approach with
extended styles.

CButton *ControlPtr = new CButton();    /* Create new control */
CWnd *myWnd = dc->GetWindow();               /* Get Pointer to Design Window */

if(myWnd && ControlPtr)
{
        BOOL Success = ControlPtr->CreateEx(NULL, "BUTTON", "Press Me", WS_CHILD | WS_VISIBLE,
                        ControlSize, myWnd, ControlID, NULL);

        // Where con
        if(!Success)
                // Deal with error

Quote:
}

--
The Obliterator
(Using VisualC 5.0 SP3)


Fri, 24 Nov 2000 03:00:00 GMT  
 adding buttons dynamically to a dialog

CButton.Create(...) will create a button on the fly for you.

Ed

Quote:

>How would I add buttons to a dialog dynamically? (i.e. at runtime as
>opposed to creating them with the resource editor at buildtime?)

>Thanks



Sun, 26 Nov 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Adding buttons dynamically to a dialog

2. Add a button dynamically on the creation of a Dialog Box

3. add button to dialog dynamically

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

5. Dynamically Created Checkbox Button Does Not Appear on Dialog

6. Problems with default button on a dynamically created dialog

7. Hiding a button in a Dialog dynamically

8. how to add edit ctrl and button into dialog dynimically

9. Adding a minimize button to an existing dialog based app

10. how can i add menu and button bar to a dialog

11. Steps to add bitmap to button in Dialog form

12. How to add dialog/buttons into a ListCtrl?

 

 
Powered by phpBB® Forum Software