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

📄 3056.html

📁 VB技巧问答10000例 VB技巧问答10000例
💻 HTML
字号:
<html>
  <head>
    <title>Re: Bitmap and word title in menu</title>
  </head>
  <BODY BACKGROUND="" BGCOLOR="white" TEXT="black" LINK="red" VLINK="#808080" ALINK="">
    <center>
      <h1>Re: Bitmap and word title in menu</h1>
    </center>

<HR><p>
Posted by <a href="mailto:JHBrother@MAilexcite.com">JHB</a> on June 02, 1998 at 06:10:00:<p>
In Reply to: <a href="3055.html"><b>用Bitmap取代Menu Item的文字项...还是要用到API</b></a> posted by 彭明柳 on June 02, 1998 at 04:49:44:<p>
Thank you for your answer.<br>However, I already know using modify menu. It only have the bitmap, no title.<br>I want the one with the title, just like the VB menu.<p><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!<p>
<br>
<p>
<a name="followups">Follow Ups:</a><br>
<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-->
<br><HR><p>

</body></html>

⌨️ 快捷键说明

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