images change on mouse over or click
images change on mouse over or click
images change on mouse over or click
images change on mouse over or click
images change on mouse over or click
images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click
images change on mouse over or click images change on mouse over or click
images change on mouse over or click
Go Back  Xtreme Visual Basic Talk > > > images change on mouse over or click


Reply
 
Thread Tools Display Modes
  #1  
Old 02-08-2004, 06:39 AM
SpiN9823's Avatar
SpiN9823 SpiN9823 is offline
Centurion
 
Join Date: Jan 2004
Location: New Jersey
Posts: 126
Default images change on mouse over or click


Is there a way to make images change on mouseover or click like in HTML?
Thanks,
__________________
SpiN
Reply With Quote
  #2  
Old 02-24-2004, 03:26 AM
FunkMaster FunkMaster is offline
Newcomer
 
Join Date: Feb 2004
Location: La Rioja, SPAIN
Posts: 14
Default

Quote:
Originally Posted by SpiN9823
Is there a way to make images change on mouseover or click like in HTML?
Thanks,



Yes. I am learning VB at the moment too so my answer may not be as tecnical as some of the pro's here in the forum. This is actually my first post here.

The way that I would do it is set up 2 images(PictureBoxes). The first is the normal image and the second is the rollover image. Place them one on top of the other on your form, Set 1 with visible=true and one with visible=false. Create an MouseHover event for the first picBox. The event will switch over the 'visible' property for both picBoxes. i.e. First is not visible and second is. Now create a MouseLeave event for the second picBox that switches the visibility to how they were before.

e.g.

Private Sub PictureBox7_MouseHover(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox7.MouseHover
PictureBox7.Visible = False
PictureBox8.Visible = True
End Sub

Private Sub PictureBox8_MouseLeave(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox8.MouseLeave
PictureBox7.Visible = True
PictureBox8.Visible = False
End Sub

The MouseHover assignment is not as instant as the old MouseOver event from VB6, so the user has to hover his mouse for a moment before the image changes. I don't know how to make it instant, although I have seen somewhere on the web where they made some kind of map area for the mouse on top of the image, and when the mouse enteres this area the image switches immediately. Can't remember where though.
Reply With Quote
  #3  
Old 02-29-2004, 06:28 AM
SpiN9823's Avatar
SpiN9823 SpiN9823 is offline
Centurion
 
Join Date: Jan 2004
Location: New Jersey
Posts: 126
Default

Wow. That's pretty cool. Never thought of that one. Thanks
__________________
SpiN
Reply With Quote
  #4  
Old 02-29-2004, 10:58 AM
Bucky's Avatar
Buckyimages change on mouse over or click Bucky is offline
A+ Certified Nerd

Retired Leader
* Expert *
 
Join Date: Dec 2001
Location: East Coast
Posts: 1,763
Default

Quote:
I have seen somewhere on the web where they made some kind of map area for the mouse on top of the image, and when the mouse enteres this area the image switches immediately. Can't remember where though.
Here, perhaps?
__________________
If you're not part of the solution, you're part of the precipitate.
Reply With Quote
  #5  
Old 03-01-2004, 02:05 PM
SpiN9823's Avatar
SpiN9823 SpiN9823 is offline
Centurion
 
Join Date: Jan 2004
Location: New Jersey
Posts: 126
Default

Are you sure that is .NET?
__________________
SpiN
Reply With Quote
  #6  
Old 03-01-2004, 05:50 PM
MikeJ's Avatar
MikeJimages change on mouse over or click MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

Yeah... That's .Net alright...
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #7  
Old 03-04-2004, 10:08 PM
sixiron sixiron is offline
Newcomer
 
Join Date: Mar 2004
Posts: 3
Default

Try this. You only need one picture box. You will be loading the picture to the picture box at runtime, not designtime. Put the image files in a subdirectory called images.

declare:
Public strPath As String

Form Load:
'locate directory
If Len(System.IO.Directory.GetCurrentDirectory) = 3 Then
strPath = System.IO.Directory.GetCurrentDirectory
Else
strPath = System.IO.Directory.GetCurrentDirectory & "\"
End If

PictureBox.Image() = Image.FromFile(strPath & "images/picture1.gif")
'end form load

Private Sub PictureBox_MouseHover(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox.MouseHover

PictureBox.Image() = Image.FromFile(strPath & "images/picture2.gif")

End Sub

Private Sub PictureBox_MouseLeave(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox.MouseLeave

PictureBox.Image() = Image.FromFile(strPath & "images/picture1.gif")

End Sub
Reply With Quote
  #8  
Old 03-14-2004, 09:08 PM
delonchew delonchew is offline
Newcomer
 
Join Date: Mar 2004
Posts: 1
Default

Quote:
Originally Posted by sixiron
Try this. You only need one picture box. You will be loading the picture to the picture box at runtime, not designtime. Put the image files in a subdirectory called images.

declare:
Public strPath As String

Form Load:
'locate directory
If Len(System.IO.Directory.GetCurrentDirectory) = 3 Then
strPath = System.IO.Directory.GetCurrentDirectory
Else
strPath = System.IO.Directory.GetCurrentDirectory & "\"
End If

PictureBox.Image() = Image.FromFile(strPath & "images/picture1.gif")
'end form load

Private Sub PictureBox_MouseHover(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox.MouseHover

PictureBox.Image() = Image.FromFile(strPath & "images/picture2.gif")

End Sub

Private Sub PictureBox_MouseLeave(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox.MouseLeave

PictureBox.Image() = Image.FromFile(strPath & "images/picture1.gif")

End Sub

To make the mouseover image change instant, do this:
Private Sub PictureBox_MouseEnter(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox.MouseEnter

PictureBox.Image() = Image.FromFile(strPath & "images/picture2.gif")

End Sub

instead of this:
Private Sub PictureBox_MouseHover(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles PictureBox.MouseHover

PictureBox.Image() = Image.FromFile(strPath & "images/picture2.gif")

End Sub

Hope this helps. Cheers.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help cleaning up/enhancing VBA code... HillsCap Word, PowerPoint, Outlook, and Other Office Products 6 01-26-2004 03:36 AM
help needed - start program on mouse click necro General 1 11-27-2003 04:36 AM
mouse click boolean problem necro General 1 11-20-2003 11:37 AM
mouse down / mouse up xmen64 Interface and Graphics 5 10-09-2002 10:36 AM
subject About Sendkeys & code to Right mouse click visualbasic700e General 2 11-28-2000 02:43 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
images change on mouse over or click
images change on mouse over or click
images change on mouse over or click images change on mouse over or click
images change on mouse over or click
images change on mouse over or click
images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click images change on mouse over or click
images change on mouse over or click
images change on mouse over or click
 
images change on mouse over or click
images change on mouse over or click
 
-->