⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_21599.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:21599 发表者:duanruiyu 发表日期:2002-11-19 08:26:56
<br>主题:请问怎样能改变菜单的颜色?
<br>内容:请问怎样能改变菜单的颜色?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:CDMA2000 回复日期:2002-11-19 09:04:24
<br>内容:cfreemenu:this class is a owner drawn menu, you will be able to:<BR>1. set the menu position<BR>2. set the menu background../di2001.jpgd color<BR>3. set the menu bar's edge color<BR>4. set the menu text color<BR>5. set the menu text font<BR>6. set the first level menu as horizontal or vertical<BR>7.develop the class to implement menuitem with icon,and cool background../di2001.jpgr (as wood, metal ,or other picture etc.)<BR><BR><BR>in order to use it,you need add the file freemenu.cpp ,freemenu.h,menuitemwnd.cpp and menuitemwnd.h to your project.if you don't change any of the code,you can get the 1-6 function.to redraw the cfreemenu's method drawmenu you can develop it.<BR><BR>in the beginning of&nbsp;&nbsp;.h file add those code:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#include "freemenu.h"<BR><BR>in the containing class add those code:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cfreemenu *m_menu;<BR><BR>in the .cpp file of the class where you want use the menu add those code:<BR><BR>1. in initialization part(as cdialog class' oninitdialog method,the cfreemenu need a parent window) add those code:<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;m_menu = new cfreemenu(idr_menu1,&nbsp;&nbsp;&nbsp;&nbsp; //the menu id<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpoint(10,10),this,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //the menu position and it's parent window<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rgb(192,192,192),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//the color of the menu bar's background../di2001.jpgd<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rgb(255,225,255),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//the color of the menu bar's left and up edge<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rgb(128,128,128),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//the color of the menu bar's right and down edge<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rgb(0,0,0),&amp;font,0);&nbsp;&nbsp;&nbsp;&nbsp; //the color and font of the menu text, when the<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// last parameter is 0 the first level of the menu if<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// horizontal,1 meant vertical<BR><BR>2.where you need the menu you add those code:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_menu-&gt;drawmenu();<BR><BR>3.in your class derive the windowproc method to call the function:<BR><BR>void ctestdidlg::onmenuitem32782() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;afxmessagebox("test menu");&nbsp;&nbsp;&nbsp;&nbsp;<BR>}<BR><BR>lresult ctestdidlg::windowproc(uint message, wparam wparam, lparam lparam) <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(message==id_menuitem32782)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;onmenuitem32782();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;return cdialog::windowproc(message, wparam, lparam);<BR>}<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:徐景周 回复日期:2002-11-19 09:26:36
<br>内容:重载菜单,重绘菜单背景色,如下菜单类:<BR>http://www.copathway.com/itbookreview/view_paper.asp?paper_id=317<BR><BR>http://www.copathway.com/itbookreview/view_paper.asp?paper_id=311
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:duanruiyu 回复日期:2002-11-19 10:17:24
<br>内容:谢谢二位!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -