Jump to content

image button problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
14 replies to this topic

#1
ikkeugh

ikkeugh

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
Hello , 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 .

Attached Files



#2
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
Try using the PictureBox instead of Image. On the mousedown/move part... You have to have code in the move that checks to see if you're holding the button down. I can think of many ways to accomplish this. Such as using a global variable to determine mouse down or up in the picturebox, then on the Move check the variable to see if down or up. Just a helpful suggestion.
Option Explicit
:cool:

#3
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
If you post the code I might have a better look at the code and perhaps help you.

#4
ikkeugh

ikkeugh

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
sure

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Image1.Picture = Big2.Picture

Image2.Picture = Minimize2.Picture

Image3.Picture = Exit2.Picture

End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Image1.Picture = Big1.Picture

Image2.Picture = Minimize2.Picture

Image3.Picture = Exit2.Picture

End Sub

Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Image1.Picture = Big3.Picture

End Sub

Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

MsgBox "hi"

End Sub

Private Sub Image2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Image1.Picture = Big2.Picture

Image2.Picture = Minimize1.Picture

Image3.Picture = Exit2.Picture

End Sub

Private Sub Image2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Image2.Picture = Minimize3.Picture

End Sub

Private Sub Image2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

WindowState = 1

End Sub

Private Sub Image3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Image1.Picture = Big2.Picture

Image2.Picture = Minimize2.Picture

Image3.Picture = Exit1.Picture

End Sub

Private Sub Image3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Image3.Picture = Exit3.Picture

End Sub

Private Sub Image3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Unload Me

End Sub
I came up with this !!!
There are three buttons , maximize : big :p
minimize and exit

#5
ikkeugh

ikkeugh

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
Wouldn't it be beter if it could be

If ((x-coördinate is bigger then mage begin x coördinate)
and (x-coördinate is smaller then image end x coördinate)
and (y-coördinate is bigger then mage begin y coördinate)
and (y-coördinate is smaller then image end y coördinate)) then
If (the mouse is pressed down on image ) then
Image1.Picture = Down.Picture
If (the mouse is in up position)
Unload Me 'do action : for example Unload Me
end if
Else
Image1.Picture = Over.Picture
End If
Else
Image1.Picture = Up.Picture
End If

But how to do this ?

#6
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Just a suggestion and I didn't try it out, but try using Form_DragOver and in there make the code to get the button back to normal.

#7
ikkeugh

ikkeugh

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
that's not working

But how to write the code :
If ((x-coördinate is bigger then mage begin x coördinate)
and (x-coördinate is smaller then image end x coördinate)
and (y-coördinate is bigger then mage begin y coördinate)
and (y-coördinate is smaller then image end y coördinate)) then
If (the mouse is pressed down on image ) then
Image1.Picture = Down.Picture
If (the mouse is in up position)
Unload Me 'do action : for example Unload Me
end if
Else
Image1.Picture = Over.Picture
End If
Else
Image1.Picture = Up.Picture
End If

#8
ikkeugh

ikkeugh

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
Let's start with the problem :
I need something like this :

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

' X= horizontal mouse position

' Y=vertical mouse position

Label1.Caption = X

Label2.Caption = Y

End Sub
(needs 2 labels , and 1 button )

But when you hold the button down , the labels don't change , because it's a form-mousemouve .

It's something with
Private Type PointAPI

    X As Long

    Y As Long

End Type


#9
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well I tested it, ok so... Add a Timer and try this code:

Private Declare Function GetCursorPos Lib "user32" (lpPoint As _
   POINTAPI) As Long

Private Type POINTAPI
        X As Long
        Y As Long
End Type
Dim Pointer As POINTAPI

Private Sub Form_Load()
Timer1.Interval = 1
End Sub

Private Sub Timer1_Timer()
ret = GetCursorPos(Pointer)
Xaxis = Pointer.X
Yaxis = Pointer.Y
Label1.Caption = Xaxis
Label2.Caption = Yaxis
End Sub



This should work, but it will display your mouse X and Y axis even if your mouse is OUTSIDE the form!

#10
ikkeugh

ikkeugh

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
Can you also do that for :
When you hold down your mouse , you know the x-coördinate and the y-coördinate . And it stays the same untill you lift the mouse up again .

#11
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
Well now you are confusing me.. If I understood well your problem was that you did not want that to happen.. right?

#12
ikkeugh

ikkeugh

    Learning Programmer

  • Members
  • PipPipPip
  • 79 posts
Just to know the position of the click , even if you move the cursor.
I'm looking for an api for this .
(Why does everyone want to avoid api calls ?)