• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
              1#include "stdafx.h"
              2#include "BtnST.h"
              3
              4#ifdef    BTNST_USE_SOUND
              5#pragma comment(lib, "winmm.lib")
              6#include <Mmsystem.h>
              7#endif
              8
              9#ifdef _DEBUG
             10#define new DEBUG_NEW
             11#undef THIS_FILE
             12static char THIS_FILE[] = __FILE__;
             13#endif
             14
             15/////////////////////////////////////////////////////////////////////////////
             16// CButtonST
             17
             18// Mask for control's type
             19#define BS_TYPEMASK SS_TYPEMASK
             20
             21#ifndef    TTM_SETTITLE
             22#define TTM_SETTITLEA           (WM_USER + 32)  // wParam = TTI_*, lParam = char* szTitle
             23#define TTM_SETTITLEW           (WM_USER + 33)  // wParam = TTI_*, lParam = wchar* szTitle
             24#ifdef    UNICODE
             25#define TTM_SETTITLE            TTM_SETTITLEW
             26#else
             27#define TTM_SETTITLE            TTM_SETTITLEA
             28#endif
             29#endif
             30
             31#ifndef    TTS_BALLOON
             32#define    TTS_BALLOON        0x40
             33#endif
             34
             35CButtonST::CButtonST()
             36{
             37    m_bIsPressed        = FALSE;
             38    m_bIsFocused        = FALSE;
             39    m_bIsDisabled        = FALSE;
             40    m_bMouseOnButton    = FALSE;
             41
             42    FreeResources(FALSE);
             43
             44    // Default type is "flat" button
             45    m_bIsFlat = TRUE;
             46    // Button will be tracked also if when the window is inactive (like Internet Explorer)
             47    m_bAlwaysTrack = TRUE;
             48  
             49    // By default draw border in "flat" button 
             50    m_bDrawBorder = TRUE; 
             51  
             52    // By default icon is aligned horizontally
             53    m_byAlign = ST_ALIGN_HORIZ; 
             54
             55    // By default use usual pressed style
             56    SetPressedStyle(BTNST_PRESSED_LEFTRIGHT, FALSE);
             57  
             58    // By default, for "flat" button, don't draw the focus rect
             59    m_bDrawFlatFocus = FALSE;
             60
             61    // By default the button is not the default button
             62    m_bIsDefault = FALSE;
             63    // Invalid value, since type still unknown
             64    m_nTypeStyle = BS_TYPEMASK;
             65
             66    // By default the button is not a checkbox
             67    m_bIsCheckBox = FALSE;
             68    m_nCheck = 0;
             69
             70    // Set default colors
             71    SetDefaultColors(FALSE);
             72
             73    // No tooltip created
             74    m_ToolTip.m_hWnd = NULL;
             75    m_dwToolTipStyle = 0;
             76
             77    // Do not draw as a transparent button
             78    m_bDrawTransparent = FALSE;
             79    m_pbmpOldBk = NULL;
             80
             81    // No URL defined
             82    SetURL(NULL);
             83
             84    // No cursor defined
             85    m_hCursor = NULL;
             86
             87    // No associated menu
             88#ifndef    BTNST_USE_BCMENU
             89    m_hMenu = NULL;
             90#endif
             91    m_hParentWndMenu = NULL;
             92    m_bMenuDisplayed = FALSE;
             93
             94    m_bShowDisabledBitmap = TRUE;
             95
             96    m_ptImageOrg.x = 3;
             97    m_ptImageOrg.y = 3;
             98
             99    // No defined callbacks
            100    ::ZeroMemory(&m_csCallbacks, sizeof(m_csCallbacks));
            101
            102#ifdef    BTNST_USE_SOUND
            103    // No defined sounds
            104    ::ZeroMemory(&m_csSounds, sizeof(m_csSounds));
            105#endif
            106}
             // End of CButtonST
            107
            108CButtonST::~CButtonST()
            109{
            110    // Restore old bitmap (if any)
            111    if (m_dcBk.m_hDC && m_pbmpOldBk)
            112    {
            113        m_dcBk.SelectObject(m_pbmpOldBk);
            114    }
             // if
            115
            116    FreeResources();
            117
            118    // Destroy the cursor (if any)
            119    if (m_hCursor) ::DestroyCursor(m_hCursor);
            120
            121    // Destroy the menu (if any)
            122#ifdef    BTNST_USE_BCMENU
            123    if (m_menuPopup.m_hMenu)    m_menuPopup.DestroyMenu();
            124#else
            125    if (m_hMenu)    ::DestroyMenu(m_hMenu);
            126#endif
            127}
             // End of ~CButtonST
            128
            129BEGIN_MESSAGE_MAP(CButtonST, CButton)
            130    //{{AFX_MSG_MAP(CButtonST)
            131    ON_WM_SETCURSOR()
            132    ON_WM_KILLFOCUS()
            133    ON_WM_MOUSEMOVE()
            134    ON_WM_SYSCOLORCHANGE()
            135    ON_CONTROL_REFLECT_EX(BN_CLICKED, OnClicked)
            136    ON_WM_ACTIVATE()
            137    ON_WM_ENABLE()
            138    ON_WM_CANCELMODE()
            139    ON_WM_GETDLGCODE()
            140    ON_WM_CTLCOLOR_REFLECT()
            141    //}}AFX_MSG_MAP
            142#ifdef    BTNST_USE_BCMENU
            143    ON_WM_MENUCHAR()
            144    ON_WM_MEASUREITEM()
            145#endif
            146
            147    ON_MESSAGE(BM_SETSTYLE, OnSetStyle)
            148    ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
            149    ON_MESSAGE(BM_SETCHECK, OnSetCheck)
            150    ON_MESSAGE(BM_GETCHECK, OnGetCheck)
            151END_MESSAGE_MAP()
            152
            153void CButtonST::FreeResources(BOOL bCheckForNULL)
            154{
            155    if (bCheckForNULL)
            156    {
            157        // Destroy icons
            158        // Note: the following two lines MUST be here! even if
            159        // BoundChecker says they are unnecessary!
            160        if (m_csIcons[0].hIcon)    ::DestroyIcon(m_csIcons[0].hIcon);
            161        if (m_csIcons[1].hIcon)    ::DestroyIcon(m_csIcons[1].hIcon);
            162
            163        // Destroy bitmaps
            164        if (m_csBitmaps[0].hBitmap)    ::DeleteObject(m_csBitmaps[0].hBitmap);
            165        if (m_csBitmaps[1].hBitmap)    ::DeleteObject(m_csBitmaps[1].hBitmap);
            166
            167        // Destroy mask bitmaps
            168        if (m_csBitmaps[0].hMask)    ::DeleteObject(m_csBitmaps[0].hMask);
            169        if (m_csBitmaps[1].hMask)    ::DeleteObject(m_csBitmaps[1].hMask);
            170    }
             // if
            171
            172    ::ZeroMemory(&m_csIcons, sizeof(m_csIcons));
            173    ::ZeroMemory(&m_csBitmaps, sizeof(m_csBitmaps));
            174}
             // End of FreeResources
            175
            176void CButtonST::PreSubclassWindow() 
            177{
            178    UINT nBS;
            179
            180    nBS = GetButtonStyle();
            181
            182    // Set initial control type
            183    m_nTypeStyle = nBS & BS_TYPEMASK;
            184
            185    // Check if this is a checkbox
            186    if (nBS & BS_CHECKBOX) m_bIsCheckBox = TRUE;
            187
            188    // Set initial default state flag
            189    if (m_nTypeStyle == BS_DEFPUSHBUTTON)
            190    {
            191        // Set default state for a default button
            192        m_bIsDefault = TRUE;
            193
            194        // Adjust style for default button
            195        m_nTypeStyle = BS_PUSHBUTTON;
            196    }
             // If
            197
            198    // You should not set the Owner Draw before this call
            199    // (don't use the resource editor "Owner Draw" or
            200    // ModifyStyle(0, BS_OWNERDRAW) before calling PreSubclassWindow() )
            201    ASSERT(m_nTypeStyle != BS_OWNERDRAW);
            202
            203    // Switch to owner-draw
            204    ModifyStyle(BS_TYPEMASK, BS_OWNERDRAW, SWP_FRAMECHANGED);
            205
            206    CButton::PreSubclassWindow();
            207}
             // End of PreSubclassWindow
            208
            209UINT CButtonST::OnGetDlgCode() 
            210{
            211    UINT nCode = CButton::OnGetDlgCode();
            212
            213    // Tell the system if we want default state handling
            214    // (losing default state always allowed)
            215    nCode |= (m_bIsDefault ? DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON);
            216
            217    return nCode;
            218}
             // End of OnGetDlgCode
            219
            220BOOL CButtonST::PreTranslateMessage(MSG* pMsg) 
            221{
            222    InitToolTip();
            223    m_ToolTip.RelayEvent(pMsg);
            224    
            225    if (pMsg->message == WM_LBUTTONDBLCLK)
            226        pMsg->message = WM_LBUTTONDOWN;
            227
            228    return CButton::PreTranslateMessage(pMsg);
            229}
             // End of PreTranslateMessage
            230
            231HBRUSH CButtonST::CtlColor(CDC* pDC, UINT nCtlColor) 
            232{
            233    return (HBRUSH)::GetStockObject(NULL_BRUSH); 
            234}
             // End of CtlColor
            235
            236void CButtonST::OnSysColorChange() 
            237{
            238    CButton::OnSysColorChange();
            239
            240    m_dcBk.DeleteDC();
            241    m_bmpBk.DeleteObject();    
            242    SetDefaultColors();
            243}
             // End of OnSysColorChange
            244
            245LRESULT CButtonST::OnSetStyle(WPARAM wParam, LPARAM lParam)
            246{
            247    UINT nNewType = (wParam & BS_TYPEMASK);
            248
            249    // Update default state flag
            250    if (nNewType == BS_DEFPUSHBUTTON)
            251    {
            252        m_bIsDefault = TRUE;
            253    }
             // if
            254    else if (nNewType == BS_PUSHBUTTON)
            255    {
            256        // Losing default state always allowed
            257        m_bIsDefault = FALSE;
            258    }
             // if
            259
            260    // Can't change control type after owner-draw is set.
            261    // Let the system process changes to other style bits
            262    // and redrawing, while keeping owner-draw style
            263    return DefWindowProc(BM_SETSTYLE,
            264        (wParam & ~BS_TYPEMASK) | BS_OWNERDRAW, lParam);
            265}
             // End of OnSetStyle
            266
            267LRESULT CButtonST::OnSetCheck(WPARAM wParam, LPARAM lParam)
            268{
            269    ASSERT(m_bIsCheckBox);
            270
            271    switch (wParam)
            272    {
            273        case BST_CHECKED:
            274        case BST_INDETERMINATE:    // Indeterminate state is handled like checked state
            275            SetCheck(1);
            276            break;
            277        default:
            278            SetCheck(0);
            279            break;
            280    }
             // switch
            281
            282    return 0;
            283}
             // End of OnSetCheck
            284
            285LRESULT CButtonST::OnGetCheck(WPARAM wParam, LPARAM lParam)
            286{
            287    ASSERT(m_bIsCheckBox);
            288    return GetCheck();
            289}
             // End of OnGetCheck
            290
            Posted on 2007-04-12 11:45 艾凡赫 閱讀(1220) 評論(0)  編輯 收藏 引用 所屬分類: MFC技術(shù)
            久久精品亚洲男人的天堂| 精品久久久噜噜噜久久久 | 丁香色欲久久久久久综合网| 久久久久这里只有精品 | 久久丫精品国产亚洲av| 久久久久久综合网天天| 99re久久精品国产首页2020| 精品久久久久久无码国产| 99久久精品免费看国产一区二区三区| 一本大道久久香蕉成人网| 国产精品久久久久jk制服| 天天综合久久一二三区| 无码国产69精品久久久久网站| 丰满少妇人妻久久久久久4| 久久久这里有精品中文字幕| 日韩人妻无码一区二区三区久久99| 久久er国产精品免费观看2| 国产精品激情综合久久| 久久国内免费视频| 99久久国产精品免费一区二区| 久久精品99无色码中文字幕| 香蕉久久影院| 亚洲午夜久久影院| 久久er热视频在这里精品| 亚洲日本va午夜中文字幕久久| 色狠狠久久AV五月综合| 国产精品成人99久久久久 | 国产免费福利体检区久久 | 久久亚洲AV无码精品色午夜麻豆| 久久综合久久综合九色| 91视频国产91久久久| 久久综合给合久久狠狠狠97色| 一级A毛片免费观看久久精品| 久久精品国产精品亚洲人人 | 手机看片久久高清国产日韩| 久久精品二区| 久久久青草青青国产亚洲免观| 99久久精品国产一区二区| 欧美综合天天夜夜久久| 国产精品9999久久久久| 国产91色综合久久免费|