📄 3055.html
字号:
<html>
<head>
<title>用Bitmap取代Menu Item的文字项...还是要用到API</title>
</head>
<BODY BACKGROUND="" BGCOLOR="white" TEXT="black" LINK="red" VLINK="#808080" ALINK="">
<center>
<h1>用Bitmap取代Menu Item的文字项...还是要用到API</h1>
</center>
<HR><p>
Posted by <a href="mailto:ml.peng@wsmc.com.tw">彭明柳</a> on June 02, 1998 at 04:49:44:<p>
In Reply to: <a href="3042.html"><b>BitMap in Menu</b></a> posted by JHB on June 01, 1998 at 14:40:10:<p>
: How do you add bitmaps/Icons to a menu in addition to the caption?<br>: Thank you<br>您是说:<br>1.把整个menu变成bitmap?<br>2.将bitmap加到menu item旁边?(如vb的menu一样)<br>先介绍第一个好了...<p>1.在form的宣告区加入以下程式码:<p>Option Explicit<br>' API函数的用途自个查哦!<br>Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long<br>Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long<br>Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long<br>Private Declare Function ModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long<p>2. 在Form上加入Menu,插入两个menu item. (第一层:mnuFile,第二层: mnuFileTest1, mnuFileTest2,随便啦!)<br>3. 在form上加入两个picturebox,Say "picBitmaps(0)"及"picBitmaps(1)",并把它的Picture属性设为您要的图案(别太大张...)<br>4. 在Form的Load Event中,加入以下程式码:<p>Private Sub Form_Load()<br> Dim hMenu As Long '宣告menu的handle<br> Dim hSubMenu As Long 'sub menu的handle<br> Dim lngID As Long<br> <br> hMenu = GetMenu(Me.hWnd)<br> hSubMenu = GetSubMenu(hMenu, 0)<p> ' 利用Image属性传回影像的代码<br> picBitmaps(0).Picture = picBitmaps(0).Image<br> lngID = GetMenuItemID(hSubMenu, 0)<br> '瞒天过海的key point!!!<br> Call ModifyMenu(hMenu, lngID, 4, lngID, CLng(picBitmaps(0).Picture))<p> ' 利用Image属性传回影像的代码<br> picBitmaps(1).Picture = picBitmaps(1).Image<br> lngID = GetMenuItemID(hSubMenu, 1)<br> Call ModifyMenu(hMenu, lngID, 4, lngID, CLng(picBitmaps(1).Picture))<br>End Sub<br>5. 好啦,就是住样! Enjoy it!
<br>
<p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 3055-->
<!--top: 3056--><li><a href="3056.html"><b>Re: Bitmap and word title in menu</b></a> JHB <i>06:10:00 6/02/98</i>
(<!--responses: 3056-->1)
<ul><!--insert: 3056-->
<!--top: 3094--><li><a href="3094.html"><b>差不多啦!</b></a> 彭明柳 <i>22:19:52 6/03/98</i>
(<!--responses: 3094-->0)
<ul><!--insert: 3094-->
</ul><!--end: 3094-->
</ul><!--end: 3056-->
</ul><!--end: 3055-->
<br><HR><p>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -