📄 bcmenu.h
字号:
// Function to set how disabled items are drawn (mode=FALSE means they are not drawn selected)
static void SetSelectDisableMode(BOOL mode){
BCMenu::original_select_disabled=mode;
BCMenu::xp_select_disabled=mode;
};
static int BCMenu::GetMenuDrawMode(void);
static BOOL BCMenu::GetSelectDisableMode(void);
// how the bitmaps are drawn in XP Luna mode
static void SetXPBitmap3D(BOOL val){
BCMenu::xp_draw_3D_bitmaps=val;
};
static BOOL GetXPBitmap3D(void){return BCMenu::xp_draw_3D_bitmaps;}
// Customizing:
// Set icon size
void SetIconSize (int, int);
// set the color in the bitmaps that is the background transparent color
void SetBitmapBackground(COLORREF color);
void UnSetBitmapBackground(void);
// obsolete functions for setting how menu images are dithered for disabled menu options
BOOL GetDisableOldStyle(void);
void SetDisableOldStyle(void);
void UnSetDisableOldStyle(void);
static COLORREF LightenColor(COLORREF col,double factor);
static COLORREF DarkenColor(COLORREF col,double factor);
// Miscellaneous Protected Member functions
protected:
static BOOL IsNewShell(void);
static BOOL IsWinXPLuna(void);
static BOOL IsLunaMenuStyle(void);
static BOOL IsWindowsClassicTheme(void);
BCMenuData *BCMenu::FindMenuItem(UINT nID);
BCMenu *FindMenuOption(int nId,int& nLoc);
BCMenu *FindAnotherMenuOption(int nId,int& nLoc,CArray<BCMenu*,BCMenu*>&bcsubs,
CArray<int,int&>&bclocs);
BCMenuData *FindMenuOption(wchar_t *lpstrText);
void InsertSpaces(void);
void DrawCheckMark(CDC *pDC,int x,int y,COLORREF color);
void DrawRadioDot(CDC *pDC,int x,int y,COLORREF color);
BCMenuData *NewODMenu(UINT pos,UINT nFlags,UINT nID,CString string);
void SynchronizeMenu(void);
void BCMenu::InitializeMenuList(int value);
void BCMenu::DeleteMenuList(void);
BCMenuData *BCMenu::FindMenuList(UINT nID);
void DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS);
void DrawItem_WinXP (LPDRAWITEMSTRUCT lpDIS);
BOOL Draw3DCheckmark(CDC *dc, const CRect& rc,BOOL bSelected,HBITMAP hbmCheck);
BOOL DrawXPCheckmark(CDC *dc, const CRect& rc, HBITMAP hbmCheck,COLORREF &colorout);
void DitherBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth,
int nHeight, HBITMAP hbm, int nXSrc, int nYSrc,COLORREF bgcolor);
void DitherBlt2(CDC *drawdc, int nXDest, int nYDest, int nWidth,
int nHeight, CBitmap &bmp, int nXSrc, int nYSrc,COLORREF bgcolor);
BOOL GetBitmapFromImageList(CDC* pDC,CImageList *imglist,int nIndex,CBitmap &bmp);
BOOL ImageListDuplicate(CImageList *il,int xoffset,CImageList *newlist);
static WORD NumBitmapColors(LPBITMAPINFOHEADER lpBitmap);
void ColorBitmap(CDC* pDC, CBitmap& bmp,CSize bitmap_size,CSize icon_size,COLORREF fill,COLORREF border,int hatchstyle=-1);
void RemoveTopLevelOwnerDraw(void);
int GetMenuStart(void);
void GetFadedBitmap(CBitmap &bmp);
void GetShadowBitmap(CBitmap &bmp);
int AddToGlobalImageList(CImageList *il,int xoffset,int nID);
int GlobalImageListOffset(int nID);
BOOL CanDraw3DImageList(int offset);
// Member Variables
protected:
CTypedPtrArray<CPtrArray, BCMenuData*> m_MenuList; // Stores list of menu items
// When loading an owner-drawn menu using a Resource, BCMenu must keep track of
// the popup menu's that it creates. Warning, this list *MUST* be destroyed
// last item first :)
CTypedPtrArray<CPtrArray, HMENU> m_SubMenus; // Stores list of sub-menus
// Stores a list of all BCMenu's ever created
static CTypedPtrArray<CPtrArray, HMENU> m_AllSubMenus;
// Global ImageList
static CImageList m_AllImages;
static CArray<int,int&> m_AllImagesID;
// icon size
int m_iconX,m_iconY;
COLORREF m_bitmapBackground;
BOOL m_bitmapBackgroundFlag;
BOOL disable_old_style;
static UINT original_drawmode;
static BOOL original_select_disabled;
static UINT xp_drawmode;
static BOOL xp_select_disabled;
static BOOL xp_draw_3D_bitmaps;
CImageList *checkmaps;
BOOL checkmapsshare;
int m_selectcheck;
int m_unselectcheck;
BOOL m_bDynIcons;
BOOL m_loadmenu;
};
class BCMenuToolBar : public CToolBar{
public:
BCMenuToolBar() : CToolBar() {m_iconX=m_iconY=0;}
BOOL LoadToolBar(LPCTSTR lpszResourceName);
BOOL LoadToolBar(UINT nIDResource){
return LoadToolBar(MAKEINTRESOURCE(nIDResource));
}
BOOL LoadBitmap(LPCTSTR lpszResourceName);
void GetIconSize(int &iconx,int &icony){iconx=m_iconX;icony=m_iconY;}
protected:
int m_iconX,m_iconY;
};
#define BCMENU_USE_MEMDC
#ifdef BCMENU_USE_MEMDC
//////////////////////////////////////////////////
// BCMenuMemDC - memory DC
//
// Author: Keith Rule
// Email: keithr@europa.com
// Copyright 1996-1997, Keith Rule
//
// You may freely use or modify this code provided this
// Copyright is included in all derived versions.
//
// History - 10/3/97 Fixed scrolling bug.
// Added print support.
// 25 feb 98 - fixed minor assertion bug
//
// This class implements a memory Device Context
class BCMenuMemDC : public CDC
{
public:
// constructor sets up the memory DC
BCMenuMemDC(CDC* pDC,LPCRECT lpSrcRect) : CDC()
{
ASSERT(pDC != NULL);
m_rect.CopyRect(lpSrcRect);
m_pDC = pDC;
m_pOldBitmap = NULL;
m_bMemDC = !pDC->IsPrinting();
if (m_bMemDC) // Create a Memory DC
{
CreateCompatibleDC(pDC);
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_pOldBitmap = SelectObject(&m_bitmap);
SetWindowOrg(m_rect.left, m_rect.top);
}
else // Make a copy of the relevent parts of the current DC for printing
{
m_bPrinting = pDC->m_bPrinting;
m_hDC = pDC->m_hDC;
m_hAttribDC = pDC->m_hAttribDC;
}
}
// Destructor copies the contents of the mem DC to the original DC
~BCMenuMemDC()
{
if (m_bMemDC)
{
// Copy the offscreen bitmap onto the screen.
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
this, m_rect.left, m_rect.top, SRCCOPY);
//Swap back the original bitmap.
SelectObject(m_pOldBitmap);
} else {
// All we need to do is replace the DC with an illegal value,
// this keeps us from accidently deleting the handles associated with
// the CDC that was passed to the constructor.
m_hDC = m_hAttribDC = NULL;
}
}
// Allow usage as a pointer
BCMenuMemDC* operator->() {return this;}
// Allow usage as a pointer
operator BCMenuMemDC*() {return this;}
private:
CBitmap m_bitmap; // Offscreen bitmap
CBitmap* m_pOldBitmap; // bitmap originally found in BCMenuMemDC
CDC* m_pDC; // Saves CDC passed in constructor
CRect m_rect; // Rectangle of drawing area.
BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.
};
#endif
#endif
//*************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -