home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples5 / ch08 / analyze.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  7.9 KB  |  194 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmAnalyze 
  4.    Caption         =   "Analyze Metafile"
  5.    ClientHeight    =   3180
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1515
  8.    ClientWidth     =   5160
  9.    LinkTopic       =   "Form1"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   3180
  12.    ScaleWidth      =   5160
  13.    Begin VB.CheckBox chkSingle 
  14.       Caption         =   "Single Step"
  15.       Height          =   255
  16.       Left            =   3660
  17.       TabIndex        =   3
  18.       Top             =   2220
  19.       Width           =   1395
  20.    End
  21.    Begin VB.PictureBox Picture1 
  22.       Height          =   1275
  23.       Left            =   3660
  24.       ScaleHeight     =   83
  25.       ScaleMode       =   3  'Pixel
  26.       ScaleWidth      =   91
  27.       TabIndex        =   2
  28.       Top             =   840
  29.       Width           =   1395
  30.    End
  31.    Begin VB.CommandButton cmdAnalyze 
  32.       Caption         =   "Analyze"
  33.       Height          =   495
  34.       Left            =   3660
  35.       TabIndex        =   1
  36.       Top             =   180
  37.       Width           =   1395
  38.    End
  39.    Begin VB.ListBox List1 
  40.       Height          =   2760
  41.       Left            =   120
  42.       TabIndex        =   0
  43.       Top             =   120
  44.       Width           =   3375
  45.    End
  46.    Begin MSComDlg.CommonDialog CMDialogMF 
  47.       Left            =   3660
  48.       Top             =   2580
  49.       _ExtentX        =   847
  50.       _ExtentY        =   847
  51.       _Version        =   327680
  52.       Filter          =   "Metafiles (*.wmf)|*.wmf"
  53.       Flags           =   4100
  54.       FontSize        =   2.54016e-29
  55.    End
  56. Attribute VB_Name = "frmAnalyze"
  57. Attribute VB_GlobalNameSpace = False
  58. Attribute VB_Creatable = False
  59. Attribute VB_PredeclaredId = True
  60. Attribute VB_Exposed = False
  61. ' Analyze.vbp
  62. ' Copyright (c) 1995-1997 by Desaware Inc. All Rights Reserved
  63. Option Explicit
  64. ' Set by frmPrompt to include or discard a record
  65. Public IncludeRecord%
  66. Private Sub cmdAnalyze_Click()
  67.     Dim usefile$
  68.     #If Win32 Then
  69.         Dim saved&
  70.         Dim dc&
  71.         Dim usemf&
  72.         Dim di&, dl&
  73.     #Else
  74.         Dim saved%
  75.         Dim dc%
  76.         Dim usemf%
  77.         Dim di%, dl&
  78.     #End If
  79.     Dim oldsize As SIZE
  80.     IncludeRecord = True    ' Initialize value
  81.     List1.Clear             ' Clear list box
  82.     CMDialogMF.DialogTitle = "Load a metafile"
  83.     CMDialogMF.Action = 1
  84.     usefile$ = CMDialogMF.FileName
  85.     If usefile$ <> "" Then
  86.         usemf = LoadTheMetafile(usefile$)
  87.         If usemf <> 0 Then
  88.                 ' Now draw the metafile
  89.             Picture1.Cls
  90.             dc = Picture1.hDC
  91.             saved = SaveDC(dc)
  92.             ' Now set the new coordinate system. See the CmdExecute()_Click
  93.             ' command for further explanation
  94.             ' Most metafiles will set their own extents, but we need
  95.             ' to set the viewport to match the scalemode of the
  96.             ' entire screen to fill the window
  97.             di = SetMapMode(dc, MM_ANISOTROPIC)
  98.             dl = SetViewportExtEx(dc, Picture1.ScaleWidth, Picture1.ScaleHeight, oldsize)
  99.             ' All of the drawing objects that were used on the original
  100.             ' objects were saved with the metafile, thus the metafile
  101.             ' will automatically draw each object in the correct color
  102.             ' and style.
  103.             di = EnumMetaFile(dc, usemf, AddressOf Callback1_EnumMetaFile, 0)
  104.             ' di = PlayMetaFile(dc, usemf)
  105.             ' And restore the original DC state
  106.             di = RestoreDC(dc, saved)
  107.             di = DeleteMetaFile(usemf)
  108.         End If
  109.     End If
  110. End Sub
  111. Public Function GetFunctionName$(fnum As Integer)
  112.     Select Case fnum
  113.         Case &H817: GetFunctionName = "Arc"
  114.         Case &H830: GetFunctionName = "Chord"
  115.         Case &H418: GetFunctionName = "Ellipse"
  116.         Case &H415: GetFunctionName = "ExcludeClipRect"
  117.         Case &H419: GetFunctionName = "FloodFill"
  118.         Case &H416: GetFunctionName = "IntersectClipRect"
  119.         Case &H213: GetFunctionName = "LineTo"
  120.         Case &H214: GetFunctionName = "MoveTo"
  121.         Case &H220: GetFunctionName = "OffsetClipRgn"
  122.         Case &H211: GetFunctionName = "OffsetViewportOrg"
  123.         Case &H20F: GetFunctionName = "OffsetWindowOrg"
  124.         Case &H211: GetFunctionName = "OffsetViewportOrg"
  125.         Case &H61D: GetFunctionName = "PatBlt"
  126.         Case &H81A: GetFunctionName = "Pie"
  127.         Case &H35: GetFunctionName = "RealizePalette"
  128.         Case &H41B: GetFunctionName = "Rectangle"
  129.         Case &H139: GetFunctionName = "ResizePalette"
  130.         Case &H127: GetFunctionName = "RestoreDC"
  131.         Case &H61C: GetFunctionName = "RoundRect"
  132.         Case &H1E: GetFunctionName = "SaveDC"
  133.         Case &H412: GetFunctionName = "ScaleViewportExt"
  134.         Case &H400: GetFunctionName = "ScaleWindowExt"
  135.         Case &H61C: GetFunctionName = "RoundRect"
  136.         Case &H201: GetFunctionName = "SetBkColor"
  137.         Case &H102: GetFunctionName = "SetBkMode"
  138.         Case &H103: GetFunctionName = "SetMapMode"
  139.         Case &H231: GetFunctionName = "SetMapperFlags"
  140.         Case &H41F: GetFunctionName = "SetPixel"
  141.         Case &H106: GetFunctionName = "SetPolyFillMode"
  142.         Case &H104: GetFunctionName = "SetROP2"
  143.         Case &H107: GetFunctionName = "SetStretchBltMode"
  144.         Case &H12E: GetFunctionName = "SetTextAlign"
  145.         Case &H108: GetFunctionName = "SetTextCharExtra"
  146.         Case &H209: GetFunctionName = "SetTextColor"
  147.         Case &H20A: GetFunctionName = "SetTextJustification"
  148.         Case &H20E: GetFunctionName = "SetViewportExt"
  149.         Case &H20D: GetFunctionName = "SetViewportOrg"
  150.         Case &H20C: GetFunctionName = "SetWindowExt"
  151.         Case &H20B: GetFunctionName = "SetWindowOrg"
  152.         Case &H2FC: GetFunctionName = "CreateBrushIndirect"
  153.         Case &H2FB: GetFunctionName = "CreateFontIndirect"
  154.         Case &HF7: GetFunctionName = "CreatePalette"
  155.         Case &H922: GetFunctionName = "BitBlt (DDB)"
  156.         Case &H940: GetFunctionName = "BitBlt (DIB)"
  157.         Case &H1F9: GetFunctionName = "CreateBrushIndirect (DDB)"
  158.         Case &H142: GetFunctionName = "CreateBrushIndirect (DIB)"
  159.         Case &H2FA: GetFunctionName = "CreatePenIndirect"
  160.         Case &H6FF: GetFunctionName = "CreateRegion"
  161.         Case &H1F0: GetFunctionName = "DeleteObject"
  162.         Case &H626: GetFunctionName = "Escape"
  163.         Case &HA32: GetFunctionName = "ExtTextOut"
  164.         Case &H324: GetFunctionName = "Polygon"
  165.         Case &H538: GetFunctionName = "PolyPolygon"
  166.         Case &H325: GetFunctionName = "Polyline"
  167.         Case &H12C: GetFunctionName = "SelectClipRgn"
  168.         Case &H12D: GetFunctionName = "SelectObject"
  169.         Case &H234: GetFunctionName = "SelectPalette"
  170.         Case &HD33: GetFunctionName = "SetDIBitsToDevice"
  171.         Case &H37: GetFunctionName = "SetPaletteEntries"
  172.         Case &HB23: GetFunctionName = "StretchBlt (DDB)"
  173.         Case &HB41: GetFunctionName = "StretchBlt (DIB)"
  174.         Case &HF43: GetFunctionName = "StretchDIBits"
  175.         Case &H521: GetFunctionName = "TextOut"
  176.     End Select
  177. End Function
  178. Public Function GetObjDescription$(objnum)
  179.     Select Case objnum
  180.         Case OBJ_PEN:   GetObjDescription$ = "Pen"
  181.         Case OBJ_BRUSH:   GetObjDescription$ = "Brush"
  182.         Case OBJ_DC:   GetObjDescription$ = "Device Context"
  183.         Case OBJ_METADC:   GetObjDescription$ = "Metafile Device Context"
  184.         Case OBJ_PAL:   GetObjDescription$ = "Palette"
  185.         Case OBJ_FONT:   GetObjDescription$ = "Font"
  186.         Case OBJ_BITMAP:   GetObjDescription$ = "Bitmap"
  187.         Case OBJ_REGION:   GetObjDescription$ = "Region"
  188.         Case OBJ_METAFILE:   GetObjDescription$ = "Metafile"
  189.         Case OBJ_MEMDC:   GetObjDescription$ = "Memory device context"
  190.         Case OBJ_EXTPEN:   GetObjDescription$ = "Extended Pen"
  191.         Case OBJ_ENHMETAFILE:   GetObjDescription$ = "Enhanced metafile"
  192.     End Select
  193. End Function
  194.