|
-
Dec 21st, 2006, 11:55 AM
#1
Thread Starter
New Member
HELP ME PLZ<<URGENT
I HAV TWO QUESTIONS ( I AM USING VB.NET2003)
1- HOW CAN I MAKE THE BACKGROUNDIMAGE OF THE FORM NOT TO BE TILE ,, I WANT IT TO BE STRECH (IN THE CENTER)
2- IF I HAVE A BUTTON AND A PICTUREBOX IN A FORM ,, HOW CAN I PRINT THE PICTURE ONLY (NOT THE FULL FORM) WHEN CLICKING ON THE BUTTON.
THX
-
Dec 21st, 2006, 01:15 PM
#2
Re: HELP ME PLZ<<URGENT
Answers for:
1. Set your form's BackgroundImageLayout property to "Stretch".
2. You need to use a PrintDocument component, and do the printing in the PrintPage event.
-
Dec 21st, 2006, 02:35 PM
#3
Thread Starter
New Member
Re: HELP ME PLZ<<URGENT
WHERE CAN I GET THE BackgroundImageLayout property , I'M NOT GETTING IT IN VB.NET2003
(You need to use a PrintDocument component, and do the printing in the PrintPage event)
COULD YOU EXPLAIN MORE?? CUZ I DIDN'T USE THIS COMPONENT EVER
-
Dec 21st, 2006, 04:33 PM
#4
Re: HELP ME PLZ<<URGENT
Didn't pay attention to your vb.net version on the first post.... For VB.Net 2003, you pretty much have to resize the background image yourself. And here is one way of doing it (Assuming that you already set your form's backgroundimage property to some image, now you just need to handle the resize in form load and form resize events)
VB Code:
Private bgImage As Image = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
bgImage = Me.BackgroundImage
StretchBackground()
End Sub
Private Sub Form1_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Resize
If Not Me.WindowState = FormWindowState.Minimized Then
StretchBackground()
End If
End Sub
Private Sub StretchBackground()
If Not bgImage Is Nothing Then
Me.BackgroundImage = ResizeImage(bgImage, _
Me.ClientSize.Width, _
Me.ClientSize.Height)
End If
End Sub
Private Function ResizeImage(ByVal img As Image, _
ByVal width As Integer, _
ByVal height As Integer) As Bitmap
Dim bm As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(bm)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(img, 0, 0, width, height)
Return bm
End Function
For using a PrintDocument, you can search the forum... There are already many examples on it, so I don't want to reinvent the wheel
-
Dec 22nd, 2006, 12:40 AM
#5
Thread Starter
New Member
Re: HELP ME PLZ<<URGENT
Thx Alot, But The Img Is Is Still Tile At The Design Time , It Is Strech Only When Running The Program, ( And Actually I Need To Assign Some Transparent Lables On Specific Locations On The Image)
-
Dec 22nd, 2006, 10:22 AM
#6
Re: HELP ME PLZ<<URGENT
To stretch it at design time, you will simply need to size the image correctly for the form, and paste it on. I don't think there is a way to automate this, as I can't see any reason why there should be.
My usual boring signature: Nothing
 
-
Dec 22nd, 2006, 10:31 AM
#7
Re: HELP ME PLZ<<URGENT
why not something like this
VB Code:
Private _BGImage As Image = Image.FromFile("c:\bgimage.jpg")
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.DrawImage(_BGImage, e.ClipRectangle)
End Sub
Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
Me.Invalidate()
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|