#include "stdafx.h"
#include "BtnST.h"
#ifdef BTNST_USE_SOUND
#pragma comment(lib, "winmm.lib")
#include <Mmsystem.h>
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CButtonST
// Mask for control's type
#define BS_TYPEMASK SS_TYPEMASK
#ifndef TTM_SETTITLE
#define TTM_SETTITLEA (WM_USER + 32) // wParam = TTI_*, lParam = char* szTitle
#define TTM_SETTITLEW (WM_USER + 33) // wParam = TTI_*, lParam = wchar* szTitle
#ifdef UNICODE
#define TTM_SETTITLE TTM_SETTITLEW
#else
#define TTM_SETTITLE TTM_SETTITLEA
#endif
#endif
CButtonST::CButtonST()
{
m_bIsPressed = FALSE;
m_bIsFocused = FALSE;
m_bIsDisabled = FALSE;
m_bMouseOnButton = FALSE;
FreeResources(FALSE);
// Default type is "flat" button
m_bIsFlat = TRUE;
// Button will be tracked also if when the window is inactive (like Internet Explorer)
m_bAlwaysTrack = TRUE;
// By default draw border in "flat" button
m_bDrawBorder = TRUE;
// By default icon is aligned horizontally
m_byAlign = ST_ALIGN_HORIZ;
// By default use usual pressed style
SetPressedStyle(BTNST_PRESSED_LEFTRIGHT, FALSE);
// By default, for "flat" button, don't draw the focus rect
m_bDrawFlatFocus = FALSE;
// By default the button is not the default button
m_bIsDefault = FALSE;
// Invalid value, since type still unknown
m_nTypeStyle = BS_TYPEMASK;
// By default the button is not a checkbox
m_bIsCheckBox = FALSE;
m_nCheck = 0;
// Set default colors
SetDefaultColors(FALSE);
// No tooltip created
m_ToolTip.m_hWnd = NULL;
m_dwToolTipStyle = 0;
// Do not draw as a transparent button
m_bDrawTransparent = FALSE;
m_pbmpOldBk = NULL;
// No URL defined
SetURL(NULL);
// No cursor defined
m_hCursor = NULL;
// No associated menu
#ifndef BTNST_USE_BCMENU
m_hMenu = NULL;
#endif
m_hParentWndMenu = NULL;
m_bMenuDisplayed = FALSE;
m_bShowDisabledBitmap = TRUE;
m_ptImageOrg.x = 3;
m_ptImageOrg.y = 3;
// No defined callbacks
::ZeroMemory(&m_csCallbacks, sizeof(m_csCallbacks));
#ifdef BTNST_USE_SOUND
// No defined sounds
::ZeroMemory(&m_csSounds, sizeof(m_csSounds));
#endif
} // End of CButtonST
CButtonST::~CButtonST()
{
// Restore old bitmap (if any)
if (m_dcBk.m_hDC && m_pbmpOldBk)
{
m_dcBk.SelectObject(m_pbmpOldBk);
} // if
FreeResources();
// Destroy the cursor (if any)
if (m_hCursor) ::DestroyCursor(m_hCursor);
// Destroy the menu (if any)
#ifdef BTNST_USE_BCMENU
if (m_menuPopup.m_hMenu) m_menuPopup.DestroyMenu();
#else
if (m_hMenu) ::DestroyMenu(m_hMenu);
#endif
} // End of ~CButtonST
BEGIN_MESSAGE_MAP(CButtonST, CButton)
//{{AFX_MSG_MAP(CButtonST)
ON_WM_SETCURSOR()
ON_WM_KILLFOCUS()
ON_WM_MOUSEMOVE()
ON_WM_SYSCOLORCHANGE()
ON_CONTROL_REFLECT_EX(BN_CLICKED, OnClicked)
ON_WM_ACTIVATE()
ON_WM_ENABLE()
ON_WM_CANCELMODE()
ON_WM_GETDLGCODE()
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
#ifdef BTNST_USE_BCMENU
ON_WM_MENUCHAR()
ON_WM_MEASUREITEM()
#endif
ON_MESSAGE(BM_SETSTYLE, OnSetStyle)
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
ON_MESSAGE(BM_SETCHECK, OnSetCheck)
ON_MESSAGE(BM_GETCHECK, OnGetCheck)
END_MESSAGE_MAP()
void CButtonST::FreeResources(BOOL bCheckForNULL)
{
if (bCheckForNULL)
{
// Destroy icons
// Note: the following two lines MUST be here! even if
// BoundChecker says they are unnecessary!
if (m_csIcons[0].hIcon) ::DestroyIcon(m_csIcons[0].hIcon);
if (m_csIcons[1].hIcon) ::DestroyIcon(m_csIcons[1].hIcon);
// Destroy bitmaps
if (m_csBitmaps[0].hBitmap) ::DeleteObject(m_csBitmaps[0].hBitmap);
if (m_csBitmaps[1].hBitmap) ::DeleteObject(m_csBitmaps[1].hBitmap);
// Destroy mask bitmaps
if (m_csBitmaps[0].hMask) ::DeleteObject(m_csBitmaps[0].hMask);
if (m_csBitmaps[1].hMask) ::DeleteObject(m_csBitmaps[1].hMask);
} // if
::ZeroMemory(&m_csIcons, sizeof(m_csIcons));
::ZeroMemory(&m_csBitmaps, sizeof(m_csBitmaps));
} // End of FreeResources
void CButtonST::PreSubclassWindow()
{
UINT nBS;
nBS = GetButtonStyle();
// Set initial control type
m_nTypeStyle = nBS & BS_TYPEMASK;
// Check if this is a checkbox
if (nBS & BS_CHECKBOX) m_bIsCheckBox = TRUE;
// Set initial default state flag
if (m_nTypeStyle == BS_DEFPUSHBUTTON)
{
// Set default state for a default button
m_bIsDefault = TRUE;
// Adjust style for default button
m_nTypeStyle = BS_PUSHBUTTON;
} // If
// You should not set the Owner Draw before this call
// (don't use the resource editor "Owner Draw" or
// ModifyStyle(0, BS_OWNERDRAW) before calling PreSubclassWindow() )
ASSERT(m_nTypeStyle != BS_OWNERDRAW);
// Switch to owner-draw
ModifyStyle(BS_TYPEMASK, BS_OWNERDRAW, SWP_FRAMECHANGED);
CButton::PreSubclassWindow();
} // End of PreSubclassWindow
UINT CButtonST::OnGetDlgCode()
{
UINT nCode = CButton::OnGetDlgCode();
// Tell the system if we want default state handling
// (losing default state always allowed)
nCode |= (m_bIsDefault ? DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON);
return nCode;
} // End of OnGetDlgCode
BOOL CButtonST::PreTranslateMessage(MSG* pMsg)
{
InitToolTip();
m_ToolTip.RelayEvent(pMsg);
if (pMsg->message == WM_LBUTTONDBLCLK)
pMsg->message = WM_LBUTTONDOWN;
return CButton::PreTranslateMessage(pMsg);
} // End of PreTranslateMessage
HBRUSH CButtonST::CtlColor(CDC* pDC, UINT nCtlColor)
{
return (HBRUSH)::GetStockObject(NULL_BRUSH);
} // End of CtlColor
void CButtonST::OnSysColorChange()
{
CButton::OnSysColorChange();
m_dcBk.DeleteDC();
m_bmpBk.DeleteObject();
SetDefaultColors();
} // End of OnSysColorChange
LRESULT CButtonST::OnSetStyle(WPARAM wParam, LPARAM lParam)
{
UINT nNewType = (wParam & BS_TYPEMASK);
// Update default state flag
if (nNewType == BS_DEFPUSHBUTTON)
{
m_bIsDefault = TRUE;
} // if
else if (nNewType == BS_PUSHBUTTON)
{
// Losing default state always allowed
m_bIsDefault = FALSE;
} // if
// Can't change control type after owner-draw is set.
// Let the system process changes to other style bits
// and redrawing, while keeping owner-draw style
return DefWindowProc(BM_SETSTYLE,
(wParam & ~BS_TYPEMASK) | BS_OWNERDRAW, lParam);
} // End of OnSetStyle
LRESULT CButtonST::OnSetCheck(WPARAM wParam, LPARAM lParam)
{
ASSERT(m_bIsCheckBox);
switch (wParam)
{
case BST_CHECKED:
case BST_INDETERMINATE: // Indeterminate state is handled like checked state
SetCheck(1);
break;
default:
SetCheck(0);
break;
} // switch
return 0;
} // End of OnSetCheck
LRESULT CButtonST::OnGetCheck(WPARAM wParam, LPARAM lParam)
{
ASSERT(m_bIsCheckBox);
return GetCheck();
} // End of OnGetCheck
#ifdef BTNST_USE_BCMENU
LRESULT CButtonST::OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu)
{
LRESULT lResult;
if (BCMenu::IsMenu(pMenu))
lResult = BCMenu::FindKeyboardShortcut(nChar, nFlags, pMenu);
else
lResult = CButton::OnMenuChar(nChar, nFlags, pMenu);
return lResult;
} // End of OnMenuChar
#endif
#ifdef BTNST_USE_BCMENU
void CButtonST::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
BOOL bSetFlag = FALSE;
if (lpMeasureItemStruct->CtlType == ODT_MENU)
{
if (IsMenu((HMENU)lpMeasureItemStruct->itemID) && BCMenu::IsMenu((HMENU)lpMeasureItemStruct->itemID))
{
m_menuPopup.MeasureItem(lpMeasureItemStruct);
bSetFlag = TRUE;
} // if
} // if
if (!bSetFlag) CButton::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
} // End of OnMeasureItem
#endif
void CButtonST::OnEnable(BOOL bEnable)
{
CButton::OnEnable(bEnable);
if (bEnable == FALSE)
{
CWnd* pWnd = GetParent()->GetNextDlgTabItem(this);
if (pWnd)
pWnd->SetFocus();
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
仿Winamp 多媒体播放器 功能齐全 界面漂亮 // Class: CButtonST // // Compiler: Visual C++ // Tested on: Visual C++ 5.0 // Visual C++ 6.0 // // Version: See GetVersionC() or GetVersionI() // // Created: xx/xxxx/1998 // Updated: 25/November/2002 // // Author: Davide Calabro' davide_calabro@yahoo.com // http://www.softechsoftware.it //
资源推荐
资源详情
资源评论
收起资源包目录
MPlayer.rar (56个子文件)
MPlayer
StdAfx.h 1KB
BtnST.cpp 58KB
MySliderControl.h 4KB
MPlayerDlg.h 3KB
res
matrixsetsmallblue.bmp 17KB
MPlayer.rc2 399B
n-ext.bmp 308B
MPlayer.bmp 161KB
matrixsetblue.bmp 31KB
matrixsettinyblue.bmp 8KB
ext.bmp 308B
MPlayer.ico 15KB
BtnST.h 10KB
MPlayer.plg 3KB
MPlayer.h 1KB
VolumeOutWave.cpp 15KB
MPlayer.clw 2KB
MPlayer.cpp 2KB
MPlayerDlg.cpp 18KB
MatrixStatic.h 5KB
MPlayer.aps 254KB
VolumeOutWave.h 2KB
MPlayer.dsw 537B
MPlayer.rc 7KB
IVolume.h 796B
Debug
MatrixStatic.sbr 0B
Media.sbr 0B
vc60.pdb 380KB
MPlayerDlg.obj 76KB
MatrixStatic.obj 34KB
MPlayer.res 234KB
Media.obj 27KB
BtnST.obj 82KB
MySliderControl.sbr 0B
MPlayer.sbr 0B
MPlayer.pdb 433KB
MPlayer.obj 13KB
StdAfx.sbr 1.37MB
MPlayer.mdr 4B
MySliderControl.obj 19KB
MPlayer.exe 440KB
StdAfx.obj 116KB
MPlayerDlg.sbr 0B
BtnST.sbr 0B
AlexfMixer.h 4KB
resource.h 2KB
MPlayer.mdr 56B
Media.h 2KB
MPlayer.dsp 5KB
StdAfx.cpp 209B
Media.cpp 8KB
MPlayer.opt 51KB
MySliderControl.cpp 7KB
AlexfMixer.cpp 5KB
MatrixStatic.cpp 11KB
MPlayer.ncb 129KB
共 56 条
- 1
资源评论
onezeros
- 粉丝: 1087
- 资源: 211
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功