我按MSDN上的例子:
CButton myButton1, myButton2, myButton3, myButton4;
// Create a push button.
myButton1.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(10,10,100,30), pParentWnd, 1);
// Create a radio button.
myButton2.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,
CRect(10,40,100,70), pParentWnd, 2);
// Create an auto 3-state button.
myButton3.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_AUTO3STATE,
CRect(10,70,100,100), pParentWnd, 3);
// Create an auto check box.
myButton4.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
CRect(10,100,100,130), pParentWnd, 4);自己这样编写代码:
CButton cbMyButton;
int iret = cbMyButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(10,10,100,30), this, 1);但在界面上无法显示,是怎么回事?请有此经验者多多赐教!
CButton myButton1, myButton2, myButton3, myButton4;
// Create a push button.
myButton1.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(10,10,100,30), pParentWnd, 1);
// Create a radio button.
myButton2.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,
CRect(10,40,100,70), pParentWnd, 2);
// Create an auto 3-state button.
myButton3.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_AUTO3STATE,
CRect(10,70,100,100), pParentWnd, 3);
// Create an auto check box.
myButton4.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
CRect(10,100,100,130), pParentWnd, 4);自己这样编写代码:
CButton cbMyButton;
int iret = cbMyButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(10,10,100,30), this, 1);但在界面上无法显示,是怎么回事?请有此经验者多多赐教!
解决方案 »
- char数组和WCHAR数组的输出问题
- 求助!一个MFC简单但很常用的问题
- mfc项目,如何将第三方 动态连接库整合到exe文件里面? 这样生成的exe就可以单独运行
- 一个大家做项目都会碰到的问题,进来看看啊?
- 做上位机用C#好些还是用VC++做好些?
- 图形处理大侠请进!!
- 请教问题
- 请问DWORD类型变量如何比较?
- 为何连接了其他的LIB后,在CMyApp中AfxLoadLibrary总是返回NULL
- 怎么老是出现这样子的语法错误信息:error C2143: syntax error : missing ';' before '*'
- 最基本Win32程序,为什么无法弹出MessageBox?
- 一个简单的openGL程序,exe执行比VC编译环境下运行更占用内存?
试着将其改成类的成员变量试试
创建了后还要显示出来,cbMyButton->ShowWindow(SW_SHOWNORMAL);
m_btn.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(10,10,100,33), this, IDC_BUTTON);
CFont* pFont = GetFont();
m_btn.SetFont(pFont);
m_btn.UnsubclassWindow(); CString strText(_T(""));
GetDlgItemText(IDC_BUTTON, strText);
AfxMessageBox(strText);
m_btn.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(10,10,100,33), this, IDC_BUTTON);
CFont* pFont = GetFont();
m_btn.SetFont(pFont);
m_btn.UnsubclassWindow(); CString strText(_T(""));
GetDlgItemText(IDC_BUTTON, strText);
AfxMessageBox(strText);
m_btn.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(10,10,100,33), this, IDC_BUTTON);
CFont* pFont = GetFont();
m_btn.SetFont(pFont);
m_btn.UnsubclassWindow(); CString strText(_T(""));
GetDlgItemText(IDC_BUTTON, strText);
AfxMessageBox(strText);