CButton::Create​

CButton::Create
http://technet.microsoft.com/zh-cn/bw4e0cww%28v=vs.71%29

http://technet.microsoft.com/zh-cn/yf1wax6c%28v=vs.71%29#

CButton::Create

BOOL Create(
     LPCTSTR lpszCaption,
     DWORD dwStyle,
     const RECT& rect,
     CWnd* pParentWnd,
     UINT nID
    );


返回值:调用成功时返回非零值,否则为0。

参数:

lpszCaption 指定按钮控件上的文本。
dwStyle 指定按钮控件的风格。可以采用控件风格的各种组合。
rect 指定按钮控件的大小和位置。既可以是一个CRect对象,也可以是一个RECT结构。
pParentWnd 指定按钮控件的父窗口,通常是一个CDialog对象。注意不能为NULL。
nID 指定按钮控件的ID号。


说明:
构造一个CButton对象需要两步:首先调用构造函数,然后调用Create函数创建Windows按钮控件并在CButton对象上应用它。
如果设置了WS_VISIBLE风格,Windows将向该按钮控件发送所有用来激活和显示该按钮的消息。
按钮控件上可用的窗口风格如下:


WS_CHILD 总是设置

WS_VISIBLE 通常要设置

WS_DISABLED 很少使用

WS_GROUP 成组按钮

WS_TABSTOP 按钮按制表键次序排列
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);

参考按钮样式:http://technet.microsoft.com/zh-cn/tf9hd91s%28v=vs.71%29


你可能感兴趣的:(CButton::Create​)