home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / leadtools / ocx32.lt / RESIZE1.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-03-27  |  10.8 KB  |  346 lines

  1. VERSION 5.00
  2. Begin VB.Form Resize 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Resize"
  5.    ClientHeight    =   2835
  6.    ClientLeft      =   1995
  7.    ClientTop       =   2595
  8.    ClientWidth     =   4605
  9.    BeginProperty Font 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    Icon            =   "Resize1.frx":0000
  19.    LinkTopic       =   "Form1"
  20.    LockControls    =   -1  'True
  21.    MaxButton       =   0   'False
  22.    MinButton       =   0   'False
  23.    PaletteMode     =   1  'UseZOrder
  24.    ScaleHeight     =   2835
  25.    ScaleWidth      =   4605
  26.    ShowInTaskbar   =   0   'False
  27.    Begin VB.CheckBox ResampleBox 
  28.       Caption         =   "&Resample"
  29.       Height          =   255
  30.       Left            =   3255
  31.       TabIndex        =   7
  32.       Top             =   1890
  33.       Width           =   1200
  34.    End
  35.    Begin VB.CommandButton Cancel 
  36.       Cancel          =   -1  'True
  37.       Caption         =   "Cancel"
  38.       Height          =   375
  39.       Left            =   2595
  40.       TabIndex        =   9
  41.       Top             =   2295
  42.       Width           =   1200
  43.    End
  44.    Begin VB.CommandButton OK 
  45.       Caption         =   "OK"
  46.       Default         =   -1  'True
  47.       Height          =   375
  48.       Left            =   810
  49.       TabIndex        =   8
  50.       Top             =   2295
  51.       Width           =   1200
  52.    End
  53.    Begin VB.CheckBox AspectRatioBox 
  54.       Caption         =   "Maintain &Aspect-Ratio"
  55.       Height          =   255
  56.       Left            =   195
  57.       TabIndex        =   6
  58.       Top             =   1890
  59.       Width           =   2250
  60.    End
  61.    Begin VB.Frame Frame2 
  62.       Caption         =   "Height"
  63.       Height          =   750
  64.       Left            =   195
  65.       TabIndex        =   3
  66.       Top             =   990
  67.       Width           =   4200
  68.       Begin VB.HScrollBar Value2Bar 
  69.          Height          =   240
  70.          LargeChange     =   10
  71.          Left            =   1035
  72.          TabIndex        =   5
  73.          Top             =   300
  74.          Width           =   2985
  75.       End
  76.       Begin VB.TextBox Value2Box 
  77.          Height          =   285
  78.          Left            =   195
  79.          TabIndex        =   4
  80.          Text            =   "Height"
  81.          Top             =   270
  82.          Width           =   720
  83.       End
  84.    End
  85.    Begin VB.Frame Frame1 
  86.       Caption         =   "Width"
  87.       Height          =   750
  88.       Left            =   195
  89.       TabIndex        =   0
  90.       Top             =   120
  91.       Width           =   4200
  92.       Begin VB.TextBox Value1Box 
  93.          Height          =   285
  94.          Left            =   195
  95.          TabIndex        =   1
  96.          Text            =   "Width"
  97.          Top             =   270
  98.          Width           =   720
  99.       End
  100.       Begin VB.HScrollBar Value1Bar 
  101.          Height          =   240
  102.          LargeChange     =   10
  103.          Left            =   1035
  104.          TabIndex        =   2
  105.          Top             =   300
  106.          Width           =   2985
  107.       End
  108.    End
  109. Attribute VB_Name = "Resize"
  110. Attribute VB_GlobalNameSpace = False
  111. Attribute VB_Creatable = False
  112. Attribute VB_PredeclaredId = True
  113. Attribute VB_Exposed = False
  114. Const CHECKED = 1
  115. Const UNCHECKED = 0
  116. Dim fInValue1Box As Boolean
  117. Dim fInValue2Box As Boolean
  118. Dim fInValue1Bar As Boolean
  119. Dim fInValue2Bar As Boolean
  120. Dim fUserGo As Boolean
  121. Dim UseType As Integer
  122. Public Sub InitTheForm(FormType%)
  123. Dim nTemp As Long
  124. fUserGo = False
  125. UseType = FormType
  126. Select Case FormType
  127.   Case RESIZEREGION_TYPE
  128.     Caption = "Resize"
  129.     Frame1.Caption = "Width"
  130.     Frame2.Caption = "Height"
  131.     Value1Bar.Min = 1
  132.     Value2Bar.Min = 1
  133.     Value1Bar.Max = 16384
  134.     nTemp = CLng(16384) * Main.ActiveForm.Lead1.BitmapHeight / Main.ActiveForm.Lead1.BitmapWidth
  135.     If nTemp > 32767 Then
  136.       nTemp = 32767
  137.     End If
  138.     Value2Bar.Max = CInt(nTemp)
  139.     Value1Bar.LargeChange = 100
  140.     Value2Bar.LargeChange = 100
  141.     Value1Bar.SmallChange = 10
  142.     Value2Bar.SmallChange = 10
  143.     Value1Bar = Main.ActiveForm.Lead1.RgnWidth
  144.     Value2Bar = Main.ActiveForm.Lead1.RgnHeight
  145.     ResampleBox.Value = UNCHECKED
  146.     AspectRatioBox.Value = CHECKED
  147.   Case RESIZE_TYPE
  148.     Caption = "Resize"
  149.     Frame1.Caption = "Width"
  150.     Frame2.Caption = "Height"
  151.     Value1Bar.Min = 1
  152.     Value2Bar.Min = 1
  153.     Value1Bar.Max = 16384
  154.     nTemp = CLng(16384) * Main.ActiveForm.Lead1.BitmapHeight / Main.ActiveForm.Lead1.BitmapWidth
  155.     If nTemp > 32767 Then
  156.       nTemp = 32767
  157.     End If
  158.     Value2Bar.Max = CInt(nTemp)
  159.     Value1Bar.LargeChange = 100
  160.     Value2Bar.LargeChange = 100
  161.     Value1Bar.SmallChange = 10
  162.     Value2Bar.SmallChange = 10
  163.     Value1Bar = Main.ActiveForm.Lead1.BitmapWidth
  164.     Value2Bar = Main.ActiveForm.Lead1.BitmapHeight
  165.     ResampleBox.Value = UNCHECKED
  166.     AspectRatioBox.Value = CHECKED
  167.   Case DETECT_TYPE
  168.     Caption = "Intensity Detect"
  169.     ResampleBox.Visible = False
  170.     AspectRatioBox.Visible = False
  171.     Frame1.Caption = "Low"
  172.     Frame2.Caption = "High"
  173.     Value1Bar.Min = 0
  174.     Value2Bar.Min = 0
  175.     Value1Bar.Max = 255
  176.     Value2Bar.Max = 255
  177.     Value1Bar.LargeChange = 10
  178.     Value2Bar.LargeChange = 10
  179.     Value1Bar.SmallChange = 1
  180.     Value2Bar.SmallChange = 1
  181.     Value1Bar = 128
  182.     Value2Bar = 128
  183.   Case STAMP_TYPE
  184.     Caption = "Stamp Dimensions"
  185.     ResampleBox.Visible = True
  186.     AspectRatioBox.Visible = True
  187.     Frame1.Caption = "Width"
  188.     Frame2.Caption = "Height"
  189.     Value1Bar.Min = 1
  190.     Value2Bar.Min = 1
  191.     Value1Bar.Max = 125
  192.     Value2Bar.Max = 125
  193.     Value1Bar.LargeChange = 10
  194.     Value2Bar.LargeChange = 10
  195.     Value1Bar.SmallChange = 1
  196.     Value2Bar.SmallChange = 1
  197.     Value1Bar = 64
  198.     Value2Bar = 64
  199.     AspectRatioBox.Value = CHECKED
  200.     ResampleBox.Value = UNCHECKED
  201.     ResampleBox.Caption = "8-bit"
  202. End Select
  203. fInValue1Box = False
  204. fInValue2Box = False
  205. fInValue1Bar = False
  206. fInValue2Bar = False
  207. Left = (Screen.Width - Width) / 2
  208. Top = (Screen.Height - Height) / 2
  209. End Sub
  210. Public Sub GetResults(fOK As Boolean, nValue1%, nValue2%, fResample As Boolean)
  211. fOK = fUserGo
  212. nValue1 = Value1Bar
  213. nValue2 = Value2Bar
  214. If ResampleBox.Value = CHECKED Then
  215.   fResample = True
  216.   fResample = False
  217. End If
  218. End Sub
  219. Private Sub AspectRatioBox_Click()
  220. Dim nTemp As Long
  221. If (UseType = RESIZE_TYPE) Or (UseType = RESIZEREGION_TYPE) Then
  222.   Value2Bar.Min = 1
  223.   If UseType = RESIZE_TYPE Then
  224.    nTemp = CLng(16384) * Main.ActiveForm.Lead1.BitmapHeight / Main.ActiveForm.Lead1.BitmapWidth
  225.   Else
  226.    nTemp = CLng(16384) * Main.ActiveForm.Lead1.RgnHeight / Main.ActiveForm.Lead1.RgnWidth
  227.   End If
  228.   If nTemp > 32767 Then
  229.     nTemp = 32767
  230.   End If
  231.   Value2Bar.Max = CInt(nTemp)
  232.   If UseType = RESIZE_TYPE Then
  233.    nTemp = CLng(Value1Bar) * Main.ActiveForm.Lead1.BitmapHeight / Main.ActiveForm.Lead1.BitmapWidth
  234.   Else
  235.    nTemp = CLng(Value1Bar) * Main.ActiveForm.Lead1.RgnHeight / Main.ActiveForm.Lead1.RgnWidth
  236.   End If
  237.   If nTemp > 32767 Then
  238.     nTemp = 32767
  239.   End If
  240.   Value2Bar = CInt(nTemp)
  241. End If
  242. End Sub
  243. Private Sub Cancel_Click()
  244. End Sub
  245. Private Sub Form_Activate()
  246. Value1Box.SetFocus
  247. End Sub
  248. Private Sub OK_Click()
  249. If Len(Value1Box.Text) > 0 And Len(Value2Box.Text) > 0 Then
  250.   If CInt(Value1Box.Text) <= Value1Bar.Max And CInt(Value1Box.Text) >= Value1Bar.Min And CInt(Value2Box.Text) <= Value2Bar.Max And CInt(Value2Box.Text) >= Value2Bar.Min Then
  251.     fUserGo = True
  252.     Hide
  253.   End If
  254. End If
  255. End Sub
  256. Private Sub Value1Bar_Change()
  257. Dim NewValue2 As Integer
  258. Dim nTemp As Long
  259. If fInValue1Box = False Then
  260.   fInValue1Bar = True
  261.   Value1Box.Text = CStr(Value1Bar.Value)
  262.   If AspectRatioBox.Value = CHECKED Then
  263.     If UseType = RESIZEREGION_TYPE Then
  264.       nTemp = CLng(Value1Bar) * Main.ActiveForm.Lead1.RgnHeight / Main.ActiveForm.Lead1.RgnWidth
  265.     Else
  266.       nTemp = CLng(Value1Bar) * Main.ActiveForm.Lead1.BitmapHeight / Main.ActiveForm.Lead1.BitmapWidth
  267.     End If
  268.     If nTemp > 32767 Then
  269.       nTemp = 32767
  270.     End If
  271.     NewValue2 = CInt(nTemp)
  272.     If NewValue2 <> Value2Bar And NewValue2 >= Value2Bar.Min And NewValue2 <= Value2Bar.Max Then
  273.       Value2Bar = NewValue2
  274.     End If
  275.   End If
  276. End If
  277. fInValue1Box = False
  278. End Sub
  279. Private Sub Value1Box_Change()
  280. Dim NewValue2 As Integer
  281. If fInValue1Bar = False Then
  282.   fInValue1Box = True
  283.   If Len(Value1Box.Text) > 0 Then
  284.     If CInt(Value1Box.Text) <= Value1Bar.Max And CInt(Value1Box.Text) >= Value1Bar.Min Then
  285.       Value1Bar = CInt(Value1Box.Text)
  286.       If AspectRatioBox.Value = CHECKED Then
  287.         If UseType = RESIZEREGION_TYPE Then
  288.          NewValue2 = CInt(CLng(Value1Bar) * Main.ActiveForm.Lead1.RgnHeight / Main.ActiveForm.Lead1.RgnWidth)
  289.         Else
  290.          NewValue2 = CInt(CLng(Value1Bar) * Main.ActiveForm.Lead1.BitmapHeight / Main.ActiveForm.Lead1.BitmapWidth)
  291.         End If
  292.         If NewValue2 <> Value2Bar And NewValue2 >= Value2Bar.Min And NewValue2 <= Value2Bar.Max Then
  293.           Value2Bar = NewValue2
  294.         End If
  295.       End If
  296.     End If
  297.   End If
  298. End If
  299. fInValue1Bar = False
  300. End Sub
  301. Private Sub Value2Bar_Change()
  302. Dim NewValue1 As Integer
  303. Dim nTemp As Long
  304. If fInValue2Box = False Then
  305.   fInValue2Bar = True
  306.   Value2Box.Text = CStr(Value2Bar.Value)
  307.   If AspectRatioBox.Value = CHECKED Then
  308.     If UseType = RESIZEREGION_TYPE Then
  309.       nTemp = CLng(Value2Bar) * Main.ActiveForm.Lead1.RgnWidth / Main.ActiveForm.Lead1.RgnHeight
  310.     Else
  311.       nTemp = CLng(Value2Bar) * Main.ActiveForm.Lead1.BitmapWidth / Main.ActiveForm.Lead1.BitmapHeight
  312.     End If
  313.     If nTemp > 32767 Then
  314.       nTemp = 32767
  315.     End If
  316.     NewValue1 = CInt(nTemp)
  317.     If NewValue1 <> Value1Bar And NewValue1 >= Value1Bar.Min And NewValue1 <= Value1Bar.Max Then
  318.       Value1Bar = NewValue1
  319.     End If
  320.   End If
  321. End If
  322. fInValue2Box = False
  323. End Sub
  324. Private Sub Value2Box_Change()
  325. Dim NewValue1 As Integer
  326. If fInValue2Bar = False Then
  327.   fInValue2Box = True
  328.   If Len(Value2Box.Text) > 0 Then
  329.     If CInt(Value2Box.Text) <= Value2Bar.Max And CInt(Value2Box.Text) >= Value2Bar.Min Then
  330.       Value2Bar = CInt(Value2Box.Text)
  331.       If AspectRatioBox.Value = CHECKED Then
  332.         If UseType = RESIZEREGION_TYPE Then
  333.          NewValue1 = CInt(CLng(Value2Bar) * Main.ActiveForm.Lead1.RgnWidth / Main.ActiveForm.Lead1.RgnHeight)
  334.         Else
  335.          NewValue1 = CInt(CLng(Value2Bar) * Main.ActiveForm.Lead1.BitmapWidth / Main.ActiveForm.Lead1.BitmapHeight)
  336.         End If
  337.         If NewValue1 <> Value1Bar And NewValue1 >= Value1Bar.Min And NewValue1 <= Value1Bar.Max Then
  338.           Value1Bar = NewValue1
  339.         End If
  340.       End If
  341.     End If
  342.   End If
  343. End If
  344. fInValue2Bar = False
  345. End Sub
  346.