' Draw a colored box the same size as the largest Frame. The controls
' won't be affected as they are drawn on top of Lines and every Frame
' of smaller size also draws its color, so the end effect is color
' between Frames. This means you must draw the Frames in order from
' the largest to the smallest.
'
' Also, when you want to find the right-most position occupied by a
' control where you are given its left-most position and its width,
' you must add the left postion and the width and subtract one.
' right-most position = (Control.Left + Control.Width) - 1
' For example: Your command button's Left property is 3 and its width
' is 5, so it occupies positions 3, 4, 5, 6, 7. To find its right
' most position, you add its Left, 3, and Width, 5, and subtract 1.
' 7 = 3 + 5 - 1
'
' In "x2 =" and "y2 =" below we substract the number of twips in each
' pixel so that the Frames right and bottom lines will each be the same
' distance away from the control as the Frames top and left lines. The
' OFFSET is the number of pixels away from the control the Frame is.
'
'Top-left to Bottom-Right box in Color
x1 = FrameLeft - Offset
y1 = FrameTop - Offset
x2 = FrameWidth + Offset - TWIPS
y2 = FrameHeight + Offset - TWIPS
Line (x1, y1)-(x2, y2), QBColor(Color), BF
' This determines if the left & top lines are white and the right &
' bottom lines are dark gray (for the "Raised" look) or the left & top
' lines are dark gray and the right & bottom lines are white (for the
' "Inset" look). Since this routine only tests the first character of
' the parameter changed to upper case, you could just put in an r or an
' i in either upper or lower case. But putting in the whole word makes
' the program read easier.
'
' Try substituting black, 0, for dark gray for a sharper look.
'
If UCase$(Left$(Style, 1)) = "R" Then
xx = 15 ' Bright White
yy = 8 ' Dark Gray
Else
xx = 8
yy = 15
End If
' The last line drawn covers up any lines below it. So the Frames left
' and top lines are drawn first and the Frames right and bottom lines
' are drawn last.
'
' Bottom-left to Top-left line
x1 = FrameLeft - Offset
y1 = FrameHeight + Offset - TWIPS
x2 = FrameLeft - Offset
y2 = FrameTop - Offset - TWIPS
Line (x1, y1)-(x2, y2), QBColor(xx)
' Top-left to Top-Right line
x1 = FrameLeft - Offset
y1 = FrameTop - Offset
x2 = FrameWidth + Offset
y2 = FrameTop - Offset
Line (x1, y1)-(x2, y2), QBColor(xx)
' Top-Right to Bottom-Right line
x1 = FrameWidth + Offset - TWIPS
y1 = FrameTop - Offset
x2 = FrameWidth + Offset - TWIPS
y2 = FrameHeight + Offset
Line (x1, y1)-(x2, y2), QBColor(yy)
' Bottom-Right to Bottom-Left line
x1 = FrameWidth + Offset - TWIPS
y1 = FrameHeight + Offset - TWIPS
x2 = FrameLeft - Offset - TWIPS
y2 = FrameHeight + Offset - TWIPS
Line (x1, y1)-(x2, y2), QBColor(yy)
' Restore the FORM's original values
DrawWidth = SaveDrawWidth
FillStyle = SaveFillStyle
ScaleMode = SaveScaleMode
End Sub
Sub Form_Load ()
Show
Color = 7
Label1.Caption = "Sub DrawFrameOn (TopLeftControl As Control, BottomRightControl As Control, Style As String, FrameOffset As Integer, Color As Integer)"
Label2.Caption = "Click the squares"
Text1.Text = ""
End Sub
Sub menuBar_Click (Index As Integer)
Select Case Index
Case 1
End
End Select
End Sub
Sub menuColor_Click (Index As Integer)
Dim i
For i = 0 To 15
menuColor(i).Checked = False
Next i
Color = Index
menuColor(Index).Checked = True
Select Case Pict
Case 1
Picture1_Click
Case 2
Picture2_Click
Case 3
Picture3_Click
Case 4
Picture4_Click
Case 5
Picture5_Click
Case 6
Picture6_Click
End Select
End Sub
Sub Picture1_Click ()
Dim LF
LF = Chr$(13) & Chr$(10)
Form1.BackColor = QBColor(7)
DrawFrameOn Picture1, Picture7, "Inset", 10, 7
Pict = 1
Msg = "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Inset"
Msg = Msg & Chr$(34) & ", 10, 7"
Text1.Text = Msg
End Sub
Sub Picture2_Click ()
Dim LF
LF = Chr$(13) & Chr$(10)
Form1.BackColor = QBColor(7)
DrawFrameOn Picture1, Picture7, "Raised", 10, 7
Pict = 2
Msg = "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Raised"
Msg = Msg & Chr$(34) & ", 10, 7"
Text1.Text = Msg
End Sub
Sub Picture3_Click ()
Dim LF
LF = Chr$(13) & Chr$(10)
Form1.BackColor = QBColor(7)
DrawFrameOn Picture1, Picture7, "Inset", 10, Color
DrawFrameOn Picture1, Picture7, "Raised", 5, 7
Pict = 3
Msg = "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Inset"
Msg = Msg & Chr$(34) & ", 10," & Str$(Color) & LF
Msg = Msg & "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Raised"
Msg = Msg & Chr$(34) & ", 5, 7"
Text1.Text = Msg
End Sub
Sub Picture4_Click ()
Dim LF
LF = Chr$(13) & Chr$(10)
Form1.BackColor = QBColor(7)
DrawFrameOn Picture1, Picture7, "Raised", 10, Color
DrawFrameOn Picture1, Picture7, "Inset", 5, 7
Pict = 4
Msg = "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Raised"
Msg = Msg & Chr$(34) & ", 10," & Str$(Color) & LF
Msg = Msg & "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Inset"
Msg = Msg & Chr$(34) & ", 5, 7"
Text1.Text = Msg
End Sub
Sub Picture5_Click ()
Dim LF
LF = Chr$(13) & Chr$(10)
Form1.BackColor = QBColor(7)
DrawFrameOn Picture1, Picture7, "Inset", 10, Color
DrawFrameOn Picture1, Picture7, "Inset", 5, 7
Pict = 5
Msg = "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Inset"
Msg = Msg & Chr$(34) & ", 10," & Str$(Color) & LF
Msg = Msg & "DrawFrameOn Picture1, Picture7, "
Msg = Msg & Chr$(34) & "Inset"
Msg = Msg & Chr$(34) & ", 5, 7"
Text1.Text = Msg
End Sub
Sub Picture6_Click ()
Dim LF
LF = Chr$(13) & Chr$(10)
Form1.BackColor = QBColor(7)
DrawFrameOn Picture1, Picture7, "Raised", 10, Color