home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmAnalyze
- Caption = "Analyze Metafile"
- ClientHeight = 3180
- ClientLeft = 1095
- ClientTop = 1515
- ClientWidth = 5160
- Height = 3585
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 3180
- ScaleWidth = 5160
- Top = 1170
- Width = 5280
- Begin VB.CheckBox chkSingle
- Caption = "Single Step"
- Height = 255
- Left = 3660
- TabIndex = 3
- Top = 2220
- Width = 1395
- End
- Begin VB.PictureBox Picture1
- Height = 1275
- Left = 3660
- ScaleHeight = 83
- ScaleMode = 3 'Pixel
- ScaleWidth = 91
- TabIndex = 2
- Top = 840
- Width = 1395
- End
- Begin VB.CommandButton cmdAnalyze
- Caption = "Analyze"
- Height = 495
- Left = 3660
- TabIndex = 1
- Top = 180
- Width = 1395
- End
- Begin VB.ListBox List1
- Height = 2955
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 3375
- End
- Begin Cbkd.Callback Callback1
- Left = 4440
- Top = 2580
- _Version = 262144
- _ExtentX = 847
- _ExtentY = 847
- _StockProps = 0
- Type = 3
- End
- Begin MSComDlg.CommonDialog CMDialogMF
- Left = 3660
- Top = 2580
- _ExtentX = 847
- _ExtentY = 847
- _Version = 327680
- Filter = """Metafiles (*.wmf)|*.wmf"""
- Flags = 4100
- End
- Attribute VB_Name = "frmAnalyze"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- ' Copyright
- 1997 by Desaware Inc. All Rights Reserved
- ' Set by frmPrompt to include or discard a record
- Public IncludeRecord%
- Dim Objlist() As Long
- Private Sub Callback1_EnumMetaFile(hDC As Long, lpHTable As Long, lpMFR As Long, nObj As Long, lpClientData As Long, retval As Long)
- Dim di&
- Dim f$, od$
- Dim x%
- Dim foundone%
- ReDim Objlist(nObj)
- Dim mr As METARECORD
- agCopyData ByVal lpMFR, mr, Len(mr)
- f$ = GetFunctionName(mr.rdFunction)
- If chkSingle.value Then
- frmPrompt.lblFunc.Caption = f$
- frmPrompt.Show 1
- End If
- If IncludeRecord Then
- di& = PlayMetaFileRecord(hDC, ByVal lpHTable, ByVal lpMFR, ByVal nObj)
- List1.AddItem f$
- If nObj > 0 Then
- agCopyData ByVal lpHTable, Objlist(0), nObj * 4
- For x% = 0 To nObj
- od$ = GetObjDescription(GetObjectType(Objlist(x)))
- If od$ <> "" Then
- If Not foundone% Then List1.AddItem "-- Objects in table"
- foundone% = True
- List1.AddItem " " & od$
- End If
- Next x%
- End If
- End If
- retval = True
- End Sub
- Private Sub cmdAnalyze_Click()
- Dim usefile$
- #If Win32 Then
- Dim saved&
- Dim dc&
- Dim usemf&
- Dim di&, dl&
- #Else
- Dim saved%
- Dim dc%
- Dim usemf%
- Dim di%, dl&
- #End If
- Dim oldsize As SIZE
- IncludeRecord = True ' Initialize value
- List1.Clear ' Clear list box
- CMDialogMF.DialogTitle = "Load a metafile"
- CMDialogMF.Action = 1
- usefile$ = CMDialogMF.FileName
- If usefile$ <> "" Then
- usemf = LoadTheMetafile(usefile$)
- If usemf <> 0 Then
- ' Now draw the metafile
- picture1.Cls
- dc = picture1.hDC
- saved = SaveDC(dc)
- ' Now set the new coordinate system. See the CmdExecute()_Click
- ' command for further explanation
- ' Most metafiles will set their own extents, but we need
- ' to set the viewport to match the scalemode of the
- ' entire screen to fill the window
- di = SetMapMode(dc, MM_ANISOTROPIC)
- dl = SetViewportExtEx(dc, picture1.ScaleWidth, picture1.ScaleHeight, oldsize)
- ' All of the drawing objects that were used on the original
- ' objects were saved with the metafile, thus the metafile
- ' will automatically draw each object in the correct color
- ' and style.
- di = EnumMetaFile(dc, usemf, Callback1.ProcAddress, 0)
- ' di = PlayMetaFile(dc, usemf)
- ' And restore the original DC state
- di = RestoreDC(dc, saved)
- di = DeleteMetaFile(usemf)
- End If
- End If
- End Sub
- Public Function GetFunctionName$(fnum As Integer)
- Select Case fnum
- Case &H817: GetFunctionName = "Arc"
- Case &H830: GetFunctionName = "Chord"
- Case &H418: GetFunctionName = "Ellipse"
- Case &H415: GetFunctionName = "ExcludeClipRect"
- Case &H419: GetFunctionName = "FloodFill"
- Case &H416: GetFunctionName = "IntersectClipRect"
- Case &H213: GetFunctionName = "LineTo"
- Case &H214: GetFunctionName = "MoveTo"
- Case &H220: GetFunctionName = "OffsetClipRgn"
- Case &H211: GetFunctionName = "OffsetViewportOrg"
- Case &H20F: GetFunctionName = "OffsetWindowOrg"
- Case &H211: GetFunctionName = "OffsetViewportOrg"
- Case &H61D: GetFunctionName = "PatBlt"
- Case &H81A: GetFunctionName = "Pie"
- Case &H35: GetFunctionName = "RealizePalette"
- Case &H41B: GetFunctionName = "Rectangle"
- Case &H139: GetFunctionName = "ResizePalette"
- Case &H127: GetFunctionName = "RestoreDC"
- Case &H61C: GetFunctionName = "RoundRect"
- Case &H1E: GetFunctionName = "SaveDC"
- Case &H412: GetFunctionName = "ScaleViewportExt"
- Case &H400: GetFunctionName = "ScaleWindowExt"
- Case &H61C: GetFunctionName = "RoundRect"
- Case &H201: GetFunctionName = "SetBkColor"
- Case &H102: GetFunctionName = "SetBkMode"
- Case &H103: GetFunctionName = "SetMapMode"
- Case &H231: GetFunctionName = "SetMapperFlags"
- Case &H41F: GetFunctionName = "SetPixel"
- Case &H106: GetFunctionName = "SetPolyFillMode"
- Case &H104: GetFunctionName = "SetROP2"
- Case &H107: GetFunctionName = "SetStretchBltMode"
- Case &H12E: GetFunctionName = "SetTextAlign"
- Case &H108: GetFunctionName = "SetTextCharExtra"
- Case &H209: GetFunctionName = "SetTextColor"
- Case &H20A: GetFunctionName = "SetTextJustification"
- Case &H20E: GetFunctionName = "SetViewportExt"
- Case &H20D: GetFunctionName = "SetViewportOrg"
- Case &H20C: GetFunctionName = "SetWindowExt"
- Case &H20B: GetFunctionName = "SetWindowOrg"
- Case &H2FC: GetFunctionName = "CreateBrushIndirect"
- Case &H2FB: GetFunctionName = "CreateFontIndirect"
- Case &HF7: GetFunctionName = "CreatePalette"
- Case &H922: GetFunctionName = "BitBlt (DDB)"
- Case &H940: GetFunctionName = "BitBlt (DIB)"
- Case &H1F9: GetFunctionName = "CreateBrushIndirect (DDB)"
- Case &H142: GetFunctionName = "CreateBrushIndirect (DIB)"
- Case &H2FA: GetFunctionName = "CreatePenIndirect"
- Case &H6FF: GetFunctionName = "CreateRegion"
- Case &H1F0: GetFunctionName = "DeleteObject"
- Case &H626: GetFunctionName = "Escape"
- Case &HA32: GetFunctionName = "ExtTextOut"
- Case &H324: GetFunctionName = "Polygon"
- Case &H538: GetFunctionName = "PolyPolygon"
- Case &H325: GetFunctionName = "Polyline"
- Case &H12C: GetFunctionName = "SelectClipRgn"
- Case &H12D: GetFunctionName = "SelectObject"
- Case &H234: GetFunctionName = "SelectPalette"
- Case &HD33: GetFunctionName = "SetDIBitsToDevice"
- Case &H37: GetFunctionName = "SetPaletteEntries"
- Case &HB23: GetFunctionName = "StretchBlt (DDB)"
- Case &HB41: GetFunctionName = "StretchBlt (DIB)"
- Case &HF43: GetFunctionName = "StretchDIBits"
- Case &H521: GetFunctionName = "TextOut"
- End Select
- End Function
- Public Function GetObjDescription$(objnum)
- Select Case objnum
- Case OBJ_PEN: GetObjDescription$ = "Pen"
- Case OBJ_BRUSH: GetObjDescription$ = "Brush"
- Case OBJ_DC: GetObjDescription$ = "Device Context"
- Case OBJ_METADC: GetObjDescription$ = "Metafile Device Context"
- Case OBJ_PAL: GetObjDescription$ = "Palette"
- Case OBJ_FONT: GetObjDescription$ = "Font"
- Case OBJ_BITMAP: GetObjDescription$ = "Bitmap"
- Case OBJ_REGION: GetObjDescription$ = "Region"
- Case OBJ_METAFILE: GetObjDescription$ = "Metafile"
- Case OBJ_MEMDC: GetObjDescription$ = "Memory device context"
- Case OBJ_EXTPEN: GetObjDescription$ = "Extended Pen"
- Case OBJ_ENHMETAFILE: GetObjDescription$ = "Enhanced metafile"
- End Select
- End Function
-