给按钮加个唯一标识
m_button1 = new CMyButton();
button[0]=m_button1;
CxImage* pImage = new CxImage();
pImage->LoadResource(FindResource(NULL,MAKEINTRESOURCE(IDR_PNG18),_T("PNG")), CXIMAGE_FORMAT_PNG);
m_button1->SetImage(pImage);
m_button1->Create("",WS_VISIBLE|WS_CHILD,CRect(43,320,153,457),this,CM_POSCHANGE);
BOOL Create(LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
UINT nID 最后一个参数怎么加呀!
[解决办法]
在resource.h 注册一个ID就行
#define ID_BUTTON_1 1002
[解决办法]
CButton::Create
BOOL Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );
Return Value
Nonzero if successful; otherwise 0.
Parameters
lpszCaption
Specifies the button control’s text.
dwStyle
Specifies the button control’s style. Apply any combination of button styles to the button.
rect
Specifies the button control’s size and position. It can be either a CRect object or a RECT structure.
pParentWnd
Specifies the button control’s parent window, usually a CDialog. It must not be NULL.
nID
Specifies the button control’s ID.
nID 为UINT类型,即无符号的整形数
Example
CButton myButton1;
// Create a push button.
myButton1.Create(_T("My button"), WS_CHILD
[解决办法]
WS_VISIBLE
[解决办法]
BS_PUSHBUTTON,
CRect(10,10,100,30), pParentWnd, 1);
也可以向楼上那样定义