Title | Get the system bitmaps for minimizing, restoring, ComboBox arrows, etc. |
Description | This example shows how to get the system bitmaps for minimizing, restoring, ComboBox arrows, etc. in Visual Basic 6. The program uses the LoadBitmapNumber API function to load the system bitmaps into an ImageList control. It then displays the images in an ImageCombo control. |
Keywords | bitmap, image, system bitmap, system image |
Categories | Windows, Graphics |
|
Private Sub Form_Load()
LoadBitmapNames
LoadSystemImages ImageList1
DisplaySystemImages ImageList1, ImageCombo1
End Sub
Private Sub LoadSystemImages(ByVal iml As ImageList)
Dim mem_dc As Long
Dim mem_bm As Long
Dim orig_bm As Long
Dim wid As Long
Dim hgt As Long
Dim bitmap_number As Long
Dim bm As BITMAP
' Create the device context.
mem_dc = CreateCompatibleDC(hdc)
' Create the bitmaps.
picHidden.AutoRedraw = True
For bitmap_number = OBM_FIRST To OBM_LAST
' Load the bitmap.
mem_bm = LoadBitmapNumber(ByVal 0&, bitmap_number)
' Make the device context use the bitmap.
orig_bm = SelectObject(mem_dc, mem_bm)
' Get the bitmap's size.
APIGetObject mem_bm, Len(bm), bm
' Copy the device context into the PictureBox.
picHidden.Line (0, 0)-Step(picHidden.ScaleWidth, _
picHidden.ScaleHeight), picHidden.BackColor, BF
BitBlt picHidden.hdc, _
0, 0, bm.bmWidth, bm.bmHeight, _
mem_dc, 0, 0, vbSrcCopy
SelectObject mem_dc, orig_bm
DeleteObject mem_bm
picHidden.Picture = picHidden.Image
' Copy the picture into the ImageList.
iml.ListImages.Add , "#" & bitmap_number, _
picHidden.Picture
Next bitmap_number
' Delete the bitmap and dc.
DeleteDC mem_dc
End Sub
Private Sub DisplaySystemImages(ByVal iml As ImageList, _
ByVal icb As ImageCombo)
Dim bitmap_number As Long
Set icb.ImageList = iml
For bitmap_number = 1 To iml.ListImages.Count
icb.ComboItems.Add , , _
m_BitmapNames(bitmap_number), bitmap_number
Next bitmap_number
End Sub
|