Re: TextBox creation, w/o resource editor?
-
Hello, The check boxes provided in the resource editor are pretty, but I would like to create check boxes without using the resource editor (dynamically). How do I do this? Any help is appreciated.
Need to use CButton class with BS_CHECKBOX style . e.g.
// Create check box.
m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX,
CRect(10,10,100,30), pParentWnd, 1);Prasad Notifier using ATL | Operator new[],delete[][^]
-
Need to use CButton class with BS_CHECKBOX style . e.g.
// Create check box.
m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX,
CRect(10,10,100,30), pParentWnd, 1);Prasad Notifier using ATL | Operator new[],delete[][^]
Hello, I put the following code into CPrintOptionsDlg::OnInitDialog() CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX, CRect(0,0,10,30), this, 1); However, I didn't see the check box. Any ideas? My CPrintOptionsDlg class is derived from CDialog.
-
Hello, I put the following code into CPrintOptionsDlg::OnInitDialog() CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX, CRect(0,0,10,30), this, 1); However, I didn't see the check box. Any ideas? My CPrintOptionsDlg class is derived from CDialog.
mla154 wrote:
I put the following code into CPrintOptionsDlg::OnInitDialog()
Did you call CDialog::OnInitDialog() before creating the button?
-
mla154 wrote:
I put the following code into CPrintOptionsDlg::OnInitDialog()
Did you call CDialog::OnInitDialog() before creating the button?
Yes, I did. My function looks like this: BOOL CPrintOptionsDlg::OnInitDialog() { CDialog::OnInitDialog(); CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE/*|BS_CHECKBOX*/, CRect(0,0,10,30), this, 1); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
-
Yes, I did. My function looks like this: BOOL CPrintOptionsDlg::OnInitDialog() { CDialog::OnInitDialog(); CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE/*|BS_CHECKBOX*/, CRect(0,0,10,30), this, 1); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
your CButton object is going out of scope (so it is destroyed) when the OnInitDialog() method returns. Try moving CButton m_Button; to your class definition (so it's a member of your CPrintOptionsDlg class).
-
Hello, The check boxes provided in the resource editor are pretty, but I would like to create check boxes without using the resource editor (dynamically). How do I do this? Any help is appreciated.
Try this
CButton m_Button; m_Button.Create("Test",WS_CHILD|BS_AUTOCHECKBOX|WS_VISIBLE,CRect(0,0,100,23),this,1);
WhiteSky
-
your CButton object is going out of scope (so it is destroyed) when the OnInitDialog() method returns. Try moving CButton m_Button; to your class definition (so it's a member of your CPrintOptionsDlg class).
-
Hello, I put the following code into CPrintOptionsDlg::OnInitDialog() CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX, CRect(0,0,10,30), this, 1); However, I didn't see the check box. Any ideas? My CPrintOptionsDlg class is derived from CDialog.
I've mentioned
CButton
variable name asm_Button
, which implies its a class member variable.Prasad Notifier using ATL | Operator new[],delete[][^]
-
I've mentioned
CButton
variable name asm_Button
, which implies its a class member variable.Prasad Notifier using ATL | Operator new[],delete[][^]
-
My Pleasure. :)
Prasad Notifier using ATL | Operator new[],delete[][^]