Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Visual Basic Programming Code Examples

Visual Basic > Control Special Effects Code Examples

How to draw 3D raised and recessed bevels on a form.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
How to draw 3D raised and recessed bevels on a form. 'How to fill a listbox with files, directories and drives. 'Note: This has only been tested with VB 3 & VB 4-16, if you convert ' Create A 3D Raised or Recessed Bevel On A Form ' Add the rountine below: Sub FormBevelLines (FormFrame As Form, side, wid, color) ' This Sub is called by FormInner/Outer Bevel to draw the ' lines for FormInnerBevel and FormOuterBevel Dim X1, Y1, X2, Y2 As Integer Dim rightX, bottomY Dim dx1, dx2, dy1, dy2 As Integer Dim i rightX = FormFrame.ScaleWidth - 1 bottomY = FormFrame.ScaleHeight - 1 Select Case side Case 0 'Left side X1 = 0: dx1 = 1 X2 = 0: dx2 = 1 Y1 = 0: dy1 = 1 Y2 = bottomY + 1: dy2 = -1 Case 1 'Right side X1 = rightX: dx1 = -1 X2 = X1: dx2 = dx1 Y1 = 0: dy1 = 1 Y2 = bottomY + 1: dy2 = -1 Case 2 'Top side X1 = 0: dx1 = 1 X2 = rightX: dx2 = -1 Y1 = 0: dy1 = 1 Y2 = 0: dy2 = 1 Case 3 'Bottom side X1 = 1: dx1 = 1 X2 = rightX + 1: dx2 = -1 Y1 = bottomY: dy1 = -1 Y2 = Y1: dy2 = dy1 End Select For i = 1 To wid FormFrame.Line (X1, Y1)-(X2, Y2), color X1 = X1 + dx1 X2 = X2 + dx2 Y1 = Y1 + dy1 Y2 = Y2 + dy2 Next i End Sub 'Here are the 2 main routines: Sub FormOuterBevel (FormFrame As Form, BevelWidth As Integer) ' This sub draws raised bevels on a Form ' ' Parameters Type Comments ' FormFrame Form the Form to bevel ' BevelWidth integer width of bevel in pixels FormFrame.ScaleMode = 3 ' Pixels FormBevelLines FormFrame, 0, BevelWidth, QBColor(15) 'White FormBevelLines FormFrame, 1, BevelWidth, QBColor(8) 'D.Gray FormBevelLines FormFrame, 2, BevelWidth, QBColor(15) 'White FormBevelLines FormFrame, 3, BevelWidth, QBColor(8) 'D.Gray End Sub ' Example: ' In the Form_Paint event: FormOuterBevel Form1, 3 '3 pixels in width Sub FormInnerBevel (FormFrame As Form, BevelWidth As Integer) ' This sub draws recessed bevels on a Form ' ' Parameters Type Comments ' FormFrame Form the Form to bevel ' BevelWidth integer width of bevel in pixels ' FormFrame.ScaleMode = 3 ' Pixels FormBevelLines FormFrame, 0, BevelWidth, QBColor(8) 'D.Gray FormBevelLines FormFrame, 1, BevelWidth, QBColor(15) 'White FormBevelLines FormFrame, 2, BevelWidth, QBColor(8) FormBevelLines FormFrame, 3, BevelWidth, QBColor(15) End Sub ' Example: ' Call from the Form_Paint event FormInnerBevel Form1, 3 '3 pixels in width