Visual Basic 6. Руководство разработчика


Создание элементов меню, содержащих растровые изображения - часть 4


(ByVal hMenu As Long, ByVal nPos As Long) As Long

Private Declare Function GetMenuItemID Lib "user32"

(ByVal hMenu As Long, ByVal nPos 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 IpString As Any) 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 BitBIt Lib "gdi32" _

(ByVal hDestDC As Long, ByVal x As Long, ByVal у 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 DeleteDC Lib "gdi32" _

(ByVal hdc As Long) As Long

 

Const SRCCOPY   &HCC0020

Const MF_BYPOSITION - &H400&

Const MF_BITMAP   &H4&

 

Private Sub Form_Load()

Dim Width As Integer, Height As Integer

Dim hTmpDC As Long, hMenuID As Long

Dim hBitmap As Long, retValue As Long

Dim tmpID As Long

Dim fileName As String

Dim menuPos As Integer, menuID As Long

‘ Установка позиции меню и имени файла

menuPos = 0

fileName = App.Path & "\verdana.bmp"

Picturel.Picture = LoadPicture(fileName)

Width = 64

Height = 16

‘ Получение дескриптора меню

hMenuID = GetSubMenu(GetMenu(Me.hwnd), menuPos)

‘ Создание контекста устройства для хранения растрового

‘изображения

hTmpDC = CreateCompatibleDC(Picturel.hdc)

‘ Создание растрового изображения

hBitmap = CreateCompatibleBitmap(Picturel.hdc, Width, Height)

‘ Выбор растрового изображения во временный контекст

tmpID = SelectObject(hTmpDC, hBitmap)

‘ Копирование содержимого из элемента управления в   контекст




Начало  Назад  Вперед



Книжный магазин