Need an images to act like a button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ikkeugh
    New Member
    • Sep 2007
    • 9

    Need an images to act like a button

    I need an images to act like a button ,
    In the button's properties , you have the option to set an downpicture , so
    If you push the button , there appears an image .
    BUT when you hold the mouse down and move the cursor away from the button , it returns to it's origional state .

    And if you do it with an image and mousedown option , it stays in that state .

    So , is there an solution for the images ?
    So it would change back again .
    Or could you change the style of the button so it wouldn't look like a button no more .and it would appear to be an image .

    (PS. how do I change the exe style to WS_EX_STATICEDG E )
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by ikkeugh
    I need an images to act like a button ,
    In the button's properties , you have the option to set an downpicture , so
    If you push the button , there appears an image .
    BUT when you hold the mouse down and move the cursor away from the button , it returns to it's origional state .

    And if you do it with an image and mousedown option , it stays in that state .

    So , is there an solution for the images ?
    So it would change back again .
    Or could you change the style of the button so it wouldn't look like a button no more .and it would appear to be an image .

    (PS. how do I change the exe style to WS_EX_STATICEDG E )
    I've been playing around with what you said and this seemed to work just fine:

    [CODE=vb]Private Sub Image1_MouseDow n(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Image1.BackColo r = vbBlue
    End Sub

    Private Sub Image1_MouseMov e(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Button = 1 Then
    If X < 0 Or X > Image1.Width Or Y < 0 Or Y > Image1.Height Then
    Image1.BackColo r = vbWhite
    Else
    Image1.BackColo r = vbBlue
    End If
    Else
    Image1.BackColo r = vbWhite
    End If
    End Sub

    Private Sub Image1_MouseUp( ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Image1.BackColo r = vbWhite
    End Sub[/CODE]

    HTH

    Comment

    • ikkeugh
      New Member
      • Sep 2007
      • 9

      #3
      Image. background?

      =>works just fine for buttons , but not for images ...

      No , I'm talking about something like this :
      Attached Files

      Comment

      • kadghar
        Recognized Expert Top Contributor
        • Apr 2007
        • 1302

        #4
        Originally posted by ikkeugh
        Image. background?

        =>works just fine for buttons , but not for images ...

        No , I'm talking about something like this :
        use that code, but instead of changing the background color change the image in it.

        instead of writing image1.backcolo r, use image1.picture

        Comment

        • ikkeugh
          New Member
          • Sep 2007
          • 9

          #5
          Well , I used a down picture for the button
          (it's an option in properties , doesn't work for images )
          Only in the button's properties

          Comment

          • kadghar
            Recognized Expert Top Contributor
            • Apr 2007
            • 1302

            #6
            Originally posted by ikkeugh
            Well , I used a down picture for the button
            (it's an option in properties , doesn't work for images )
            Only in the button's properties
            Create a couple of dummy images, set them visible=false. One will be called dummy1, the other will be dummy2. Dummy1 will have in it the up picture, Dummy2 will have the down picture.

            Change:
            image1.Backcolo r=vbBlue for image1.Picture = dummy2.Picture and,
            image1.Backcolo r=vbWhite for image1.Picture= dummy1.Picture

            That's an easy way to assign images.

            Comment

            • ikkeugh
              New Member
              • Sep 2007
              • 9

              #7
              Could you attach a file that works, because nothing works here ...

              Comment

              • kadghar
                Recognized Expert Top Contributor
                • Apr 2007
                • 1302

                #8
                Originally posted by ikkeugh
                Could you attach a file that works, because nothing works here ...
                I see what you mean, I tried that code with images but they didn't change every time, only when they wanted to.

                I'll check it out.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  Here's one I've just created in VB6. It works, as far as I can tell.

                  Sorry, I was in a rush so there aren't a lot of comments, and I just grabbed two stock images that came with VB, so they don't look so good. But you can easily fix that.
                  Attached Files

                  Comment

                  • ikkeugh
                    New Member
                    • Sep 2007
                    • 9

                    #10
                    Very good ! ,
                    but can you do it to with mouseover ?
                    not working here ...

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Originally posted by ikkeugh
                      Very good ! ,
                      but can you do it to with mouseover ?
                      not working here ...
                      Not sure what you mean. That code was designed to make the image act like a button, as requested. And it worked on my PC.

                      Comment

                      • baranwalravi123
                        New Member
                        • Sep 2007
                        • 1

                        #12
                        its urgent

                        hi i have used the code that u have given but got an error as
                        i am using it in the activex control
                        "Procedure declaration does not match description of event or procedure having the same error"
                        please help the solution as soon as possible
                        thanks

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          Originally posted by baranwalravi123
                          "Procedure declaration does not match description of event or procedure having the same error"
                          Hm... I'm going to take a stab in the dark and say that you probably used the code for a control which is part of an array, so the procedure declaration (the Sub statement) needs an Index parameter.

                          Comment

                          Working...