Buttons from images (1 Viewer)

ITguy1981

Registered User.
Local time
Yesterday, 23:26
Joined
Aug 24, 2011
Messages
137
I was wondering if there is a way to layer images for the use of buttons, for example, have the first image for the button, the second image for the button highlight on mouseover, and the third image for button clicked. I've tried to use mousemove, on click, with variations of image.visible = and either get buttons disappearing and not reappearing or flickering. I realize I can use an image on a button, but I don't like being forced to have the standard square button with the same border. Maybe what i'm trying to do can be done with move the images to front or back instead of hiding the button images. Please help.
 

ITguy1981

Registered User.
Local time
Yesterday, 23:26
Joined
Aug 24, 2011
Messages
137
After plenty of searching I found the answer to my problem. This solution uses a module, 3 images for the button (up, down, and highlighted), and a cmd button. The module is long so here is a link to the site
http://www.tek-tips.com/faqs.cfm?fid=5307
 

ttomw

Registered User.
Local time
Yesterday, 20:26
Joined
Apr 13, 2012
Messages
26
After plenty of searching I found the answer to my problem. This solution uses a module, 3 images for the button (up, down, and highlighted), and a cmd button. The module is long so here is a link to the site
http://www.tek-tips.com/faqs.cfm?fid=5307

Did you have any luck getting this code working?

I get Compile error: Expected variable or procedure, not module

I have the following code in the On Form Load property:
Private Sub Form_Load()
InitButtons Me
End Sub


I tried changing the name of the module to InitButtons2 but still get the same error.

Any ideas what I am doing wrong?
Thanks.
 

ITguy1981

Registered User.
Local time
Yesterday, 23:26
Joined
Aug 24, 2011
Messages
137
Re: I did get it to work

I'm attaching a sample. First create a module. Just copy the code from my module. Create a form. Add 3 pictures that will make up your regular button, highlighted button, and on press button. All 3 pictures need to be the same size and have the same name, but the end of the name will be changed. In my example the pictures are name ITS_Up, ITS_Hover, and ITS_Down. Stack the 3 pictures on top of each other. Create a button the same size without any coding to it and make it transparent. Make sure the name of the button is the same as your images. Mine is "ITS". Also make sure the transparent button tag under "other" is "cmdbutton" without the quotes. Place the transparent button over the stacked images so they all overlap. Creat an "On Load" event procedure for the form. My procedure looks like this.

Private Sub Form_Load()
InitButtons Me
End Sub

Don't forget to add an "on click" event to the transparent button if you want it to do something when clicked.
 

Attachments

  • TestRollover.zip
    123.7 KB · Views: 109

ttomw

Registered User.
Local time
Yesterday, 20:26
Joined
Apr 13, 2012
Messages
26
I was missing the "cmdbutton" in the tag property.

Thanks Much! This works great now.
 

ITguy1981

Registered User.
Local time
Yesterday, 23:26
Joined
Aug 24, 2011
Messages
137
Glad I could help. I had an issue with the directions on the other site. Took me a while of reading through it before I found my mistakes.
 

ttomw

Registered User.
Local time
Yesterday, 20:26
Joined
Apr 13, 2012
Messages
26
Have you successfully used this technique with multiple image buttons on a form? It works for me with 1, but as soon as I add more buttons following the same recipe, I get error: Access can't find macro....

I've attached an example. This is in 2003 format as that is the required compatibility for this DB.

Do I need to add code to Initbuttons module to make this work with multiple buttons?
Thanks
 

Attachments

  • TestRolloverMultiple2003.zip
    76.9 KB · Views: 107

ITguy1981

Registered User.
Local time
Yesterday, 23:26
Joined
Aug 24, 2011
Messages
137
I've not had much time to look at the database, but I tested original code from what I used with two buttons and it worked fine. I have a feeling the error is possibly related to the module code and Acess 2003. I'm going to work a little more with your example now to see if I can pinpoint the issue.
 

ITguy1981

Registered User.
Local time
Yesterday, 23:26
Joined
Aug 24, 2011
Messages
137
The issue is your command button. Whatever command or how you created the command button is wrong. Typically, I use the add button option, click on the form, and then cancel so I'm just left with a default command button. I then set it to transparent and set the height and width. Then make sure to add the "cmdbutton" in the tag and set the name of the button to match the other pictures that were used. You can always go in and create your on click events after you know module is working properly.
 

ITguy1981

Registered User.
Local time
Yesterday, 23:26
Joined
Aug 24, 2011
Messages
137
I forgot to mention that your test form worked by deleting the command button and creating a new one. Did you have any macros or anything attached to the command button yet? If so, I would try deleting the command button as I did and making a new one and adding the code after you see that the button works.
 

Simon_MT

Registered User.
Local time
Today, 04:26
Joined
Feb 26, 2007
Messages
2,176
All you can really do is change the Image on GotFocus or LostFocus. I do not believe that there is a Property Event [Hover]. As it a 2003 formatted database you can only use bitmaps rather than proper images.

You would be better to use on GotFocus/LostFocus Events and use OnClick for actual events.

Here is some the code, obviously you will have to specify the image files:
Code:
Private Sub Test2_GotFocus()
    Me.Test2.Picture = "C:\Databases\Test\Menu_Prints_Large_focus.bmp"
End Sub

Private Sub Test2_LostFocus()
    Me.Test2.Picture = "C:\Databases\Test\Menu_Prints_Large_lost.bmp"
End Sub

Simon
 

Users who are viewing this thread

Top Bottom