Question Image Button Help Please

madhushanka

Member
Joined
Aug 8, 2010
Messages
5
Programming Experience
Beginner
Hi guys!
I'm new to this forum and this is my 1st post. Can some one tell me, how to create image buttons using these types of images
balloonbtnclosered.png
. I mean how to align them to correct position when hovering, clicking...etc Please help me

sample button image: http://img180.imageshack.us/img180/2274/balloonbtnclosered.png
balloon_btn_close_red.png
 
Do you have the image itself?

If you're talking about the Hover effect, you can use the onHover event in the picture box..

Reply ASAP
 
Is this maybe Web based project? If it's web then you can use CSS to achive what you want. I will be waiting for your confirmation and then help further. Till then Regards :)

hmm no this is for border less form (eg: kaspersky 2011)... thank you so much for caring.. :)
 
Well i doubt that PictureBox's Image property allows you to set the Image x and y by default. Maybe you should first slice the image in Photoshop and then load the slices on certain event respectively. PictureBox supports all needed events for that (MouseEnter, MouseLeave, MouseClick etc.).
 
The easiest way I can think of is along kulrom's post here. Break the image into the needed pieces (make sure they're of equal size) and swap the images around in the appropriate events.

If you're wanting this control to have focus (the user can press space or enter to cause it's click event to happen) then I would use a Button control for this, not a PictureBox.
 
finally i found the solution. but bmp's quality is bad.. hmm another issue :(

Public Sub close()
Dim imgClose = New Bitmap("Skin/Images/main_window_close.png")
Dim imglstClose As New ImageList
imglstClose.ImageSize = New Size(imgClose.Width / 4, imgClose.Height)
For I = 0 To 3
Dim BMP As Bitmap = New Bitmap(imgClose.Width / 4, imgClose.Height, Imaging.PixelFormat.Format64bppArgb)
Dim G As Graphics = Graphics.FromImage(BMP)
G.DrawImage(imgClose, New Rectangle(0, 0, imgClose.Width / 4, imgClose.Height), New Rectangle(I * (imgClose.Width / 4), 0, imgClose.Width / 4, imgClose.Height), System.Drawing.GraphicsUnit.Pixel)
imglstClose.Images.Add(BMP)
Next
End Sub
 
Back
Top