資源簡介
mfc中Menu控件的美化,可改變任意菜單項的寬高,并使用自己定義的顏色作為背景,可以漸變。能夠在每個菜單項左側添加位圖,并改變菜單中右側箭頭形狀。本例子使用打過補丁后的VS2008創建,內附控件類的接口說明文檔

代碼片段和文件信息
//?HSGraphics.cpp:?implementation?of?the?CHSGraphics?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“HSGraphics.h“
#include?
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
void?WINAPI?Draw3DLine(HDC?hDC?bool?bHeave?const?POINT&?ptStart?const?POINT&?ptEnd)
{
HPEN hpen;
HGDIOBJ?hpenOld;
hpen?=?::CreatePen(?PS_SOLID?1?GetSysColor(?bHeave???COLOR_3DHILIGHT?:?COLOR_3DSHADOW??)?);
hpenOld?=?::Selectobject(?hDC?hpen?);
::MoveToEx(?hDC?ptStart.x?ptStart.y?NULL?);
::LineTo(?hDC?ptEnd.x?ptEnd.y?);
::Deleteobject(?hpen?);
hpen?=?::CreatePen(?PS_SOLID?1?GetSysColor(?bHeave???COLOR_3DSHADOW?:?COLOR_3DHILIGHT?)?);
::Selectobject(?hDC?hpen?);
::MoveToEx(?hDC?ptStart.x?ptStart.y+1?NULL?);
::LineTo(?hDC?ptEnd.x?ptEnd.y+1?);
::Deleteobject(?hpen?);
::Selectobject(?hDC?hpenOld?);
}
void?WINAPI?DrawRectEdge(HDC?hDC?const?RECT&?rect?int?nWidth?COLORREF?clrEdge?int?nstyle)
{
HPEN hpen =?::CreatePen(?nstyle?nWidth?clrEdge?);
HGDIOBJ hobjOld?=?::Selectobject(?hDC?hpen?);
POINT pt[3];
pt[0].x?=?pt[1].x?=?rect.left; // ?p1 +-----+?p2
pt[0].y?=?rect.bottom; // |
pt[1].y?=?pt[2].y?=?rect.top; // |
pt[2].x?=?rect.right; // ?p0 +
::Polyline(?hDC?pt?3?);
pt[1].x?=?pt[2].x?=?rect.right; // ??????+?p2
pt[1].y?=?rect.bottom; // ??|
pt[2].y?=?rect.top; // ??|
// ?p0?+-----+ p1
::Polyline(?hDC?pt?3?);
::Selectobject(?hDC?hobjOld?);
::Deleteobject(?hpen?);
}
void?WINAPI?Draw3DRectEdge(HDC?hDC?bool?bHeave?int?nLeft?int?nTop?int?nRight?int?nBottom)
{
HPEN hpen;
HGDIOBJ?hpenOld;
POINT pt[3];
pt[0].x?=?pt[1].x?=?nLeft; // ?p1 +-----+?p2
pt[0].y?=?nBottom; // |
pt[1].y?=?pt[2].y?=?nTop; // |
pt[2].x?=?nRight?+?1; // ?p0 +
hpen?=?::CreatePen(?PS_SOLID?1?GetSysColor(?bHeave???COLOR_3DHILIGHT?:?COLOR_3DSHADOW??)?);
hpenOld?=?::Selectobject(?hDC?hpen?);
::Polyline(?hDC?pt?3?);
::Deleteobject(?hpen?);
pt[1].x?=?pt[2].x?=?nRight; // ??????+?p2
pt[1].y?=?nBottom; // ??|
pt[2].y?=?nTop; // ??|
// ?p0?+-----+ p1
hpen?=?::CreatePen(?PS_SOLID?1?GetSysColor(?bHeave???COLOR_3DSHADOW?:?COLOR_3DHILIGHT?)?);
::Selectobject(?hDC?hpen?);
::Polyline(?hDC?pt?3?);
::Deleteobject(?hpen?);
::Selectobject(?hDC?hpenOld?);
}
void?WINAPI?Draw3DRgnEdge(HDC?hDC?bool?bHeave?HRGN?rgnWnd)
{
HBRUSH hbr;
HRGN rgnTemp?=?::CreateRectRgn(?0?0?0?0?);
::CombineRgn(?rgnTemp?rgnWnd?0?RGN_COPY?);
::OffsetRgn?(?rgnTemp?1?1?);
::CombineRgn(?rgnTemp?rgnWnd?rgnTemp?RGN_DIFF?);
hbr?=?::CreateSolidBrush(?GetSysColor(?bHeave???COLOR_3DHILIGHT?:?COLOR_3DSHADOW?)?);
::FillRgn(?hDC?rgnTemp?hbr?);
::Deleteobject(?hbr?);
::Combi
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????I.A....?????20897??2012-02-23?18:07??MenuControl\CHSMenu(Pro)使用說明.txt
????I.A....?????24606??2012-02-07?16:06??MenuControl\MyMenu\HSGraphics.cpp
????I.A....??????3511??2012-02-07?16:06??MenuControl\MyMenu\HSGraphics.h
????I.A....?????31133??2012-02-07?16:02??MenuControl\MyMenu\HSMenu.cpp
????I.A....??????8920??2012-02-07?16:03??MenuControl\MyMenu\HSMenu.h
????I.A....?????10242??2012-02-07?15:56??MenuControl\MyMenu\HSMenuPro.cpp
????I.A....??????3596??2012-02-07?16:05??MenuControl\MyMenu\HSMenuPro.h
????I.A....??????2685??2012-02-07?14:58??MenuControl\MyMenu\HSMenuX.cpp
????I.A....???????674??2003-03-10?22:06??MenuControl\MyMenu\HSMenuX.h
????I.A....????154628??2012-02-07?17:03??MenuControl\MyMenu\MyMenu.aps
????I.A....??????2090??2012-02-07?13:36??MenuControl\MyMenu\MyMenu.cpp
????I.A....???????508??2012-02-07?13:36??MenuControl\MyMenu\MyMenu.h
????I.A....??????6540??2012-02-07?17:03??MenuControl\MyMenu\MyMenu.rc
????I.A....??????8054??2012-02-07?15:00??MenuControl\MyMenu\MyMenu.vcproj
????I.A....??????1421??2012-05-10?11:51??MenuControl\MyMenu\MyMenu.vcproj.INGRASYS.marsquan.user
????I.A....??????7321??2012-02-07?17:07??MenuControl\MyMenu\MyMenuDlg.cpp
????I.A....???????852??2012-02-08?11:34??MenuControl\MyMenu\MyMenuDlg.h
????I.A....??????4224??2012-02-07?13:36??MenuControl\MyMenu\ReadMe.txt
????I.A....???????894??2012-02-07?14:43??MenuControl\MyMenu\res\icon001.ico
????I.A....???????894??2012-02-07?14:43??MenuControl\MyMenu\res\icon002.ico
????I.A....??????4150??2012-02-07?14:43??MenuControl\MyMenu\res\icon008.ico
????I.A....??????4150??2002-07-27?18:42??MenuControl\MyMenu\res\icon014.ico
????I.A....???????894??2012-02-07?14:43??MenuControl\MyMenu\res\icon015.ico
????I.A....??????3262??2002-09-02?11:37??MenuControl\MyMenu\res\icon106.ico
????I.A....??????3262??2012-02-07?14:43??MenuControl\MyMenu\res\icon107.ico
????I.A....??????3262??2002-09-02?11:37??MenuControl\MyMenu\res\icon109.ico
????I.A....??????3262??2002-06-07?15:09??MenuControl\MyMenu\res\icon115.ico
????I.A....??????3262??2002-06-07?16:10??MenuControl\MyMenu\res\icon130.ico
????I.A....??????3262??2002-05-30?22:08??MenuControl\MyMenu\res\icon15.ico
????I.A....??????3262??2002-07-20?20:24??MenuControl\MyMenu\res\icon18.ico
............此處省略34個文件信息
評論
共有 條評論