add button to dialog dynamically 
Author Message
 add button to dialog dynamically

if i add a cbutton control to a dialog in its oninitdialog() it doesn`t show
it. why

thanks

christoph



Sat, 22 Sep 2001 03:00:00 GMT  
 add button to dialog dynamically
Christoph:

It should. Show us the code.

David

=================

Quote:

> if i add a cbutton control to a dialog in its oninitdialog() it doesn`t show
> it. why

> thanks

> christoph



Sat, 22 Sep 2001 03:00:00 GMT  
 add button to dialog dynamically
Christoph,

What code are you using? It should work fine if you do it properly. First, make
sure define the variable as a member of you class, otherwise you risk it
destroying the window when it goes out of scope. Second, make sure you put it at
the right coordinates, so it doesn't get under any other control or out of the
visible area of the dialog window.

--
Tomas Restrepo

http://members.xoom.com/trestrep/


Quote:
> if i add a cbutton control to a dialog in its oninitdialog() it doesn`t show
> it. why

> thanks

> christoph



Sat, 22 Sep 2001 03:00:00 GMT  
 add button to dialog dynamically
Hello
thank for your help. here is my code:

BOOL CShowFeedbackDlg::OnInitDialog()
{
 TRACE("\nCShowFeedbackDlg::OnInitDialog");
 CDialog::OnInitDialog();

 SetWindowPos( NULL,
     m_dlgEnclosingRect.left, m_dlgEnclosingRect.top ,
     m_dlgEnclosingRect.Width(), m_dlgEnclosingRect.Height(),
     SWP_NOZORDER );

CRect buttonRect;
 buttonRect.SetRect(m_dlgEnclosingRect.left, m_dlgEnclosingRect.bottom -35,
m_dlgEnclosingRect.right, m_dlgEnclosingRect.bottom -5);
 m_bc_ok.Create("OK",BS_PUSHBUTTON, buttonRect, this, IDOK);
 m_bc_ok.ShowWindow(SW_SHOW);

 return TRUE;

Quote:
}



Sat, 22 Sep 2001 03:00:00 GMT  
 add button to dialog dynamically
Christoph:

(a) I think you need WS_CHILD style.

(b) You need to do a ScreenToClient() to get the button rectangle in client
coordinates.

(c) Also, I presume you have gotten rid of the original button with the IDOK
identifier (if you haven't then you are trying to create two controls with the
same ID, which has to create a problem, not quite sure what would happen...).
But you could have just kept the original OK button and used MoveWindow() or
SetWindowPos() to move it.

HTH,

David Wilkinson

===========

David

===============

Quote:

> Hello
> thank for your help. here is my code:

> BOOL CShowFeedbackDlg::OnInitDialog()
> {
>  TRACE("\nCShowFeedbackDlg::OnInitDialog");
>  CDialog::OnInitDialog();

>  SetWindowPos( NULL,
>      m_dlgEnclosingRect.left, m_dlgEnclosingRect.top ,
>      m_dlgEnclosingRect.Width(), m_dlgEnclosingRect.Height(),
>      SWP_NOZORDER );

> CRect buttonRect;
>  buttonRect.SetRect(m_dlgEnclosingRect.left, m_dlgEnclosingRect.bottom -35,
> m_dlgEnclosingRect.right, m_dlgEnclosingRect.bottom -5);
>  m_bc_ok.Create("OK",BS_PUSHBUTTON, buttonRect, this, IDOK);
>  m_bc_ok.ShowWindow(SW_SHOW);

>  return TRUE;

> }



Sat, 22 Sep 2001 03:00:00 GMT  
 add button to dialog dynamically
Thank you David
the screentoclient() was necessary

I get to know, that i havent't understand the stuff with different
coordinates yet.
can you recommend me anything which i could study about this topic
(tutorial)?

thank you

christoph



Sat, 22 Sep 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

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

2. Adding buttons dynamically to a dialog

3. adding buttons dynamically to a dialog

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