Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Commandbutton rollover (A2K)

    Is it possible for me to make my commandbuttons work like the buttons on the toolbars where they are "flat" until the mouseover at which time they are "raised" (the border turns on)?

    I can't seem to find any border properties on commandbuttons.

    TIA
    Donald

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Commandbutton rollover (A2K)

    Rather than use command buttons, you would have to use labels. You have Style property set to flat, then set it to Raised in the MouseMove event. The problem is, however, knowing when to make it flat again.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Commandbutton rollover (A2K)

    You can also use an Image control if you want to see a button picture rather than a text label.

    I generally do this using classes, but you could do the same thing by creating a routine in your form's module and calling it from the Mousemove event of each label or image control you want to see this behavior for.

    You would need a module level variable to keep track of what the name of "current" control (label or image) is so that you can set that one's special effect back to flat when you set the new "current" control's special effect to raised.

    Here's a routine I used for this purpose in one of my applications, although this is a routine in a standard module that is simply called from the MoveMove event of the image controls on a form. I declared the following public constants to make it, and the MouseUp and MouseDown routines work:

    Global Const OBJ_FLAT = 0
    Global Const OBJ_RAISED = 1
    Global Const OBJ_SUNKEN = 2


    <pre>Public Sub ImageMouseMove(OLECurrent As Image, _
    ByVal Button As Long, _
    ByVal Shift As Integer, _
    ByVal X As Single, _
    ByVal Y As Single)
    Dim frm As Form
    Dim strCurrentButton As String

    Set frm = OLECurrent.Parent
    strCurrentButton = frm.CurrentButton
    If strCurrentButton <> OLECurrent.Name Then
    If strCurrentButton <> "" Then
    frm(strCurrentButton).SpecialEffect = OBJ_FLAT
    End If
    frm.CurrentButton = OLECurrent.Name
    If frm.CurrentButton <> "OLEReset" Then
    OLECurrent.SpecialEffect = OBJ_RAISED
    End If
    End If
    Set frm = Nothing
    End Sub 'ImageMouseMove(OLECurrent As Image, _
    ByVal Button As Long, _
    ByVal Shift As Integer, _
    ByVal X As Single, _
    ByVal Y As Single)</pre>


    Of course, if you want to see the apparent effect of clicking the "buttons", you'll have to add code to the MouseUp and MouseDown events as well. The MouseDown event would set the control's special effect to Sunken, while the MouseUp event would set it to Raised.
    Charlotte

  4. #4
    2 Star Lounger
    Join Date
    Dec 2000
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Commandbutton rollover (A2K)

    Charlotte,
    I started working with this code but ran into a problem with the line

    frm.CurrentButton

    Everything I find in MSDN says CurrentButton has something to do with the media player.

    Can you enlighten me on this please?
    TIA
    Donald

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Commandbutton rollover (A2K)

    Oops! <img src=/S/blush.gif border=0 alt=blush width=15 height=15> I inadvertently left out specific instructions on that. I only posted that piece of code as a '"for instance", and not as a complete routine.
    <hr>You would need a module level variable to keep track of what the name of "current" control (label or image) is so that you can set that one's special effect back to flat when you set the new "current" control's special effect to raised<hr>
    ... actually means that you need to add a public property to your form module. Declare CurrentButton as a public string, which will make it available outside the form module. Then in the Click event of each image control, set the CurrentButton property to the name of that control.

    Actually, I just finished building a demo where the form uses labels and image controls rather than buttons. This allows you to create virtual toolbars on modal popup forms where there's no access to either built-in or custom toolbars. I'm going to attach it to this message so you can see how the whole thing works.
    Attached Files Attached Files
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •