| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 848 人关注过本帖
标题:让菜单条用图片显示
只看楼主 加入收藏
CAD.CAD
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-12-27
收藏
 问题点数:0 回复次数:1 
让菜单条用图片显示
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long

Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long

Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

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

Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Const SRCCOPY = &HCC0020
Const MF_BITMAP = &H4&
Const MF_BYPOSITION = &H400&


Private Sub Form_Click()
 Dim nLoopCtr As Integer
    Dim lResult As Long
    Dim hTempDC As Long
    Dim nWidth As Long
    Dim nHeight As Long
    Dim lTempID As Long
    Dim hMenuID As Long
    Dim lItemCount As Long
    Dim hBitmap As Long
   
   
    nWidth = Pic.Width \ Screen.TwipsPerPixelX
    nHeight = Pic.Height \ Screen.TwipsPerPixelY
   
    hMenuID = GetSubMenu(GetMenu(Me.hwnd), 0)
    hTempDC = CreateCompatibleDC(Pic.hdc)
    For i = 0 To 1
        hBitmap = CreateCompatibleBitmap(Pic.hdc, nWidth, nHeight)
        lTempID = SelectObject(hTempDC, hBitmap)
        lResult = BitBlt(hTempDC, 0, 0, nWidth, nHeight, Pic.hdc, 0, 0, SRCCOPY)
        lTempID = SelectObject(hTempDC, lTempID)
      '  M_Item1(i).Caption = ""
        lResult = ModifyMenu(hMenuID, i, MF_BYPOSITION Or MF_BITMAP, GetMenuItemID(hMenuID, i), hBitmap)
    Next i
    lResult = DeleteDC(hTempDC)

End Sub

第二章-4.rar (12.89 KB)
搜索更多相关主题的帖子: Long ByVal Lib Function 
2007-12-27 11:10
xyc_lemon
Rank: 1
来 自:重庆
等 级:新手上路
帖 子:185
专家分:0
注 册:2007-12-22
收藏
得分:0 
行不``我看看``

[url=http://www./bbs/down.asp?html=863986]
2007-12-27 13:34
快速回复:让菜单条用图片显示
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033368 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved