By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

Need an images to act like a button

P: 9
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_STATICEDGE )
Sep 17 '07 #1
Share this Question
Share on Google+
12 Replies


kadghar
Expert 100+
P: 1,295
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_STATICEDGE )
I've been playing around with what you said and this seemed to work just fine:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  2. Image1.BackColor = vbBlue
  3. End Sub
  4.  
  5. Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  6. If Button = 1 Then
  7.     If X < 0 Or X > Image1.Width Or Y < 0 Or Y > Image1.Height Then
  8.         Image1.BackColor = vbWhite
  9.     Else
  10.         Image1.BackColor = vbBlue
  11.     End If
  12. Else
  13.     Image1.BackColor = vbWhite
  14. End If
  15. End Sub
  16.  
  17. Private Sub Image1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  18. Image1.BackColor = vbWhite
  19. End Sub
HTH
Sep 17 '07 #2

P: 9
Image. background?

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

No , I'm talking about something like this :
Attached Files
File Type: zip buttons problem.zip (6.3 KB, 66 views)
Sep 17 '07 #3

kadghar
Expert 100+
P: 1,295
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.backcolor, use image1.picture
Sep 17 '07 #4

P: 9
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
Sep 18 '07 #5

kadghar
Expert 100+
P: 1,295
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.Backcolor=vbBlue for image1.Picture = dummy2.Picture and,
image1.Backcolor=vbWhite for image1.Picture=dummy1.Picture

That's an easy way to assign images.
Sep 18 '07 #6

P: 9
Could you attach a file that works, because nothing works here ...
Sep 18 '07 #7

kadghar
Expert 100+
P: 1,295
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.
Sep 18 '07 #8

Expert 5K+
P: 8,434
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
File Type: zip Form1.zip (1.4 KB, 107 views)
Sep 18 '07 #9

P: 9
Very good ! ,
but can you do it to with mouseover ?
not working here ...
Sep 19 '07 #10

Expert 5K+
P: 8,434
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.
Sep 20 '07 #11

P: 1
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
Sep 20 '07 #12

Expert 5K+
P: 8,434
"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.
Sep 20 '07 #13

Post your reply

Sign in to post your reply or Sign up for a free account.