LabelPlus




' API Declarations Required

Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SYSCOMMAND = &H112
'_________________________________________________________


Private Sub Command1_Click()
' Next

OpenerFrame.Visible = False
' Resize the form and hide it to recenter it, then re display it

Form1.Width = 7020
Form1.Height = 4950
Form1.Hide
Form1.Show
frameExamples.Visible = True
' Hide Command Buttons

Command1.Visible = False
Command2.Visible = False
End Sub
'_________________________________________________________


Private Sub Command2_Click()
' Cancel

Unload Form1
End
End Sub
'_________________________________________________________


Private Sub Form_Load()
' Position Controls and set sizes

OpenerFrame.Left = 120
Command1.Left = 3960
Command2.Left = 4920
Me.Width = 5970
Me.Height = 3945
Me.Show
BuildNote
End Sub
'_________________________________________________________


Private Sub BuildNote()
' Dimension a variable to contain a string message

Dim WelcomeNote As String
' Build the message string

WelcomeNote = "Welcome to the Stormdev Software Learning Series"
WelcomeNote = WelcomeNote & vbCrLf & vbCrLf
WelcomeNote = WelcomeNote & "In this series we will examine some of the different uses for the label control, this example is aimed at novice programmers but may provide useful information for programmers of any level. "
WelcomeNote = WelcomeNote & "Anyways, I hope that this series will shine some light on creative uses for the label control."
WelcomeNote = WelcomeNote & vbCrLf & vbCrLf & "Happy Coding," & vbCrLf
WelcomeNote = WelcomeNote & vbCrLf & "Jonathan Roach - CEO Stormdev Software Development"
WelcomeNote = WelcomeNote & vbCrLf & "stormdev@golden.net"
' Display the message string

lblWelcome.Caption = WelcomeNote
End Sub
'_________________________________________________________


Private Sub frameExamples_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Reset the forecolor of the button label to Black when the mouse is outside the button label

lblButtonEffect(0).ForeColor = vbBlack
End Sub
'_________________________________________________________


Private Sub lblButtonEffect_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' If the mouse is over the first label in our control array then move the label to the same position as our shadow label

If Index = 0 Then
lblButtonEffect(0).Move lblButtonEffect(1).Left, lblButtonEffect(1).Top
End If
End Sub
'_________________________________________________________


Private Sub lblButtonEffect_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' If the mouse is over the first label in our control array change the text color "Highlight"

If Index = 0 Then
lblButtonEffect(0).ForeColor = vbYellow
End If
End Sub
'_________________________________________________________


Private Sub lblButtonEffect_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' Return the button label to it's un-pressed position

If Index = 0 Then
lblButtonEffect(0).Move 4065, 570
End If
End Sub
'_________________________________________________________


Private Sub lblMenuSystem_Click(Index As Integer)
Select Case Index
Case 1 ' Option 1
MsgBox "Applications Option Selected !", vbOKOnly, "Menu Option Selected"
Case 2 ' Option 2
MsgBox "Information Option Selected", vbOKOnly, "Menu Option Selected"
Case 3 ' Option 3
MsgBox "VB Programming Option Selected", vbOKOnly, "Menu Option Selected"
Case 4 ' Option 4
MsgBox "This menu uses 7 Label Controls, In a Control Array", vbOKOnly, "Menu Option Selected"
End Select
End Sub
'_________________________________________________________


Private Sub lblMenuSystem_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' Change the highlight on the menu to distinguish which option is active to click

If Index <> 0 And Index <= 4 Then
For X = 1 To 4
If X = Index Then
lblMenuSystem(X).Font.Bold = True
lblMenuSystem(X).ForeColor = vbBlack
Else
lblMenuSystem(X).Font.Bold = False
lblMenuSystem(X).ForeColor = &H8000&
End If
Next X
End If
End Sub
'_________________________________________________________


Private Sub lblMoveForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' The following code uses our API declarations to accomplish moving the form from

' the label control.

If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_SYSCOMMAND, &HF012, 0
End If
End Sub
'_________________________________________________________


Private Sub lblShadowFg_Click()
' Display a message explaining the shadow effect

MsgBox "This effect is accomplished by using 2 Label Controls in slightly different positions with different colors...", vbOKOnly, "Shadowing Explanation"
End Sub

