Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hot Tracking Label Button
Message
From
10/10/2004 14:49:20
 
 
To
09/10/2004 19:48:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00950207
Message ID:
00950277
Views:
22
This message has been marked as the solution to the initial question of the thread.
>Hi
>
>I now have a button that looks like a label until you mouse over it. Then, the hot tracking effect makes it look like a button. What I would like to do to complete the effect is as follows :-
>
>1) When the mouse is over the button, display a picture that is totally left justified.
>2) At all times, display the text caption that is totally right justified.
>
>I have placed code in the mouse enter/ mouse leave to show and hide the picture but at this stage, it left justifies relative to the text. As the text can be of variable length, the picture does not stay in the same left position. I would like the picture to be in the same position as the picture in the BAR of a MENU, ie., the very leftmost position.
>
>Any ideas would be greatly appreciated.
>
>Best


Hi Gary,

Like Frank said, you can make your own custom class (from an image) to act like a button. You can download this file #14876 if you want to try. The ImageButton class was made in VFP6.

Or you can make it from a Container, LineShape & Label control.
Here is the example:
DEFINE CLASS ButtonLabel AS container

   Width = 71
   Height = 35
   BackStyle = 0
   BorderWidth = 0
   Name = "ButtonLabel"

   ADD OBJECT label1 AS label WITH ;
      AutoSize = .T., Caption = "Menu1", ;
      Height = 17, Left = 17, Top = 10, Width = 39, ;
      TabIndex = 1, ;
      Name = "Label1"

   ADD OBJECT line_1 AS line WITH ;
      Height = 0, Left = 3, Top = 3, Width = 63, ;
      Name = "Line_1"

   ADD OBJECT line_2 AS line WITH ;
      Height = 28, Left = 3, Top = 3, Width = 0, ;
      Name = "Line_2"

   ADD OBJECT line_3 AS line WITH ;
      Height = 0, Left = 3, Top = 31, Width = 63, ;
      Name = "Line_3"

   ADD OBJECT line_4 AS line WITH ;
      Height = 28, Left = 66, Top = 3, Width = 0, ;
      Name = "Line_4"


   PROCEDURE Init
      If (type('ThisForm.nLightColor') == 'U')
         Declare Long GetSysColor in User32 Integer nIndex
         With ThisForm
            .AddProperty( 'nLightColor', GetSysColor(20) )
            .AddProperty( 'nShadowColor', GetSysColor(16) )
            .AddProperty( 'oMenuActive', Null )
         EndWith
         Clear Dlls GetSysColor
      endif

      With This
         .SetAll( 'BorderStyle', 0, 'Line' )
         .Label1.Visible = .T.
         .Height = .Label1.Height + 8
         .Width = .Label1.Width + 15

         .Line_1.Left = 1
         .Line_1.Top = 1
         .Line_1.Width = .Width
         .Line_1.BorderColor = ThisForm.nLightColor

         .Line_2.Left = 1
         .Line_2.Top = 1
         .Line_2.Height = .Height
         .Line_2.BorderColor = ThisForm.nLightColor

         .Line_3.Left = 1
         .Line_3.Top = .Height - 1
         .Line_3.Width = .Width
         .Line_3.BorderColor = ThisForm.nShadowColor

         .Line_4.Left = .Width - 1
         .Line_4.Top = 1
         .Line_4.Height = .Height
         .Line_4.BorderColor = ThisForm.nShadowColor
      EndWith
   ENDPROC


   PROCEDURE MouseEnter
      LPARAMETERS nButton, nShift, nXCoord, nYCoord

      If (nButton == 0)
         With ThisForm
            If !IsNull( .oMenuActive ) and ( .oMenuActive.Name != This.Name )
               .oMenuActive = Null
            endif

            If IsNull( .oMenuActive )
               This.SetAll( 'BorderStyle', 1, 'Line' )
               .oMenuActive = This
            endif
         EndWith
      endif
   ENDPROC


   PROCEDURE MouseLeave
      LPARAMETERS nButton, nShift, nXCoord, nYCoord

      If (nButton == 0)
         This.SetAll( 'BorderStyle', 0, 'Line' )
         ThisForm.oMenuActive = Null
      endif
   ENDPROC


   PROCEDURE MouseDown
      LPARAMETERS nButton, nShift, nXCoord, nYCoord

      If (nButton == 1)
         With This
            .Line_1.BorderColor = ThisForm.nShadowColor
            .Line_2.BorderColor = ThisForm.nShadowColor
            .Line_3.BorderColor = ThisForm.nLightColor
            .Line_4.BorderColor = ThisForm.nLightColor
            .Label1.Top = .Label1.Top + 1
            .Label1.Left = .Label1.Left + 1
         EndWith
      endif
   ENDPROC


   PROCEDURE MouseUp
      LPARAMETERS nButton, nShift, nXCoord, nYCoord

      If (nButton == 1)
         With This
            .Label1.Top = .Label1.Top - 1
            .Label1.Left = .Label1.Left - 1
            .Line_1.BorderColor = ThisForm.nLightColor
            .Line_2.BorderColor = ThisForm.nLightColor
            .Line_3.BorderColor = ThisForm.nShadowColor
            .Line_4.BorderColor = ThisForm.nShadowColor
         EndWith
      endif
   ENDPROC


   PROCEDURE label1.Init
      With This
         .Top = 4
         .Left = 9
      EndWith
   ENDPROC


   PROCEDURE label1.MouseDown
      LPARAMETERS nButton, nShift, nXCoord, nYCoord

      If (nButton == 1)
         This.Parent.MouseDown( nButton, nShift, nXCoord, nYCoord )
      endif
   ENDPROC


   PROCEDURE label1.MouseUp
      LPARAMETERS nButton, nShift, nXCoord, nYCoord

      If (nButton == 1)
         This.Parent.MouseUp( nButton, nShift, nXCoord, nYCoord )
      endif
   ENDPROC


ENDDEFINE
You may want to modify it to fit your needs.
Regards
Herman
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform