User Interface in VB 2005

S

Saber

Where can I find articles about UI?
Specially:
1) using actions like hover effects.
2) communications between a SWF file and a VB application.

I'm using this code to simulate an effect, but it is heavy:

Private Sub pb1_MouseEnter(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles pb1.MouseEnter, pb2.MouseHover, pb3.MouseHover

Dim pb As PictureBox = sender
For Each c As Control In Me.Controls
If Not c Is pb Then pb1_MouseLeave(c, e)
Next
pb.BorderStyle = BorderStyle.Fixed3D
End Sub

Private Sub pb1_MouseLeave(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles pb1.MouseLeave, pb2.MouseLeave, pb3.MouseLeave

Dim pb As PictureBox = sender
pb.BorderStyle = BorderStyle.None

End Sub

'NOTE: there are only picture boxes on the form.

Any idea to do it using it a better way?

Thanks
 
A

Armin Zingler

"Saber" <saber[.AT.]oxin.ir> schrieb>
No idea?

You didn't write what the problem was, only that it is "heavy". I didn't
know what it meant.
How can I make image switching faster and reduce the delay?

Which images do you want to switch? Which delay is there?


Shouldn't this be

Handles pb1.MouseEnter, pb2.MouseEnter, pb3.MouseEnter


Armin
 
S

Saber

Thank for your response Armin,
I've three picture box, when user hovers on a picture box,
I want the picture changes and when the mouse leaves picture box,
the old picture load in picture box again.
It is easy in HTML:
http://www.howtocreate.co.uk/tutorials/jsexamples/testingRoll.html
but it causes a delay to change the pictures in VB when a mouse event
occurs. (at least by my method!)
I want a good way to simulate HTML mouseover/hover/rolling effect in VB.
Shouldn't this be

Handles pb1.MouseEnter, pb2.MouseEnter, pb3.MouseEnter

That was a cut/paste error, it is:
Handles pb1.MouseHover, pb2.MouseHover, pb3.MouseHover

--
Saber S.
http://maghalat.com

Armin Zingler said:
"Saber" <saber[.AT.]oxin.ir> schrieb>
No idea?

You didn't write what the problem was, only that it is "heavy". I didn't
know what it meant.
How can I make image switching faster and reduce the delay?

Which images do you want to switch? Which delay is there?


Shouldn't this be

Handles pb1.MouseEnter, pb2.MouseEnter, pb3.MouseEnter


Armin
 
A

Armin Zingler

Saber said:
Thank for your response Armin,
I've three picture box, when user hovers on a picture box,
I want the picture changes and when the mouse leaves picture box,
the old picture load in picture box again.
It is easy in HTML:
http://www.howtocreate.co.uk/tutorials/jsexamples/testingRoll.html
but it causes a delay to change the pictures in VB when a mouse
event occurs. (at least by my method!)
I want a good way to simulate HTML mouseover/hover/rolling effect in
VB.

How much delay is it (approximate)? 200 ms, 500 ms, 1000 ms, 5000 ms - just
to get an imagination of it.

How do you set the picture? It was not shown in your code.

I tried it and can't see any noticable delay. Not even with 1280x1024
bitmaps with picbox.sizemode = strechimage. This is the code:

Private Sub PictureBox_MouseEnter( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles PictureBox1.MouseEnter, PictureBox2.MouseEnter, _
PictureBox3.MouseEnter

DirectCast(sender, PictureBox).Image = Me.PictureBox4.Image

End Sub

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

DirectCast(sender, PictureBox).Image = Me.PictureBox5.Image
End Sub


PictureBox1, PictureBox2 and PictureBox3 are also 3 Pictureboxes.
PictureBox4 and PictureBox5 are only there to contain the picture (was the
simplest way to create a sample using the designer).

Armin
 
S

Saber

Approximately delay is 500 ms, I use small transparent gif images (2 KB)
added to resource.
I'll send the source code and images to your email address.

Thanks
 
A

Armin Zingler

Saber said:
Approximately delay is 500 ms, I use small transparent gif images (2
KB) added to resource.
I'll send the source code and images to your email address.

Insert an underscore: az.no_spam@....


Armin
 
A

Armin Zingler

Saber said:
Approximately delay is 500 ms, I use small transparent gif images (2
KB) added to resource.
I'll send the source code and images to your email address.


Took some time to get a compilable project from the files you sent. I can't
see any delay when hovering over the picboxes (Athlon 64 3000+, GF 6800).
What you can try is to load the resources only once, not each time you
change the image.


Armin
 
S

Saber

Sorry for inconvenience!
I'm using Athlon 1800+, GF MX 440.
What you can try is to load the resources only once, not each time you
change the image.
Would you please explain more about it?
 
A

Armin Zingler

Saber said:
Sorry for inconvenience!

No problem. Did it voluntarily. :)
I'm using Athlon 1800+, GF MX 440.

Would you please explain more about it?


Each time you assign the image to the picturebox, you are referring to
"my.resources.*". This means that each time the image resource must be
loaded. On very slow PCs this might cause a delay. Your PC is not too slow
for this job, thus this is not the cause. To optimize the code, you could
load all images into an array or hashtable or other variables only at
startup, e.g. in form_load. When hovering over the pictureboxes, you will
already have the images in the variables. You don't have to load them each
time from the resource. But as I said, I don't think this will matter with
your machine; only if it was much slower (IMO, "old" machines are 500 MHz or
less; that's my personal limit). Therefore, I currently don't know what is
causing the delay. Anybody else can help?


Armin
 
S

Saber

Armin,

I did your tip and now using an array to keep images when form loads,
as you mentioned, it is not the reason of the delay problem, but logical!

still waiting for ideas..
 
S

Saber

I Finaly found the reason of problem:
Me.BackgroundImage = Global.pezeshki.My.Resources.Resources.bgmain1

after removing the background, there is no delay in hover effect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top