如题:)
解决方案 »
- 可以遍历本程序当前所有messagebox吗??
- CListCtrl如何象资源浏览器一样显示数据项信息?
- 请问我这样设计通讯合理不啊?
- 求vc开发的windows服务程序源码
- C++中关于运算符重载的问题
- 请问谁知道像QQ,如果有10个好友,我们就可以同时打开10个聊天对话框,关且可以把消息发给10个不同的人,是怎么做的?
- 请问:串口通信的控件Mscomm是不是只能应用在对话框Dialog下?
- 谁有在线播放的原代码啊,能不能不用WMP控件,用WINDOWS自带的函数实现?
- UINT nFlags 中的UINT是什么?是枚举常量吗?
- 如何在InstallShield制作的安装程序中定制卸载时执行的程序?
- 为什么我装了VS2005之后,启动只显示欢迎画面,然后主界面不出现程序就退出了,也没错误信息~~~奇怪啊~~急!!!!
- NAT的疑惑,我们都在用NAT?
下面是一段自绘菜单项目的代码,可供参考(用API写的,在MFC中你可以让MainFrame窗口处理消息WM_MEASUREITEM,WM_DRAWITEM来实现。)
int CChargeChildView::OnMeasureItem(WPARAM wParam,LPARAM lParam)
{
MEASUREITEMSTRUCT* lpmis=(MEASUREITEMSTRUCT*)lParam;
if(lpmis!=NULL)
{
if(lpmis->CtlType==ODT_MENU)
{
lpmis->itemWidth=160;
if(lpmis->itemID==0)
lpmis->itemHeight=3;
else
lpmis->itemHeight=22;
return TRUE;
}
}
return FALSE;
}
int CChargeChildView::OnDrawItem(WPARAM wParam,LPARAM lParam)
{
HBRUSH hbr=NULL,hbrLeft=NULL,hbrSel=NULL,hbrOrg=NULL;
HICON hIcon=NULL;
HFONT hfOrg=NULL;
char szMenuItem[50];
RECT rc;
DRAWITEMSTRUCT* lpdis=(DRAWITEMSTRUCT*)lParam;
if(lpdis!=NULL)
{
if(lpdis->CtlType==ODT_MENU)
{ hbr=CreateSolidBrush(RGB(249,248,247));
hbrLeft=CreateSolidBrush(RGB(219,216,209));
FillRect(lpdis->hDC,&lpdis->rcItem,hbr);
CopyRect(&rc,&lpdis->rcItem);
rc.right=rc.left+20;
FillRect(lpdis->hDC,&rc,hbrLeft); if(lpdis->itemID==0)
{
HPEN hpen,hpenOrg;
hpen=CreatePen(PS_SOLID,1,RGB(166,166,166));
hpenOrg=(HPEN)SelectObject(lpdis->hDC,hpen);
MoveToEx(lpdis->hDC,24,lpdis->rcItem.top+1,NULL);
LineTo(lpdis->hDC,lpdis->rcItem.right,lpdis->rcItem.top+1);
SelectObject(lpdis->hDC,hpenOrg);
DeleteObject(hpen); DeleteObject(hbrLeft);
DeleteObject(hbr);
return TRUE;
} SetBkMode(lpdis->hDC,TRANSPARENT); switch(lpdis->itemID)
{
case IDM_SAVE:
{
hIcon=LoadIcon(app.m_hInstance,MAKEINTRESOURCE(IDI_SAVE));
GetMenuString((HMENU)lpdis->hwndItem,lpdis->itemID,szMenuItem,50,MF_BYCOMMAND);
}
break;
case IDCANCEL:
{
hIcon=LoadIcon(app.m_hInstance,MAKEINTRESOURCE(IDI_CANCEL));
GetMenuString((HMENU)lpdis->hwndItem,lpdis->itemID,szMenuItem,50,MF_BYCOMMAND);
}
break;
default:
{
GetMenuString((HMENU)lpdis->hwndItem,lpdis->itemID,szMenuItem,50,MF_BYCOMMAND);
}
} CopyRect(&rc,&lpdis->rcItem);
if(hIcon!=NULL)
DrawIconEx(lpdis->hDC,lpdis->rcItem.left+2,lpdis->rcItem.top+2,hIcon,16,16,0,NULL,DI_NORMAL); lpdis->rcItem.left=24;
hfOrg=(HFONT)SelectObject(lpdis->hDC,m_hfMenuItem);
DrawText(lpdis->hDC,szMenuItem,-1,&lpdis->rcItem,DT_LEFT | DT_VCENTER | DT_SINGLELINE);
SelectObject(lpdis->hDC,hfOrg); DeleteObject(hbr);
DeleteObject(hbrLeft); if(lpdis->itemState & ODS_SELECTED)
{
//Draw select item bar
int nROP;
nROP=SetROP2(lpdis->hDC,R2_MASKPEN); lpdis->rcItem.left=rc.left;
CopyRect(&rc,&lpdis->rcItem);
hbrSel=CreateSolidBrush(RGB(182,189,210));
hbrOrg=(HBRUSH)SelectObject(lpdis->hDC,hbrSel);
Rectangle(lpdis->hDC,rc.left,rc.top,rc.right,rc.bottom);
SelectObject(lpdis->hDC,hbrOrg);
DeleteObject(hbrSel);
SetROP2(lpdis->hDC,nROP); }
SetBkMode(lpdis->hDC,OPAQUE);
return TRUE;
}
} return FALSE;
}
http://community.csdn.net/Expert/topic/4419/4419124.xml?temp=.2382318