#include "stdafx.h" // Standard windows header file
#include "officexpmenu.h" // COfficeXPMenu class declaration
#include <afxpriv.h> //SK: makes A2W and other spiffy AFX macros work
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define GAP 1
#ifndef OBM_CHECK
#define OBM_CHECK 32760 // from winuser.h
#endif
#if _MFC_VER <0x400
#error This code does not work on Versions of MFC prior to 4.0
#endif
static CPINFO CPInfo;
// how the menu's are drawn in win9x/NT/2000
UINT COfficeXPMenu::original_drawmode=TYPE_NORMAL;
BOOL COfficeXPMenu::xp_select_disabled=FALSE;
// how the menu's are drawn in winXP
UINT COfficeXPMenu::xp_drawmode=TYPE_XP;
BOOL COfficeXPMenu::original_select_disabled=TRUE;
enum Win32Type
{
Win32s,
Windoze95,
WinNT3,
WinNT4orHigher
};
Win32Type IsShellType()
{
Win32Type ShellType;
DWORD winVer;
OSVERSIONINFO *osvi;
winVer=GetVersion();
if(winVer<0x80000000)
{/*NT */
ShellType=WinNT3;
osvi= (OSVERSIONINFO *)malloc(sizeof(OSVERSIONINFO));
if (osvi!=NULL)
{
memset(osvi,0,sizeof(OSVERSIONINFO));
osvi->dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(osvi);
if (osvi->dwMajorVersion>=4L)
ShellType=WinNT4orHigher;//yup, it is NT 4 or higher!
free(osvi);
}
}
else if (LOBYTE(LOWORD(winVer))<4)
ShellType=Win32s;/*Win32s*/
else
ShellType=Windoze95;/*Windoze95*/
return ShellType;
}
static Win32Type g_Shell=IsShellType();
void COfficeXPMenuData::SetAnsiString(LPCSTR szAnsiString)
{
USES_CONVERSION;
SetWideString(A2W(szAnsiString)); //SK: see MFC Tech Note 059
}
CString COfficeXPMenuData::GetString(void)//returns the menu text in ANSI or UNICODE
//depending on the MFC-Version we are using
{
CString strText;
if (m_szMenuText)
{
#ifdef UNICODE
strText = m_szMenuText;
#else
USES_CONVERSION;
strText=W2A(m_szMenuText); //SK: see MFC Tech Note 059
#endif
}
return strText;
}
CTypedPtrArray<CPtrArray, HMENU> COfficeXPMenu::m_AllSubMenus; // Stores list of all sub-menus
COfficeXPMenu::COfficeXPMenu()
{
m_bDynIcons = FALSE; // O.S. - no dynamic icons by default
disable_old_style=FALSE;
m_iconX = 16; // Icon sizes default to 16 x 16
m_iconY = 15; // ...
m_selectcheck = -1;
m_unselectcheck = -1;
checkmaps=NULL;
checkmapsshare=FALSE;
// set the color used for the transparent background in all bitmaps
m_bitmapBackground=RGB(192,192,192); //gray
m_bitmapBackgroundFlag=FALSE;
GetCPInfo(CP_ACP,&CPInfo);
}
COfficeXPMenu::~COfficeXPMenu()
{
DestroyMenu();
}
BOOL COfficeXPMenu::IsNewShell ()
{
return (Windoze95==g_Shell || WinNT4orHigher==g_Shell);
}
COfficeXPMenuData::~COfficeXPMenuData()
{
if(bitmap)
delete(bitmap);
delete[] m_szMenuText; //Need not check for NULL because ANSI X3J16 allows "delete NULL"
}
void COfficeXPMenuData::SetWideString(const wchar_t *szWideString)
{
delete[] m_szMenuText;//Need not check for NULL because ANSI X3J16 allows "delete NULL"
if (szWideString)
{
m_szMenuText = new wchar_t[sizeof(wchar_t)*(wcslen(szWideString)+1)];
if (m_szMenuText)
wcscpy(m_szMenuText,szWideString);
}
else
m_szMenuText=NULL;//set to NULL so we need not bother about dangling non-NULL Ptrs
}
BOOL COfficeXPMenu::IsMenu(CMenu *submenu)
{
int m;
int numSubMenus = m_AllSubMenus.GetUpperBound();
for(m=0;m<=numSubMenus;++m)
{
if(submenu->m_hMenu==m_AllSubMenus[m])return(TRUE);
}
return(FALSE);
}
BOOL COfficeXPMenu::IsMenu(HMENU submenu)
{
int m;
int numSubMenus = m_AllSubMenus.GetUpperBound();
for(m=0;m<=numSubMenus;++m)
{
if(submenu==m_AllSubMenus[m])return(TRUE);
}
return(FALSE);
}
BOOL COfficeXPMenu::DestroyMenu()
{
// Destroy Sub menus:
int m,n;
int numAllSubMenus = m_AllSubMenus.GetUpperBound();
for(n = numAllSubMenus; n>= 0; n--)
{
if(m_AllSubMenus[n]==this->m_hMenu)m_AllSubMenus.RemoveAt(n);
}
int numSubMenus = m_SubMenus.GetUpperBound();
for(m = numSubMenus; m >= 0; m--)
{
numAllSubMenus = m_AllSubMenus.GetUpperBound();
for(n = numAllSubMenus; n>= 0; n--)
{
if(m_AllSubMenus[n]==m_SubMenus[m])m_AllSubMenus.RemoveAt(n);
}
delete((COfficeXPMenu *)FromHandle(m_SubMenus[m]));
}
m_SubMenus.RemoveAll();
// Destroy menu data
int numItems = m_MenuList.GetUpperBound();
for(m = 0; m <= numItems; m++)delete(m_MenuList[m]);
m_MenuList.RemoveAll();
if(checkmaps&&!checkmapsshare)
{
delete checkmaps;
checkmaps=NULL;
}
// Call base-class implementation last:
return(CMenu::DestroyMenu());
};
int COfficeXPMenu::GetMenuDrawMode(void)
{
COLORREF m_newclrBack=GetSysColor((IsNewShell())?COLOR_3DFACE:COLOR_MENU);
COLORREF m_clrBack=GetSysColor(COLOR_MENU);
BOOL XPflag = m_newclrBack==m_clrBack ? FALSE : TRUE;
if(XPflag)
return(xp_drawmode);
return(original_drawmode);
}
void COfficeXPMenu::DrawItem (LPDRAWITEMSTRUCT lpDIS)
{
ASSERT(lpDIS != NULL);
COLORREF m_newclrBack=GetSysColor((IsNewShell())?COLOR_3DFACE:COLOR_MENU);
COLORREF m_clrBack=GetSysColor(COLOR_MENU);
BOOL XPflag = m_newclrBack==m_clrBack ? FALSE : TRUE;
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
if(pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE)DrawItem_Win9xNT2000(lpDIS);
else
{
if(XPflag)
{
if(xp_drawmode==TYPE_XP) DrawItem_WinXP(lpDIS);
else DrawItem_Win9xNT2000(lpDIS);
}
else
{
if(original_drawmode==TYPE_XP) DrawItem_WinXP(lpDIS);
else DrawItem_Win9xNT2000(lpDIS);
}
}
}
void COfficeXPMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS)
{
ASSERT(lpDIS != NULL);
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
CRect rect;
UINT state = (((COfficeXPMenuData*)(lpDIS->itemData))->nFlags);
CBrush m_brBackground;
m_brBackground.CreateSolidBrush(GetSysColor((IsNewShell())?COLOR_3DFACE:COLOR_MENU));
// remove the selected bit if it's grayed out
if(lpDIS->itemState & ODS_GRAYED && !original_select_disabled)
{
if(lpDIS->itemState & ODS_SELECTED)lpDIS->itemState=lpDIS->itemState & ~ODS_SELECTED;
}
if(state & MF_SEPARATOR)
{
rect.CopyRect(&lpDIS->rcItem);
pDC->FillRect (rect,&m_brBackground);
rect.top += (rect.Height()>>1);
pDC->DrawEdge(&rect,EDGE_ETCHED,BF_TOP);
}
else
{
CRect rect2;
BOOL standardflag=FALSE,selectedflag=FALSE,disableflag=FALSE;
BOOL checkflag=FALSE;
COLORREF crText = GetSysColor(COLOR_MENUTEXT);
COLORREF m_clrBack=GetSysColor((IsNewShell())?COLOR_3DFACE:COLOR_MENU);
CBrush m_brSelect;
CPen m_penBack;
int x0,y0,dy;
int nIconNormal=-1,xoffset=-1;
CImageList *bitmap=NULL;
CFont m_fontMenu;
LOGFONT m_lf;
// set some colors and the font
m_penBack.CreatePen (PS_SOLID,0,GetSysColor((IsNewShell())?COLOR_3DFACE:COLOR_MENU));
m_brSelect.CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
ZeroMemory ((PVOID) &m_lf,sizeof (LOGFONT));
NONCLIENTMETRICS nm;
nm.cbSize = sizeof (NONCLIENTMETRICS);
VERIFY (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,nm.cbSize,&nm,0));
m_lf = nm.lfMenuFont;
m_fontMenu.CreateFontIndirect (&m_lf);
// draw the colored rectangle portion
rect.CopyRect(&lpDIS->rcItem);
rect2=rect;
// draw the up/down/focused/disabled state
UINT state = lpDIS->itemState;
CString strText;
LOGFONT lf;
lf = m_lf;
CFont dispFont;
CFont *pFont=NULL;
if(lpDIS->itemData != NULL)
{
nIconNormal = (((COfficeXPMenuData*)(lpDIS->itemData))->menuIconNormal);
xoffset = (((COfficeXPMenuData*)(lpDIS->itemData))->xoffset);
bitmap = (((COfficeXPMenuData*)(lpDIS->itemData))->bitmap);
strText = ((COfficeXPMenuData*) (lpDIS->itemData))->GetString();
if(state&ODS_CHECKED && nIconNormal<0)
{
if(state&ODS_SELECTED && m_selectcheck>0)checkflag=TRUE;
else if(m_unselectcheck>0) checkfl
没有合适的资源?快使用搜索试试~ 我知道了~
VC实现控制系统音量大小程序(编译通过)
共45个文件
h:11个
cpp:10个
ico:9个
5星 · 超过95%的资源 需积分: 49 154 下载量 168 浏览量
2009-05-19
09:52:40
上传
评论 4
收藏 112KB RAR 举报
温馨提示
VC编程实现对系统音量大小的控制,很实用的代码,可以直接嵌入到其它程序里面,为开发音频软件提供了方便
资源推荐
资源详情
资源评论
收起资源包目录
Volume.rar (45个子文件)
Volume
mutecontrol.cpp 3KB
VolumControl.h 694B
OfficeXPMenu.h 10KB
Link.h 1KB
TransparentImage.cpp 2KB
FaderWnd.h 1KB
StdAfx.cpp 203B
音量控制.exe 68KB
VDlg.h 2KB
V.clw 2KB
V.plg 3KB
OfficeXPMenu.cpp 73KB
StdAfx.h 1KB
V.APS 43KB
VDlg.cpp 13KB
VolumControl.cpp 4KB
Resource.h 2KB
V.h 1KB
mutecontrol.h 436B
res
xptheme.bin 653B
icon2.ico 766B
11.bmp 39KB
22.bmp 39KB
2.ico 3KB
V.rc2 393B
bg.bmp 834B
1.ico 3KB
V.ico 1KB
Thumbs.db 12KB
toolbar1.bmp 478B
icon3.ico 894B
138.ico 2KB
142.ico 894B
139.ico 894B
icon1.ico 766B
TransparentImage.h 373B
Link.cpp 3KB
V.dsw 525B
PPDlg.h 1KB
V.rc 8KB
V.cpp 2KB
PPDlg.cpp 1KB
V.dsp 5KB
FaderWnd.cpp 2KB
Settings.ini 93B
共 45 条
- 1
emily836
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页