' API Declarations Required

Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SYSCOMMAND = &H112

Private Sub Command1_Click()
' Next

OpenerFrame.Visible = False
' Resize the form and hide it to recenter it, then re display it

Form1.Width = 7020
Form1.Height = 4950
Form1.Hide
Form1.Show
frameExamples.Visible = True
' Hide Command Buttons

Command1.Visible = False
Command2.Visible = False
End Sub

Private Sub Command2_Click()
' Cancel

Unload Form1
End
End Sub

Private Sub Form_Load()
' Position Controls and set sizes

OpenerFrame.Left = 120
Command1.Left = 3960
Command2.Left = 4920
Me.Width = 5970
Me.Height = 3945
Me.Show
BuildNote
End Sub

Private Sub BuildNote()
' Dimension a variable to contain a string message

Dim WelcomeNote As String
' Build the message string

WelcomeNote = "Welcome to the Stormdev Software Learning Series"
WelcomeNote = WelcomeNote & vbCrLf & vbCrLf
WelcomeNote = WelcomeNote & "In this series we will examine some of the different uses for the label control, this example is aimed at novice programmers but may provide useful information for programmers of any level. "
WelcomeNote = WelcomeNote & "Anyways, I hope that this series will shine some light on creative uses for the label control."
WelcomeNote = WelcomeNote & vbCrLf & vbCrLf & "Happy Coding," & vbCrLf
WelcomeNote = WelcomeNote & vbCrLf & "Jonathan Roach - CEO Stormdev Software Development"
WelcomeNote = WelcomeNote & vbCrLf & "stormdev@golden.net"
' Display the message string

lblWelcome.Caption = WelcomeNote
End Sub

Private Sub frameExamples_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Reset the forecolor of the button label to Black when the mouse is outside the button label

lblButtonEffect(0).ForeColor = vbBlack
End Sub

Private Sub lblButtonEffect_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' If the mouse is over the first label in our control array then move the label to the same position as our shadow label

If Index = 0 Then
lblButtonEffect(0).Move lblButtonEffect(1).Left, lblButtonEffect(1).Top
End If
End Sub

Private Sub lblButtonEffect_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' If the mouse is over the first label in our control array change the text color "Highlight"

If Index = 0 Then
lblButtonEffect(0).ForeColor = vbYellow
End If
End Sub

Private Sub lblButtonEffect_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' Return the button label to it's un-pressed position

If Index = 0 Then
lblButtonEffect(0).Move 4065, 570
End If
End Sub

Private Sub lblMenuSystem_Click(Index As Integer)
Select Case Index
Case 1 ' Option 1
MsgBox "Applications Option Selected !", vbOKOnly, "Menu Option Selected"
Case 2 ' Option 2
MsgBox "Information Option Selected", vbOKOnly, "Menu Option Selected"
Case 3 ' Option 3
MsgBox "VB Programming Option Selected", vbOKOnly, "Menu Option Selected"
Case 4 ' Option 4
MsgBox "This menu uses 7 Label Controls, In a Control Array", vbOKOnly, "Menu Option Selected"
End Select
End Sub

Private Sub lblMenuSystem_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
' Change the highlight on the menu to distinguish which option is active to click

If Index <> 0 And Index <= 4 Then
For X = 1 To 4
If X = Index Then
lblMenuSystem(X).Font.Bold = True
lblMenuSystem(X).ForeColor = vbBlack
Else
lblMenuSystem(X).Font.Bold = False
lblMenuSystem(X).ForeColor = &H8000&
End If
Next X
End If
End Sub

Private Sub lblMoveForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' The following code uses our API declarations to accomplish moving the form from

' the label control.

If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_SYSCOMMAND, &HF012, 0
End If
End Sub

Private Sub lblShadowFg_Click()
' Display a message explaining the shadow effect

MsgBox "This effect is accomplished by using 2 Label Controls in slightly different positions with different colors...", vbOKOnly, "Shadowing Explanation"
End Sub

' Feel Free to use this code as you see fit ;)

' I hoped you learned from some of this code, any questions or comments are welcome, stormdev@golden.net











( labelplus.html )- by Paolo Puglisi - Modifica del 17/12/2023