home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / Main.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-06-26  |  11.9 KB  |  376 lines

  1. VERSION 5.00
  2. Object = "{00100063-B1BA-11CE-ABC6-F5B2E79D9E3F}#1.0#0"; "LTDLG10N.OCX"
  3. Begin VB.MDIForm Main 
  4.    Appearance      =   0  'Flat
  5.    BackColor       =   &H8000000C&
  6.    Caption         =   "LEAD Visual Basic Drawing Demo Program"
  7.    ClientHeight    =   2595
  8.    ClientLeft      =   2280
  9.    ClientTop       =   2280
  10.    ClientWidth     =   7785
  11.    Icon            =   "Main.frx":0000
  12.    LinkTopic       =   "MDIForm1"
  13.    Begin LEADDlgLibCtl.LEADDlg LEADDlg1 
  14.       Left            =   600
  15.       Top             =   480
  16.       Angle           =   0
  17.       AngleFlag       =   -1  'True
  18.       NewWidth        =   0
  19.       NewHeight       =   0
  20.       MaxFileSize     =   0
  21.       LoadCompressed  =   -1  'True
  22.       LoadRotated     =   -1  'True
  23.       Change          =   0
  24.       SaveMulti       =   0
  25.       PageNumber      =   1
  26.       Effect          =   2000
  27.       Grain           =   5
  28.       Delay           =   20
  29.       MaxPass         =   1
  30.       Transparent     =   0   'False
  31.       WandWidth       =   2
  32.       GradientStyle   =   1000
  33.       GradientSteps   =   256
  34.       Transition      =   1000
  35.       Shape           =   1000
  36.       ShapeBackStyle  =   1
  37.       ShapeFillStyle  =   0
  38.       ShapeBorderStyle=   1
  39.       ShapeBorderWidth=   1
  40.       ShapeInnerStyle =   0
  41.       ShapeInnerWidth =   0
  42.       ShapeOuterStyle =   0
  43.       ShapeOuterWidth =   0
  44.       ShadowXDepth    =   5
  45.       ShadowYDepth    =   5
  46.       SampleText      =   "LEADTOOLS!"
  47.       TextStyle       =   1
  48.       TextAlign       =   4
  49.       TextWordWrap    =   -1  'True
  50.       TextUseForegroundImage=   0   'False
  51.       FileDlgFlags    =   0
  52.       FileDialogTitle =   "LEADTOOLS Common Dialog"
  53.       FileName        =   ""
  54.       Filter          =   $"Main.frx":030A
  55.       FilterIndex     =   0
  56.       InitialDir      =   ""
  57.       UIFlags         =   0
  58.       ShowHelpButton  =   0   'False
  59.       PreviewEnabled  =   -1  'True
  60.       EnableMethodErrors=   -1  'True
  61.       LowBit          =   1
  62.       HighBit         =   11
  63.       LowValue        =   0
  64.       HighValue       =   0
  65.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  66.          Name            =   "Times New Roman"
  67.          Size            =   12
  68.          Charset         =   0
  69.          Weight          =   400
  70.          Underline       =   0   'False
  71.          Italic          =   0   'False
  72.          Strikethrough   =   0   'False
  73.       EndProperty
  74.       BackColor       =   255
  75.       ForeColor       =   16711680
  76.       StartColor      =   255
  77.       EndColor        =   16711680
  78.       TransparentColor=   0
  79.       WandColor       =   255
  80.       ShapeBorderColor=   0
  81.       ShapeInnerHiliteColor=   16777215
  82.       ShapeInnerShadowColor=   0
  83.       ShapeOuterHiliteColor=   16777215
  84.       ShapeOuterShadowColor=   0
  85.       ShadowColor     =   0
  86.       TextColor       =   16711680
  87.       TextHiliteColor =   16777215
  88.    End
  89.    Begin VB.Menu MenuFile 
  90.       Caption         =   "&File"
  91.       Begin VB.Menu OpenFile 
  92.          Caption         =   "&Open..."
  93.          Index           =   1
  94.       End
  95.       Begin VB.Menu SaveFile 
  96.          Caption         =   "&Save..."
  97.          Index           =   2
  98.       End
  99.       Begin VB.Menu s0 
  100.          Caption         =   "-"
  101.       End
  102.       Begin VB.Menu Exit 
  103.          Caption         =   "E&xit"
  104.          Index           =   3
  105.       End
  106.       Begin VB.Menu s1 
  107.          Caption         =   "-"
  108.       End
  109.       Begin VB.Menu About 
  110.          Caption         =   "&About"
  111.          Index           =   4
  112.       End
  113.    End
  114.    Begin VB.Menu MenuObject 
  115.       Caption         =   "&Object"
  116.       Begin VB.Menu ObjectSelect 
  117.          Caption         =   "&Ellipse"
  118.          Index           =   0
  119.       End
  120.       Begin VB.Menu ObjectSelect 
  121.          Caption         =   "&Line"
  122.          Index           =   1
  123.       End
  124.       Begin VB.Menu ObjectSelect 
  125.          Caption         =   "&Rectangle"
  126.          Index           =   2
  127.       End
  128.    End
  129.    Begin VB.Menu MenuColor 
  130.       Caption         =   "&Color"
  131.       Begin VB.Menu ColorSelect 
  132.          Caption         =   "&Black"
  133.          Index           =   0
  134.       End
  135.       Begin VB.Menu ColorSelect 
  136.          Caption         =   "B&lue"
  137.          Index           =   1
  138.       End
  139.       Begin VB.Menu ColorSelect 
  140.          Caption         =   "&Green"
  141.          Index           =   2
  142.       End
  143.       Begin VB.Menu ColorSelect 
  144.          Caption         =   "&Red"
  145.          Index           =   3
  146.       End
  147.       Begin VB.Menu ColorSelect 
  148.          Caption         =   "&White"
  149.          Index           =   4
  150.       End
  151.    End
  152.    Begin VB.Menu MenuThickness 
  153.       Caption         =   "&Thickness..."
  154.    End
  155.    Begin VB.Menu MenuDraw 
  156.       Caption         =   "&Action"
  157.       Begin VB.Menu EnableSelect 
  158.          Caption         =   "&Disable Action"
  159.          Index           =   0
  160.       End
  161.       Begin VB.Menu EnableSelect 
  162.          Caption         =   "Draw &Objects"
  163.          Index           =   1
  164.       End
  165.       Begin VB.Menu EnableSelect 
  166.          Caption         =   "&Copy Area"
  167.          Index           =   2
  168.       End
  169.       Begin VB.Menu EnableSelect 
  170.          Caption         =   "&Paste"
  171.          Index           =   3
  172.       End
  173.       Begin VB.Menu EnableSelect 
  174.          Caption         =   "&Zoom In On Selection"
  175.          Index           =   4
  176.       End
  177.    End
  178.    Begin VB.Menu MenuWindow 
  179.       Caption         =   "&Window"
  180.       WindowList      =   -1  'True
  181.       Begin VB.Menu Cascade 
  182.          Caption         =   "&Cascade"
  183.          Index           =   181
  184.       End
  185.       Begin VB.Menu Tile 
  186.          Caption         =   "&Tile"
  187.          Index           =   182
  188.       End
  189.       Begin VB.Menu ArrangeIcons 
  190.          Caption         =   "Arrange &Icons"
  191.          Index           =   183
  192.       End
  193.       Begin VB.Menu CloseAll 
  194.          Caption         =   "Close &All"
  195.          Index           =   184
  196.       End
  197.    End
  198. Attribute VB_Name = "Main"
  199. Attribute VB_GlobalNameSpace = False
  200. Attribute VB_Creatable = False
  201. Attribute VB_PredeclaredId = True
  202. Attribute VB_Exposed = False
  203. Private Sub About_Click(Index As Integer)
  204.   AboutFrm.Show 1
  205. End Sub
  206. Private Sub ArrangeIcons_Click(Index As Integer)
  207.   Main.Arrange 3
  208. End Sub
  209. Private Sub Cascade_Click(Index As Integer)
  210.   Main.Arrange 0
  211. End Sub
  212. Private Sub CloseAll_Click(Index As Integer)
  213.   While gNumChildren > 0
  214.     Unload Main.ActiveForm
  215.   Wend
  216. End Sub
  217. Private Sub ColorSelect_Click(Index As Integer)
  218.   Main.ActiveForm.DrawColor = Index
  219. End Sub
  220. Private Sub EnableSelect_Click(Index As Integer)
  221.   Select Case (Index)
  222.   Case 0
  223.     DrawMenu = "Disabled"
  224.     Main.ActiveForm.UndoZoom
  225.     Main.ActiveForm.Caption = Main.ActiveForm.FileName + "  (" + CStr(Main.ActiveForm.Lead1.BitmapWidth) + " x " + CStr(Main.ActiveForm.Lead1.BitmapHeight) + " - " + CStr(Main.ActiveForm.Lead1.BitmapBits) + " BPP)"
  226.   Case 1
  227.     DrawMenu = "Object"
  228.   Case 2
  229.     DrawMenu = "Copy"
  230.   Case 3
  231.     DrawMenu = "Paste"
  232.   Case 4
  233.     DrawMenu = "ZoomIn"
  234.   Case Else
  235.     DrawMenu = "Disabled"
  236.   End Select
  237.   Main.EnableSelect(0).CHECKED = False
  238.   Main.EnableSelect(1).CHECKED = False
  239.   Main.EnableSelect(2).CHECKED = False
  240.   Main.EnableSelect(3).CHECKED = False
  241.   Main.EnableSelect(4).CHECKED = False
  242.   Main.EnableSelect(Index).CHECKED = True
  243. End Sub
  244. Private Sub Exit_Click(Index As Integer)
  245.   End
  246. End Sub
  247. Private Sub MDIForm_Load()
  248.   left = 20 * Screen.TwipsPerPixelX
  249.   top = 20 * Screen.TwipsPerPixelY
  250.   Width = Screen.Width - 40 * Screen.TwipsPerPixelX
  251.   Height = Screen.Height - 40 * Screen.TwipsPerPixelY
  252.   MenuFile.Enabled = True
  253.   SaveFile(2).Enabled = False
  254.   MenuObject.Enabled = False
  255.   MenuColor.Enabled = False
  256.   MenuThickness.Enabled = False
  257.   MenuDraw.Enabled = False
  258.   MenuWindow.Enabled = False
  259.   Main.EnableSelect(0).CHECKED = True
  260.   DrawMenu = "Disabled"
  261. End Sub
  262. Private Sub MDIForm_Unload(Cancel As Integer)
  263.   End
  264. End Sub
  265. Private Sub MenuColor_Click()
  266.   For i = 0 To 4
  267.     ColorSelect(i).CHECKED = False
  268.   Next
  269.   ColorSelect(Main.ActiveForm.DrawColor).CHECKED = True
  270. End Sub
  271. Private Sub MenuObject_Click()
  272.   For i = 0 To 2
  273.     ObjectSelect(i).CHECKED = False
  274.   Next
  275.   ObjectSelect(Main.ActiveForm.DrawObject).CHECKED = True
  276. End Sub
  277. Private Sub MenuThickness_Click()
  278.   Dim fOK As Integer
  279.   Dim nValue As Integer
  280.   Dim fChecked As Integer
  281.   Load GetValueFrm
  282.   GetValueInitTheForm "PEN THICKNESS", "Pixels:", 15, 1, Main.ActiveForm.ViewFactor, 3, 1, False
  283.   GetValueFrm.Show 1
  284.   GetValueGetUserSelections fOK, nValue, fChecked
  285.   Unload GetValueFrm
  286.   If fOK Then
  287.     Main.ActiveForm.ViewFactor = nValue
  288.   End If
  289. End Sub
  290. Private Sub ObjectSelect_Click(Index As Integer)
  291.   Main.ActiveForm.DrawObject = Index
  292. End Sub
  293. Private Sub OpenFile_Click(Index As Integer)
  294.     Dim Frm As New ViewFrm
  295.     Static FileName As String
  296.     Dim nBits As Integer
  297.     Dim fPaintWL As Integer
  298.     On Error GoTo ErrorOpen
  299.     LEADDlg1.FileDlgFlags = 0
  300.     LEADDlg1.Filter = "Graphics|*.cmp;*.jpg;*.jff;*.jtf;*.bmp;*.tif;*.tga;*.pcx;*.cal;*.mac;*.img;*.msp;*.wpg;*.wpg;*.ras;*.pct;*.pcd;*.eps;*.wmf;*.gif;*.png"
  301.     LEADDlg1.DialogTitle = "Open File"
  302.     LEADDlg1.UIFlags = DLG_FO_MULTIPAGE + DLG_FO_FILEINFO + DLG_FO_SHOWPREVIEW + DLG_FO_SHOWSTAMP + DLG_FO_95STYLE
  303.     LEADDlg1.FileOpen hWnd
  304.     FileName = LEADDlg1.FileName
  305.     Screen.MousePointer = HOURGLASS
  306.     gDitheringType = 0
  307.     gPaintFixed = PAINTPALETTE_AUTO
  308.     gBitonalType = BITONALSCALING_NORMAL
  309.     Load Frm
  310.     ViewerInitTheForm Frm, FileName, FileName, 0, False
  311.     ' Let windows process messages to avoid a double paint after loading
  312.     DoEvents
  313.     'Load the selected file
  314.     Frm.FileName = FileName
  315.     Frm.Lead1.Load FileName, 0, LEADDlg1.PageNumber, 1
  316.     Frm.ViewFactor = 3
  317.     Frm.Lead1.AutoRepaint = True
  318.     Screen.MousePointer = DEFAULT
  319. Exit Sub
  320. ErrorOpen:
  321.     If Err.Number = ERROR_DLG_CANCELED Then
  322.         'Do nothing if this is just a Cancel.
  323.     Else
  324.         Screen.MousePointer = DEFAULT
  325.         Unload Frm
  326.         MsgBox Err.Source + " " + CStr(Err.Number) + Chr(13) + Err.Description
  327.     End If
  328. End Sub
  329. Private Sub SaveFile_Click(Index As Integer)
  330.     Dim fOK As Boolean
  331.     Static FileName As String
  332.     Static nSaveIdx As Integer
  333.     Dim nBits As Integer
  334.     Dim nFormat As Integer
  335.     Dim nQFactor As Integer
  336.     Dim fMultipage As Boolean
  337.     Dim fStamp As Boolean
  338.     Dim nStampWidth%, nStampHeight%, nStampBits%
  339.     On Error GoTo ErrorSave
  340.     LEADDlg1.FileDlgFlags = 0
  341.     LEADDlg1.UIFlags = DLG_FS_95STYLE + DLG_FS_MULTIPAGE + DLG_FS_STAMP + DLG_FS_QFACTOR
  342.     LEADDlg1.SaveFormatFlags = DLG_FS_ALL
  343.     LEADDlg1.FileSave hWnd
  344.     FileName = LEADDlg1.FileName
  345.     nFormat = LEADDlg1.SaveFormat
  346.     nBits = LEADDlg1.SaveBitsPerPixel
  347.     nQFactor = LEADDlg1.SaveQFactor
  348.     fMultipage = LEADDlg1.SaveMulti
  349.     fStamp = LEADDlg1.SaveWithStamp
  350.     nStampBits = LEADDlg1.SaveStampBits
  351.     nStampWidth = LEADDlg1.SaveStampWidth
  352.     nStampHeight = LEADDlg1.SaveStampHeight
  353.     Main.ActiveForm.Lead1.SaveInterlaced = LEADDlg1.SaveInterlaced
  354.     Screen.MousePointer = HOURGLASS
  355.     If LEADDlg1.SaveWithStamp = True Then
  356.       nOldScaleMode = Main.ActiveForm.Lead1.ScaleMode
  357.       Main.ActiveForm.Lead1.ScaleMode = 3
  358.       Main.ActiveForm.Lead1.SaveWithStamp FileName, nFormat, nBits, nQFactor, nStampWidth, nStampHeight, nStampBits
  359.       Main.ActiveForm.Lead1.ScaleMode = nOldScaleMode
  360.     Else
  361.       Main.ActiveForm.Lead1.Save FileName, nFormat, nBits, nQFactor, fMultipage
  362.     End If
  363.     Screen.MousePointer = DEFAULT
  364. Exit Sub
  365. ErrorSave:
  366.     If Err.Number = ERROR_DLG_CANCELED Then
  367.         'Do nothing if this is just a Cancel.
  368.     Else
  369.         Screen.MousePointer = DEFAULT
  370.         MsgBox Err.Source + " " + CStr(Err.Number) + Chr(13) + Err.Description
  371.     End If
  372. End Sub
  373. Private Sub Tile_Click(Index As Integer)
  374.   Main.Arrange 2
  375. End Sub
  376.