home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / bmp2ico / bmp2icon.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-12  |  19.1 KB  |  527 lines

  1. VERSION 5.00
  2. Begin VB.Form frmBmp2Icon 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "BMP to ICO, ICO to BMP"
  5.    ClientHeight    =   4410
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   4395
  9.    LinkTopic       =   "Form1"
  10.    LockControls    =   -1  'True
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   294
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   293
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin VB.PictureBox Picture2 
  18.       AutoRedraw      =   -1  'True
  19.       AutoSize        =   -1  'True
  20.       BackColor       =   &H80000005&
  21.       Height          =   540
  22.       Left            =   690
  23.       ScaleHeight     =   32
  24.       ScaleMode       =   3  'Pixel
  25.       ScaleWidth      =   32
  26.       TabIndex        =   14
  27.       Top             =   2640
  28.       Width           =   540
  29.    End
  30.    Begin VB.PictureBox Picture1 
  31.       AutoRedraw      =   -1  'True
  32.       AutoSize        =   -1  'True
  33.       BackColor       =   &H80000005&
  34.       Height          =   540
  35.       Left            =   660
  36.       Picture         =   "Bmp2Icon.frx":0000
  37.       ScaleHeight     =   32
  38.       ScaleMode       =   3  'Pixel
  39.       ScaleWidth      =   32
  40.       TabIndex        =   13
  41.       Top             =   1080
  42.       Width           =   540
  43.    End
  44.    Begin VB.CommandButton Command4 
  45.       Height          =   345
  46.       Left            =   3930
  47.       TabIndex        =   11
  48.       ToolTipText     =   "Clear display of new bmp"
  49.       Top             =   3630
  50.       Width           =   135
  51.    End
  52.    Begin VB.CommandButton Command3 
  53.       Height          =   345
  54.       Left            =   1620
  55.       TabIndex        =   10
  56.       ToolTipText     =   "Clear display of new ico"
  57.       Top             =   3630
  58.       Width           =   135
  59.    End
  60.    Begin VB.PictureBox picImage 
  61.       Appearance      =   0  'Flat
  62.       AutoRedraw      =   -1  'True
  63.       BackColor       =   &H00000000&
  64.       ForeColor       =   &H80000008&
  65.       Height          =   540
  66.       Left            =   3750
  67.       ScaleHeight     =   34
  68.       ScaleMode       =   3  'Pixel
  69.       ScaleWidth      =   34
  70.       TabIndex        =   9
  71.       Top             =   30
  72.       Visible         =   0   'False
  73.       Width           =   540
  74.    End
  75.    Begin VB.PictureBox picMask 
  76.       Appearance      =   0  'Flat
  77.       AutoRedraw      =   -1  'True
  78.       BackColor       =   &H80000005&
  79.       ForeColor       =   &H80000008&
  80.       Height          =   540
  81.       Left            =   3750
  82.       ScaleHeight     =   34
  83.       ScaleMode       =   3  'Pixel
  84.       ScaleWidth      =   34
  85.       TabIndex        =   8
  86.       Top             =   600
  87.       Visible         =   0   'False
  88.       Width           =   540
  89.    End
  90.    Begin VB.CommandButton Command2 
  91.       Caption         =   "Ico to Bmp"
  92.       Height          =   345
  93.       Left            =   2640
  94.       TabIndex        =   7
  95.       Top             =   3630
  96.       Width           =   1185
  97.    End
  98.    Begin VB.CommandButton Command1 
  99.       Caption         =   "Bmp to Ico"
  100.       Height          =   345
  101.       Left            =   330
  102.       TabIndex        =   6
  103.       Top             =   3630
  104.       Width           =   1185
  105.    End
  106.    Begin VB.PictureBox Picture4 
  107.       BackColor       =   &H80000005&
  108.       Height          =   540
  109.       Left            =   2850
  110.       ScaleHeight     =   32
  111.       ScaleMode       =   3  'Pixel
  112.       ScaleWidth      =   32
  113.       TabIndex        =   1
  114.       Top             =   2610
  115.       Width           =   540
  116.    End
  117.    Begin VB.PictureBox Picture3 
  118.       AutoSize        =   -1  'True
  119.       BackColor       =   &H80000005&
  120.       Height          =   540
  121.       Left            =   2850
  122.       Picture         =   "Bmp2Icon.frx":0282
  123.       ScaleHeight     =   32
  124.       ScaleMode       =   3  'Pixel
  125.       ScaleWidth      =   32
  126.       TabIndex        =   0
  127.       Top             =   1080
  128.       Width           =   540
  129.    End
  130.    Begin VB.Label Label5 
  131.       Caption         =   "(Size of examples here is 32x32 pixels)"
  132.       Height          =   195
  133.       Left            =   90
  134.       TabIndex        =   12
  135.       Top             =   30
  136.       Width           =   3285
  137.    End
  138.    Begin VB.Line Line1 
  139.       X1              =   142
  140.       X2              =   142
  141.       Y1              =   48
  142.       Y2              =   264
  143.    End
  144.    Begin VB.Label Label4 
  145.       Caption         =   "New bmp (saved in file ""Fromico.bmp"")"
  146.       Height          =   405
  147.       Left            =   2400
  148.       TabIndex        =   5
  149.       Top             =   2100
  150.       Width           =   1575
  151.    End
  152.    Begin VB.Label Label3 
  153.       Caption         =   "Original ico"
  154.       Height          =   285
  155.       Left            =   2670
  156.       TabIndex        =   4
  157.       Top             =   690
  158.       Width           =   855
  159.    End
  160.    Begin VB.Label Label2 
  161.       Caption         =   "New ico (saved in file  ""Frombmp.ico"")"
  162.       Height          =   465
  163.       Left            =   300
  164.       TabIndex        =   3
  165.       Top             =   2070
  166.       Width           =   1485
  167.    End
  168.    Begin VB.Label Label1 
  169.       Caption         =   "Original bmp"
  170.       Height          =   285
  171.       Left            =   480
  172.       TabIndex        =   2
  173.       Top             =   690
  174.       Width           =   975
  175.    End
  176. Attribute VB_Name = "frmBmp2Icon"
  177. Attribute VB_GlobalNameSpace = False
  178. Attribute VB_Creatable = False
  179. Attribute VB_PredeclaredId = True
  180. Attribute VB_Exposed = False
  181. ' Bmp2Ico.frm
  182. ' By Herman Liu
  183. ' To show how to make an icon file out of a bitmap, and vice versa.
  184. ' Sometimes you see a nice bitmap picture, or part of it, and want to make it as an icon.
  185. ' You can do what you want now (Just add "file open" and "file save" functions to open the
  186. ' bmp/ico file and save the ico/bmp file respectively. That is, for example, instead of
  187. ' using the existing image in Picture1, load your own. When it is converted into an icon in
  188. ' Picture2, save it to a file name you want.  Of course, in this case, you may want to fix
  189. ' the size of the image first).
  190. ' Notes: If you have a copy of my "IconEdit", and you want to give yourself a challenge, you
  191. ' can incorporate this code into it. This will be fairly easy. (Basically, you only need to
  192. ' add a few menu items, as almost all the APIs here are already there, so are all major
  193. ' procedures).  In "IconEdit" I have left out many functions, since I don't want to blur the
  194. ' essentials.  For example, if I open up just the Region function, there would be
  195. ' implications on Flip/Rotate/Invert and I have to allow region dragging and so on.)
  196. Option Explicit
  197. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, _
  198.     ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _
  199.     ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  200. Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, _
  201.     ByVal nWidth As Long, ByVal nHeight As Long) As Long
  202. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
  203. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
  204.     ByVal hObject As Long) As Long
  205. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
  206. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  207. Private Declare Function CreateIconIndirect Lib "user32" (icoinfo As ICONINFO) As Long
  208. Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (lppictDesc As _
  209.      pictDesc, riid As Guid, ByVal fown As Long, ipic As IPicture) As Long
  210.      
  211. Private Declare Function GetIconInfo Lib "user32" (ByVal hIcon As Long, _
  212.      icoinfo As ICONINFO) As Long
  213.      
  214. Private Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, _
  215.     ByVal crColor As Long) As Long
  216. Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight _
  217.     As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
  218. 'Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, _
  219.       ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
  220. Private Type ICONINFO
  221.     fIcon As Long
  222.     xHotspot As Long
  223.     yHotspot As Long
  224.     hBMMask As Long
  225.     hBMColor As Long
  226. End Type
  227. Private Type Guid
  228.     Data1 As Long
  229.     Data2 As Integer
  230.     Data3 As Integer
  231.     Data4(7) As Byte
  232. End Type
  233. Private Type pictDesc
  234.     cbSizeofStruct As Long
  235.     picType As Long
  236.     hImage As Long
  237.     xExt As Long
  238.     yExt As Long
  239. End Type
  240. Const PICTYPE_BITMAP = 1
  241. Const PICTYPE_ICON = 3
  242. Dim iGuid As Guid
  243. Dim hdcMono
  244. Dim bmpMono
  245. Dim bmpMonoTemp
  246. Const stdW = 32
  247. Const stdH = 32
  248. Dim mresult
  249. Private Sub Form_Load()
  250.      ' Create monochrome hDC and bitmap
  251.     hdcMono = CreateCompatibleDC(hdc)
  252.     bmpMono = CreateCompatibleBitmap(hdcMono, stdW, stdH)
  253.     bmpMonoTemp = SelectObject(hdcMono, bmpMono)
  254.     With iGuid
  255.          .Data1 = &H20400
  256.          .Data4(0) = &HC0
  257.          .Data4(7) = &H46
  258.     End With
  259.       ' Just to make sure
  260.     picImage.AutoRedraw = True
  261.     picMask.AutoRedraw = True
  262. End Sub
  263. Private Sub command1_click()
  264.     On Error Resume Next
  265.     picImage.Picture = LoadPicture()
  266.     picMask.Picture = LoadPicture()
  267.     Picture2.Picture = LoadPicture()
  268.     '------------------------------------------------
  269.     ' As the main aim of this program is for learning,
  270.     ' variations are advanced for your own study.
  271.     '------------------------------------------------
  272.     '-------------------
  273.     ' Alternative 1
  274.     ' For general use
  275.     '-------------------
  276.     command1_Alternative
  277.     Exit Sub
  278.     '-------------------
  279.     ' Alternative 2
  280.     ' If you have a known use at a particular place
  281.     '-------------------
  282.         ' Let us select a background color here (just a matter of choice
  283.         ' e.g. form1.backcolor, vbGray, so that the transparent part will
  284.         ' blend in the surrounding backcolor when loaded)
  285. '    picImage.BackColor = Picture1.BackColor
  286.         ' Area having the following color is to be left out as it is meant
  287.         ' to be transparent
  288. '    Dim mtransp As Long
  289. '    mtransp = Picture1.Point(0, 0)
  290.         ' Create transparent part
  291. '    CreateTransparent Picture1, picImage, mtransp
  292.         ' Make sure no Autoredraw for picMask with this alternative
  293. '    picMask.AutoRedraw = False
  294.         ' Create a mask
  295. '    CreateMask_viaMemoryDC picImage, picMask
  296. '    mresult = BitBlt(Picture2.hdc, 0, 0, stdW, stdH, picMask.hdc, 0, 0, vbSrcAnd)
  297. '    mresult = BitBlt(Picture2.hdc, 0, 0, stdW, stdH, picImage.hdc, 0, 0, vbSrcInvert)
  298. '    BuildIcon Picture2
  299. '    SavePicture Picture2.Picture, App.Path & "/Frombmp.ico"
  300. End Sub
  301. Private Sub command1_Alternative()
  302.     picImage.Line (0, 0)-(stdW - 1, stdH - 1), vbBlack, BF
  303.     picMask.Line (0, 0)-(stdW - 1, stdH - 1), vbWhite, BF
  304.     Dim mtransp As Long
  305.       ' Area having the following color is to be left out
  306.       ' as it is meant to be transparent
  307.     mtransp = Picture1.Point(0, 0)
  308.     Dim i, j
  309.     For i = 0 To stdW - 1
  310.         For j = 0 To stdH - 1
  311.             If Picture1.Point(i, j) <> mtransp Then
  312.                  picImage.PSet (i, j), Picture1.Point(i, j)
  313.                  picMask.PSet (i, j)
  314.             End If
  315.         Next j
  316.     Next i
  317.     BuildIcon Picture2
  318.     SavePicture Picture2.Picture, App.Path & "/Frombmp.ico"
  319. End Sub
  320. Private Sub command2_Click()
  321.     On Error Resume Next
  322.     Dim i, j
  323.     Dim p, q
  324.     Picture4.Picture = Picture3.Image
  325. '--------------------------------------------------------
  326. 'NB This following is only a matter of variation, not a must.
  327. '   Let us select the form's color as background color here
  328. '   and replace the existing one with it.
  329. '--------------------------------------------------------
  330.     p = Picture4.Point(0, 0)
  331.     q = Me.BackColor
  332.       ' Paint the desired color as if backgound
  333.     For i = 0 To stdW
  334.          For j = 0 To stdH
  335.               If Picture4.Point(i, j) = p Then
  336.                    Picture4.PSet (i, j), q
  337.               End If
  338.          Next j
  339.     Next i
  340. '--------------------------------------------------------
  341. '  Alternatively
  342. '  To open the following, close above and uncomment API first
  343. '--------------------------------------------------------
  344. '    Picture4.FillColor = q
  345. '    Picture4.FillStyle = vbFSSolid
  346. '    mresult = ExtFloodFill(Picture4.hdc, 0, 0, p, 1)
  347. '       'Another line is required only because the fill area
  348. '       'is broken by the tip point of the flap of envelope.
  349. '    mresult = ExtFloodFill(Picture4.hdc, stdW - 1, stdH - 1, p, 1)
  350. '--------------------------------------------------------
  351.     SavePicture Picture4.Picture, App.Path & "/Fromico.bmp"
  352. End Sub
  353. ' To let you see it again and again.
  354. Private Sub Command3_Click()
  355.     Picture2.Picture = LoadPicture()
  356. End Sub
  357. Private Sub Command4_Click()
  358.     Picture4.Picture = LoadPicture()
  359. End Sub
  360. Private Function CreateMask_viaMemoryDC(Pic1 As PictureBox, Pic2 As PictureBox) As Boolean
  361.      On Error GoTo errHandler
  362.      CreateMask_viaMemoryDC = False
  363.      
  364.      Dim dx As Long, dy As Long
  365.      Dim hdcMono2 As Long, bmpMono2 As Long, bmpMonoTemp2 As Long
  366.      
  367.      dx = Pic1.ScaleWidth
  368.      dy = Pic1.ScaleHeight
  369.      
  370.       ' Create memory device context (0 is screen, as we want the new
  371.       ' DC compatible with the screen).
  372.      hdcMono2 = CreateCompatibleDC(0)
  373.      If hdcMono2 = 0 Then
  374.          GoTo errHandler
  375.      End If
  376.       ' Create monochrome bitmap, of a wanted size
  377.      bmpMono2 = CreateCompatibleBitmap(hdcMono2, dx, dy)
  378.       ' Get a monohrome bitmap by default after putting in the
  379.       ' above created bitmap into the DC.
  380.      bmpMonoTemp2 = SelectObject(hdcMono2, bmpMono2)
  381.       ' Copy bitmap of Pic1 to memory DC to create mono mask of the color bitmap.
  382.      mresult = BitBlt(hdcMono2, 0, 0, dx, dy, Pic1.hdc, 0, 0, vbSrcCopy)
  383.       ' Copy mono memory mask to a picture box, as wanted in this case
  384.      mresult = BitBlt(Pic2.hdc, 0, 0, dx, dy, hdcMono2, 0, 0, vbSrcCopy)
  385.      
  386.       ' Clean up
  387.      Call SelectObject(hdcMono2, bmpMonoTemp2)
  388.      Call DeleteDC(hdcMono2)
  389.      Call DeleteObject(bmpMono2)
  390.      
  391.      CreateMask_viaMemoryDC = True
  392.      Exit Function
  393. errHandler:
  394.      MsgBox "MakeMask_viaMemoryDC"
  395. End Function
  396. Private Sub ExtractIconComposite(inPic As PictureBox)
  397.     On Error Resume Next
  398.     Dim ipic As IPicture
  399.     Dim icoinfo As ICONINFO
  400.     Dim pDesc As pictDesc
  401.     Dim hDCWork
  402.     Dim hBMOldWork
  403.     Dim hNewBM
  404.     Dim hBMOldMono
  405.     GetIconInfo inPic.Picture, icoinfo
  406.     hDCWork = CreateCompatibleDC(0)
  407.     hNewBM = CreateCompatibleBitmap(inPic.hdc, stdW, stdH)
  408.     hBMOldWork = SelectObject(hDCWork, hNewBM)
  409.     hBMOldMono = SelectObject(hdcMono, icoinfo.hBMMask)
  410.     BitBlt hDCWork, 0, 0, stdW, stdH, hdcMono, 0, 0, vbSrcCopy
  411.     SelectObject hdcMono, hBMOldMono
  412.     SelectObject hDCWork, hBMOldWork
  413.     With pDesc
  414.         .cbSizeofStruct = Len(pDesc)
  415.         .picType = PICTYPE_BITMAP
  416.         .hImage = hNewBM
  417.     End With
  418.     OleCreatePictureIndirect pDesc, iGuid, 1, ipic
  419.     picMask = ipic
  420.     Set ipic = Nothing
  421.     pDesc.hImage = icoinfo.hBMColor
  422.       ' Third parameter set to 1 (true) to let picture be destroyed automatically
  423.     OleCreatePictureIndirect pDesc, iGuid, 1, ipic
  424.     picImage = ipic
  425.     DeleteObject icoinfo.hBMMask
  426.     DeleteDC hDCWork
  427.     Set hBMOldWork = Nothing
  428.     Set hBMOldMono = Nothing
  429. End Sub
  430. Private Sub BuildIcon(inPic As PictureBox)
  431.     On Error Resume Next
  432.     Dim hOldMonoBM
  433.     Dim hDCWork
  434.     Dim hBMOldWork
  435.     Dim hBMWork
  436.     Dim ipic As IPicture
  437.     Dim pDesc As pictDesc
  438.     Dim icoinfo As ICONINFO
  439.     BitBlt hdcMono, 0, 0, stdW, stdH, picMask.hdc, 0, 0, vbSrcCopy
  440.     SelectObject hdcMono, bmpMonoTemp
  441.     hDCWork = CreateCompatibleDC(0)
  442.     With inPic
  443.         hBMWork = CreateCompatibleBitmap(inPic.hdc, stdW, stdH)
  444.     End With
  445.     hBMOldWork = SelectObject(hDCWork, hBMWork)
  446.     BitBlt hDCWork, 0, 0, stdW, stdH, picImage.hdc, 0, 0, vbSrcCopy
  447.     SelectObject hDCWork, hBMOldWork
  448.     With icoinfo
  449.         .fIcon = 1
  450.         .xHotspot = 16            ' Doesn't matter here
  451.         .yHotspot = 16
  452.         .hBMMask = bmpMono
  453.         .hBMColor = hBMWork
  454.     End With
  455.     With pDesc
  456.         .cbSizeofStruct = Len(pDesc)
  457.         .picType = PICTYPE_ICON
  458.         .hImage = CreateIconIndirect(icoinfo)
  459.     End With
  460.     OleCreatePictureIndirect pDesc, iGuid, 1, ipic
  461.     inPic.Picture = LoadPicture()
  462.     inPic = ipic
  463.     bmpMonoTemp = SelectObject(hdcMono, bmpMono)
  464.     DeleteObject icoinfo.hBMMask
  465.     DeleteDC hDCWork
  466.     Set hBMOldWork = Nothing
  467. End Sub
  468. Sub CreateTransparent(inpicSrc As PictureBox, inpicDest As PictureBox, _
  469.           inTrasparentColor As Long)
  470.     On Error Resume Next
  471.     Dim mMaskDC As Long
  472.     Dim mMaskBmp As Long
  473.     Dim mTempMaskBMP As Long
  474.     Dim mMonoBMP As Long
  475.     Dim mMonoDC As Long
  476.     Dim mTempMonoBMP As Long
  477.     Dim mSrcHDC As Long, mDestHDC As Long
  478.     Dim w As Long, h As Long
  479.     w = inpicSrc.ScaleWidth
  480.     h = inpicSrc.ScaleHeight
  481.     mSrcHDC = inpicSrc.hdc
  482.     mDestHDC = inpicDest.hdc
  483.      ' Set back color of source pic and dest pic to the desired transparent color
  484.     mresult = SetBkColor&(mSrcHDC, inTrasparentColor)
  485.     mresult = SetBkColor&(mDestHDC, inTrasparentColor)
  486.     ' Create a mask DC compatible with dest image
  487.     mMaskDC = CreateCompatibleDC(mDestHDC)
  488.     ' and a bitmap of its size
  489.     mMaskBmp = CreateCompatibleBitmap(mDestHDC, w, h)
  490.     ' Move that bitmap into mMaskDC
  491.     mTempMaskBMP = SelectObject(mMaskDC, mMaskBmp)
  492.     ' Meanwhile create another DC for mono bitmap
  493.     mMonoDC = CreateCompatibleDC(mDestHDC)
  494.     '  and its bitmap, a mono one (by setting nPlanes and nbitcount
  495.     '  both to 1)
  496.     mMonoBMP = CreateBitmap(w, h, 1, 1, 0)
  497.     mTempMonoBMP = SelectObject(mMonoDC, mMonoBMP)
  498.     ' Copy source image to mMonoDC
  499.     mresult = BitBlt(mMonoDC, 0, 0, w, h, mSrcHDC, 0, 0, vbSrcCopy)
  500.         
  501.     ' Copy mMonoDC into mMaskDC
  502.     mresult = BitBlt(mMaskDC, 0, 0, w, h, mMonoDC, 0, 0, vbSrcCopy)
  503.     'We don't need mMonoBMP any longer
  504.     mMonoBMP = SelectObject(mMonoDC, mTempMonoBMP)
  505.     mresult = DeleteObject(mMonoBMP)
  506.     mresult = DeleteDC(mMonoDC)
  507.     'Now copy source image to dest image with XOR
  508.     mresult = BitBlt(mDestHDC, 0, 0, w, h, mSrcHDC, 0, 0, vbSrcInvert)
  509.     'Copy the mMaskDC to dest image with AND
  510.     mresult = BitBlt(mDestHDC, 0, 0, w, h, mMaskDC, 0, 0, vbSrcAnd)
  511.     'Copy source image to dest image with XOR
  512.     BitBlt mDestHDC, 0, 0, w, h, mSrcHDC, 0, 0, vbSrcInvert
  513.     'Picture is there to stay
  514.     inpicDest.Picture = inpicDest.Image
  515.      
  516.     ' We don't need these
  517.     mMaskBmp = SelectObject(mMaskDC, mTempMaskBMP)
  518.     mresult = DeleteObject(mMaskBmp)
  519.     mresult = DeleteDC(mMaskDC)
  520. End Sub
  521. ' Last clear up
  522. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  523.     SelectObject bmpMono, bmpMonoTemp
  524.     DeleteObject bmpMono
  525.     DeleteDC hdcMono
  526. End Sub
  527.