Dim nHeight As Integer
Dim lTempID As Long
Dim hMenuID As Long
Dim lItemCount As Long
Dim hBitmap As Long
nWidth = Picture1(nLoopCtr).Width\Screen.TwipsPerPixelX 逆风者
nHeight = Picture1(nLoopCtr).Height\Screen.TwipsPerPixelY
hMenuID = GetSubMenu(GetMenu((Me.hwnd)), 1)
hTempDC = CreateCompatibleDC(Picture1(nLoopCtr).hdc)
For nLoopCtr = 0 To 3
hBitmap = CreateCompatibleBitmap(Picture1(nLoopCtr).hdc, nWidth, nHeight)
lTempID = SelectObject(hTempDC, hBitmap)
lResult = BitBlt(hTempDC, 0, 0, nWidth, nHeight, (Picture1(nLoopCtr).hdc) , 0, 0, SRCCOPY)
lTempID = SelectObject(hTempDC, lTempID)
mnuFaceSel(nLoopCtr).Caption = ""
lResult = ModifyMenu(hMenuID, nLoopCtr, MF_BYPOSITION Or MF_BITMAP, GetMe nuItemID(hMenuID, nLoopCtr), hBitmap)
Next nLoopCtr
lResult = DeleteDC(hTempDC)
End Sub
9.将如下的代码添加到"退出"子菜单的单击事件中:
Private Sub mnuExit_Click(Index As Integer)
Select Case Index
Case 0
Unload Me
End Select
End Sub
运行该样例程序,单击"脸谱"菜单,则会看到由4个脸谱图标所形成的位图子菜单项,如下图所示;单击"文件"\"退出"菜单可退出应用程序。 本文章更多内容:<<上一页 - 1 - 2 |