home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frm3DControlsDemo
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "3D Controls Demo--VBX vs. Code-Drawn"
- ClientHeight = 4560
- ClientLeft = 1350
- ClientTop = 2085
- ClientWidth = 6555
- ForeColor = &H000000FF&
- Height = 4965
- Icon = DS3D.FRX:0000
- Left = 1290
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 4560
- ScaleWidth = 6555
- Top = 1740
- Width = 6675
- Begin SSCommand c3dCommandBtn
- Caption = "3D Command Button--&Exit"
- Font3D = 2 'Raised w/heavy shading
- Height = 675
- Left = 195
- TabIndex = 0
- Top = 3645
- Width = 2865
- End
- Begin SSPanel Panel3D2
- AutoSize = 3 'AutoSize Child To Panel
- BackColor = &H00C0C0C0&
- BevelInner = 2 'Raised
- BevelOuter = 0 'None
- BevelWidth = 2
- BorderWidth = 0
- Caption = "Panel3D2"
- Font3D = 0 'None
- ForeColor = &H00800000&
- Height = 675
- Left = 195
- TabIndex = 4
- Top = 2745
- Width = 2865
- Begin PictureBox picScrollCorner
- AutoSize = -1 'True
- Height = 240
- Index = 1
- Left = 2580
- Picture = DS3D.FRX:0302
- ScaleHeight = 210
- ScaleWidth = 210
- TabIndex = 14
- TabStop = 0 'False
- Top = 405
- Width = 240
- End
- Begin TextBox txtTextBoxIn3D
- BorderStyle = 0 'None
- Height = 615
- Left = 45
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 13
- TabStop = 0 'False
- Text = "Standard text box inside THREED.VBX frame"
- Top = 30
- Width = 2775
- End
- End
- Begin OptionButton optStandardOption
- BackColor = &H00C0C0C0&
- Caption = "Standard Option"
- Height = 315
- Left = 3510
- TabIndex = 12
- TabStop = 0 'False
- Top = 2265
- Value = -1 'True
- Width = 2865
- End
- Begin SSOption o3dOption
- Caption = "3D Option"
- Font3D = 4 'Inset w/heavy shading
- ForeColor = &H00000000&
- Height = 285
- Left = 195
- TabIndex = 11
- Top = 2265
- Value = -1 'True
- Width = 1410
- End
- Begin Frame fraStandardFrame
- BackColor = &H00C0C0C0&
- Caption = "Standard Frame"
- Height = 945
- Left = 3510
- TabIndex = 6
- Top = 1155
- Width = 2865
- End
- Begin SSFrame f3dFrame
- Caption = "3D Frame"
- Font3D = 1 'Raised w/light shading
- ForeColor = &H00000000&
- Height = 945
- Left = 180
- TabIndex = 3
- Top = 1155
- Width = 2865
- End
- Begin CheckBox chkStandardCheckBox
- BackColor = &H00C0C0C0&
- Caption = "Standard Check Box"
- Height = 270
- Left = 3510
- TabIndex = 10
- TabStop = 0 'False
- Top = 675
- Value = 1 'Checked
- Width = 2865
- End
- Begin SSCheck x3dCheckBox
- Caption = "3D Check Box"
- Font3D = 1 'Raised w/light shading
- Height = 270
- Left = 210
- TabIndex = 9
- TabStop = 0 'False
- Top = 675
- Value = -1 'True
- Width = 1530
- End
- Begin SSPanel p3dPanel
- BackColor = &H00C0C0C0&
- BevelWidth = 2
- BorderWidth = 0
- Caption = "3D Panel"
- Font3D = 3 'Inset w/light shading
- ForeColor = &H00800000&
- Height = 315
- Left = 180
- TabIndex = 2
- Top = 150
- Width = 2865
- End
- Begin PictureBox picScrollCorner
- AutoSize = -1 'True
- Height = 240
- Index = 0
- Left = 6135
- Picture = DS3D.FRX:046C
- ScaleHeight = 210
- ScaleWidth = 210
- TabIndex = 8
- TabStop = 0 'False
- Top = 3180
- Width = 240
- End
- Begin TextBox txtTextBox
- Height = 675
- Left = 3510
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 7
- Text = "3D controls!"
- Top = 2745
- Width = 2865
- End
- Begin CommandButton cmdExit
- BackColor = &H00000000&
- Caption = "Standard Command Button--E&xit"
- Height = 675
- Left = 3510
- TabIndex = 1
- Top = 3645
- Width = 2865
- End
- Begin Label lblStandardLabel
- Alignment = 2 'Center
- BackColor = &H00C0C0C0&
- Caption = "Standard Label"
- Height = 270
- Left = 3495
- TabIndex = 5
- Top = 180
- Width = 2865
- End
- '3D Controls By Code--demonstration and template code.
- Option Explicit
- DefInt A-Z
- 'Constants to describe control 3D state to paint.
- Const RAISED = -1 'Frame is raised
- Const RECESSED = 0 'Frame is recessed
- 'Color values to use for specific lines that give 3D look.
- 'For the line, Red, Green and Blue values will all
- 'be set to this value, so all three will be equal--which
- 'produces a shade of grey.
- Const WHITE = 255 'Light gray/white
- Const DARKGRAY = 128 'Dark gray
- Const BLACK = 64 'Black
- 'Variable to hold the width of the frame desired.
- Dim FrameWidth% 'Width of 3d frame (in pixels)
- 'A flag.
- Dim flgScrollCornerClicked%
- Sub c3dCommandBtn_Click ()
- Unload Me
- End
- End Sub
- Sub cmdExit_Click ()
- Unload Me
- End
- End Sub
- Sub Form_Load ()
- Left = (Screen.Width - Width) / 2: Top = (Screen.Height - Height) / 2
- End Sub
- Sub Form_Paint ()
- 'The calling syntax for the called sub is:
- 'subInit3D (Ctrl As Control, ThreeDState As Integer)
- 'So we pass it two parameters within the parens: the
- 'control we want to run the sub on, and the CONSTANT
- 'name for the 3D state we want for that control.
- 'EACH CONTROL FOR WHICH A 3D EFFECT IS DESIRED
- 'MUST BE INITIALIZED SEPARATELY!
- If flgScrollCornerClicked = True Then
- Call subInit3D(lblStandardLabel, RECESSED)
- Call subInit3D(chkStandardCheckBox, RECESSED)
- Call subInit3D(fraStandardFrame, RECESSED)
- Call subInit3D(optStandardOption, RECESSED)
- Call subInit3D(txtTextBox, RECESSED)
- Call subInit3D(cmdExit, RECESSED)
- Else
- Call subInit3D(lblStandardLabel, RAISED)
- Call subInit3D(chkStandardCheckBox, RAISED)
- Call subInit3D(fraStandardFrame, RAISED)
- Call subInit3D(optStandardOption, RAISED)
- Call subInit3D(txtTextBox, RAISED)
- Call subInit3D(cmdExit, RAISED)
- End If
- End Sub
- Sub picScrollCorner_Click (Index As Integer)
- Select Case Index
- Case 0
- flgScrollCornerClicked = Not flgScrollCornerClicked
- Call Form_Paint
- Case 1
- If Panel3D2.BevelOuter = 1 Then
- Panel3D2.BevelOuter = 2
- Else
- Panel3D2.BevelOuter = 1
- End If
- If p3dPanel.BevelOuter = 1 Then
- p3dPanel.BevelOuter = 2
- Else
- p3dPanel.BevelOuter = 1
- End If
- End Select
- End Sub
- Sub subInit3D (Ctrl As Control, ThreeDState As Integer)
- 'Top, Left, Height, Width.
- Dim T%, L%, H%, W%
- 'Counter index.
- Dim i%
- 'Top/Left sides shade, Bottom/Right sides shade.
- Dim TLShade&, BRShade& 'Top/Left sides shade, Bottom/Right sides shade.
- 'Convert ScaleMode of form to pixels.
- Ctrl.Parent.ScaleMode = 3
- 'Set up colors for borders on ThreeDState. For recessed control:
- 'top & left = dark, bottom & right = light
- 'opposite for raised controls.
- If ThreeDState = RAISED Then
- TLShade& = RGB(WHITE, WHITE, WHITE)
- BRShade& = RGB(DARKGRAY, DARKGRAY, DARKGRAY)
- ElseIf ThreeDState = RECESSED Then
- TLShade& = RGB(DARKGRAY, DARKGRAY, DARKGRAY)
- BRShade& = RGB(WHITE, WHITE, WHITE)
- End If
- 'Now draw the Frame Around the Control, on the Parent Form.
- FrameWidth = 2 '1 (or n) pixel(s) wide. Most 3D controls use 2 pixels; this look is more subtle. 2 is good, too. 3 starts looking horsey.
- 'The loop draws a line around the control i pixels away
- 'in the specified direction.
- For i = 1 To FrameWidth
- T = Ctrl.Top - i
- L = Ctrl.Left - i
- H = Ctrl.Height + 2 * i
- W = Ctrl.Width + 2 * i
- Ctrl.Parent.Line (L, T)-Step(0, H), TLShade& ' left side
- Ctrl.Parent.Line (L, T)-Step(W, 0), TLShade& ' top
- Ctrl.Parent.Line (L + W, T)-Step(0, H), BRShade& ' right side
- Ctrl.Parent.Line (L, T + H)-Step(W, 0), BRShade& ' bottom
- Next i
- End Sub
-