小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

VC++之Button控件

 昵稱(chēng)4328468 2010-11-21
VC++之Button控件
2001-10-15· · ··vchelp

 按鈕窗口(控件)在MFC中使用CButton表示,CButton包含了三種樣式的按鈕,Push Button,Check Box,Radio Box。所以在利用CButton對(duì)象生成按鈕窗口時(shí)需要指明按鈕的風(fēng)格。

創(chuàng)建按鈕:BOOL CButton::Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );其中l(wèi)pszCaption是按鈕上顯示的文字,dwStyle為按鈕風(fēng)格,除了Windows風(fēng)格可以使用外(如WS_CHILD|WS_VISUBLE|WS_BORDER)還有按鈕專(zhuān)用的一些風(fēng)格。

  • BS_AUTOCHECKBOX 檢查框,按鈕的狀態(tài)會(huì)自動(dòng)改變   Same as a check box, except that a check mark appears in the check box when the user selects the box; the check mark disappears the next time the user selects the box.
  • BS_AUTORADIOBUTTON 圓形選擇按鈕,按鈕的狀態(tài)會(huì)自動(dòng)改變   Same as a radio button, except that when the user selects it, the button automatically highlights itself and removes the selection from any other radio buttons with the same style in the same group.
  • BS_AUTO3STATE 允許按鈕有三種狀態(tài)即:選中,未選中,未定   Same as a three-state check box, except that the box changes its state when the user selects it.
  • BS_CHECKBOX 檢查框   Creates a small square that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style).
  • BS_DEFPUSHBUTTON 默認(rèn)普通按鈕   Creates a button that has a heavy black border. The user can select this button by pressing the ENTER key. This style enables the user to quickly select the most likely option (the default option).
  • BS_LEFTTEXT 左對(duì)齊文字   When combined with a radio-button or check-box style, the text appears on the left side of the radio button or check box.
  • BS_OWNERDRAW 自繪按鈕   Creates an owner-drawn button. The framework calls theDrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.
  • BS_PUSHBUTTON 普通按鈕   Creates a pushbutton that posts a WM_COMMAND message to the owner window when the user selects the button.
  • BS_RADIOBUTTON 圓形選擇按鈕   Creates a small circle that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style). Radio buttons are usually used in groups of related but mutually exclusive choices.
  • BS_3STATE 允許按鈕有三種狀態(tài)即:選中,未選中,未定   Same as a check box, except that the box can be dimmed as well as checked. The dimmed state typically is used to show that a check box has been disabled.
rect為窗口所占據(jù)的矩形區(qū)域,pParentWnd為父窗口指針,nID為該窗口的ID值。

獲取/改變按鈕狀態(tài):對(duì)于檢查按鈕和圓形按鈕可能有兩種狀態(tài),選中和未選中,如果設(shè)置了BS_3STATE或BS_AUTO3STATE風(fēng)格就可能出現(xiàn)第三種狀態(tài):未定,這時(shí)按鈕顯示灰色。通過(guò)調(diào)用int CButton::GetCheck( ) 得到當(dāng)前是否被選中,返回0:未選中,1:選中,2:未定。調(diào)用void CButton::SetCheck( int nCheck );設(shè)置當(dāng)前選中狀態(tài)。

處理按鈕消息:要處理按鈕消息需要在父窗口中進(jìn)行消息映射,映射宏為ON_BN_CLICKED( id, memberFxn )id為按鈕的ID值,就是創(chuàng)建時(shí)指定的nID值。處理函數(shù)原型為afx_msg void memberFxn( );

按鈕窗口(控件)在MFC中使用CButton表示,CButton包含了三種樣式的按鈕,Push Button,Check Box,Radio Box。所以在利用CButton對(duì)象生成按鈕窗口時(shí)需要指明按鈕的風(fēng)格。

創(chuàng)建按鈕:BOOL CButton::Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );其中l(wèi)pszCaption是按鈕上顯示的文字,dwStyle為按鈕風(fēng)格,除了Windows風(fēng)格可以使用外(如WS_CHILD|WS_VISUBLE|WS_BORDER)還有按鈕專(zhuān)用的一些風(fēng)格。
  • BS_AUTOCHECKBOX 檢查框,按鈕的狀態(tài)會(huì)自動(dòng)改變   Same as a check box, except that a check mark appears in the check box when the user selects the box; the check mark disappears the next time the user selects the box.
  • BS_AUTORADIOBUTTON 圓形選擇按鈕,按鈕的狀態(tài)會(huì)自動(dòng)改變   Same as a radio button, except that when the user selects it, the button automatically highlights itself and removes the selection from any other radio buttons with the same style in the same group.
  • BS_AUTO3STATE 允許按鈕有三種狀態(tài)即:選中,未選中,未定   Same as a three-state check box, except that the box changes its state when the user selects it.
  • BS_CHECKBOX 檢查框   Creates a small square that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style).
  • BS_DEFPUSHBUTTON 默認(rèn)普通按鈕   Creates a button that has a heavy black border. The user can select this button by pressing the ENTER key. This style enables the user to quickly select the most likely option (the default option).
  • BS_LEFTTEXT 左對(duì)齊文字   When combined with a radio-button or check-box style, the text appears on the left side of the radio button or check box.
  • BS_OWNERDRAW 自繪按鈕   Creates an owner-drawn button. The framework calls theDrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.
  • BS_PUSHBUTTON 普通按鈕   Creates a pushbutton that posts a WM_COMMAND message to the owner window when the user selects the button.
  • BS_RADIOBUTTON 圓形選擇按鈕   Creates a small circle that has text displayed to its right (unless this style is combined with the BS_LEFTTEXT style). Radio buttons are usually used in groups of related but mutually exclusive choices.
  • BS_3STATE 允許按鈕有三種狀態(tài)即:選中,未選中,未定   Same as a check box, except that the box can be dimmed as well as checked. The dimmed state typically is used to show that a check box has been disabled.

rect為窗口所占據(jù)的矩形區(qū)域,pParentWnd為父窗口指針,nID為該窗口的ID值。 

獲取/改變按鈕狀態(tài):對(duì)于檢查按鈕和圓形按鈕可能有兩種狀態(tài),選中和未選中,如果設(shè)置了BS_3STATE或BS_AUTO3STATE風(fēng)格就可能出現(xiàn)第三種狀態(tài):未定,這時(shí)按鈕顯示灰色。通過(guò)調(diào)用int CButton::GetCheck( ) 得到當(dāng)前是否被選中,返回0:未選中,1:選中,2:未定。調(diào)用void CButton::SetCheck( int nCheck );設(shè)置當(dāng)前選中狀態(tài)。

處理按鈕消息:要處理按鈕消息需要在父窗口中進(jìn)行消息映射,映射宏為ON_BN_CLICKED( id, memberFxn )id為按鈕的ID值,就是創(chuàng)建時(shí)指定的nID值。處理函數(shù)原型為afx_msg void memberFxn( );

■ 相關(guān)內(nèi)容
 VC++之Static Box控件
 VC++之Edit Box控件
 VC++之Scroll Bar
 VC++之List Box/Check List Box控件
 VC++ Combo Box/Combo Box Ex控件
 VC++ List Ctrl控件
 利用序列化進(jìn)行文件讀寫(xiě)
 MFC中所提供的各種視類(lèi)介紹
 文檔,視,框架之間相互作用
 使用菜單
 接收用戶(hù)輸入
 文檔、視圖、框架間的關(guān)系和消息傳送

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多