|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
set back ground image to stretchhow can i set a back ground image property on an MDI main form to stretch?
Hi again,
in .net 2003 you have to resize the image your self via code, below is an example that resizes the image and keeps the correct proportions, it shouldn't be to hard to modify the code so the image stretches over the entire form ignorig the proportions. This in fact would be less code then the sample. Hope this helps Greetz, Peter Private Sub loadimage(ByVal myFileName As String) Try Dim imgOrg As Bitmap Dim imgShow As Bitmap Dim g As Graphics Dim delenDoor, delenDoorHO, delenDoorBR As Double 'delenDoor = divide by 'delenDoorHO = divide by height 'delenDoorBR = divide by width imgOrg = DirectCast(Bitmap.FromFile(myFileName), Bitmap) 'Get the forms' dimensions delenDoorBR = imgOrg.Width / Me.ClientSize.Width delenDoorHO = imgOrg.Height / Me.ClientSize.Height If delenDoorBR > 1 Or delenDoorHO > 1 Then If delenDoorBR > delenDoorHO Then delenDoor = delenDoorBR Else delenDoor = delenDoorHO End If imgShow = New Bitmap(CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) / delenDoor)) imgShow.SetResolution(imgOrg.HorizontalResolution, imgOrg.VerticalResolution) g = Graphics.FromImage(imgShow) g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic g.DrawImage(imgOrg, New Rectangle(0, 0, CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) / delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pixel) g.Dispose() Else imgShow = New Bitmap(imgOrg.Width, imgOrg.Height) imgShow.SetResolution(imgOrg.HorizontalResolution, imgOrg.VerticalResolution) g = Graphics.FromImage(imgShow) g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic g.DrawImage(imgOrg, New Rectangle(0, 0, imgOrg.Width, imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pixel) g.Dispose() End If imgOrg.Dispose() Me.BackgroundImage = imgShow Me.Refresh() Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load 'pass the image file you want to load loadimage("c:\2_1024x768.jpg") End Sub -- Show quoteHide quoteProgramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook) "mcnewsxp" <mcour***@mindspring.com> schreef in bericht news:OtCj4ipTGHA.3976@TK2MSFTNGP10.phx.gbl... > how can i set a back ground image property on an MDI main form to stretch? > > what if the image was placed on the form in the design window?
Me.BackgroundImage ? Show quoteHide quote "Peter Proost" <pproost@nospam.hotmail.com> wrote in message news:%23t0YhSxTGHA.1868@TK2MSFTNGP09.phx.gbl... > Hi again, > > in .net 2003 you have to resize the image your self via code, below is an > example that resizes the image and keeps the correct proportions, it > shouldn't be to hard to modify the code so the image stretches over the > entire form ignorig the proportions. This in fact would be less code then > the sample. > > Hope this helps > > Greetz, Peter > > Private Sub loadimage(ByVal myFileName As String) > Try > Dim imgOrg As Bitmap > Dim imgShow As Bitmap > Dim g As Graphics > > Dim delenDoor, delenDoorHO, delenDoorBR As Double > 'delenDoor = divide by > 'delenDoorHO = divide by height > 'delenDoorBR = divide by width > > imgOrg = DirectCast(Bitmap.FromFile(myFileName), Bitmap) > > 'Get the forms' dimensions > delenDoorBR = imgOrg.Width / Me.ClientSize.Width > delenDoorHO = imgOrg.Height / Me.ClientSize.Height > > > If delenDoorBR > 1 Or delenDoorHO > 1 Then > If delenDoorBR > delenDoorHO Then > delenDoor = delenDoorBR > Else > delenDoor = delenDoorHO > End If > > imgShow = New Bitmap(CInt(CDbl(imgOrg.Width) / delenDoor), > CInt(CDbl(imgOrg.Height) / delenDoor)) > imgShow.SetResolution(imgOrg.HorizontalResolution, > imgOrg.VerticalResolution) > g = Graphics.FromImage(imgShow) > g.InterpolationMode = > Drawing2D.InterpolationMode.HighQualityBicubic > g.DrawImage(imgOrg, New Rectangle(0, 0, > CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) / > delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pixel) > g.Dispose() > Else > imgShow = New Bitmap(imgOrg.Width, imgOrg.Height) > imgShow.SetResolution(imgOrg.HorizontalResolution, > imgOrg.VerticalResolution) > g = Graphics.FromImage(imgShow) > g.InterpolationMode = > Drawing2D.InterpolationMode.HighQualityBicubic > g.DrawImage(imgOrg, New Rectangle(0, 0, imgOrg.Width, > imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pixel) > g.Dispose() > End If > imgOrg.Dispose() > > Me.BackgroundImage = imgShow > Me.Refresh() > > Catch ex As Exception > MsgBox(ex.ToString) > End Try > > End Sub > > Private Sub form1_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles MyBase.Load > 'pass the image file you want to load > loadimage("c:\2_1024x768.jpg") > End Sub > > -- > Programming today is a race between software engineers striving to build > bigger and better idiot-proof programs, and the Universe trying to produce > bigger and better idiots. So far, the Universe is winning. (Rich Cook) > > "mcnewsxp" <mcour***@mindspring.com> schreef in bericht > news:OtCj4ipTGHA.3976@TK2MSFTNGP10.phx.gbl... >> how can i set a back ground image property on an MDI main form to >> stretch? >> >> > > I think it isn't possible in 2003 to strech the backgroundimage when it's
set via the design window Greetz Peter -- Show quoteHide quoteProgramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook) "mcnewsxp" <mcour***@mindspring.com> schreef in bericht news:#AWWV62TGHA.4452@TK2MSFTNGP12.phx.gbl... > what if the image was placed on the form in the design window? > > Me.BackgroundImage ? > > "Peter Proost" <pproost@nospam.hotmail.com> wrote in message > news:%23t0YhSxTGHA.1868@TK2MSFTNGP09.phx.gbl... > > Hi again, > > > > in .net 2003 you have to resize the image your self via code, below is an > > example that resizes the image and keeps the correct proportions, it > > shouldn't be to hard to modify the code so the image stretches over the > > entire form ignorig the proportions. This in fact would be less code then > > the sample. > > > > Hope this helps > > > > Greetz, Peter > > > > Private Sub loadimage(ByVal myFileName As String) > > Try > > Dim imgOrg As Bitmap > > Dim imgShow As Bitmap > > Dim g As Graphics > > > > Dim delenDoor, delenDoorHO, delenDoorBR As Double > > 'delenDoor = divide by > > 'delenDoorHO = divide by height > > 'delenDoorBR = divide by width > > > > imgOrg = DirectCast(Bitmap.FromFile(myFileName), Bitmap) > > > > 'Get the forms' dimensions > > delenDoorBR = imgOrg.Width / Me.ClientSize.Width > > delenDoorHO = imgOrg.Height / Me.ClientSize.Height > > > > > > If delenDoorBR > 1 Or delenDoorHO > 1 Then > > If delenDoorBR > delenDoorHO Then > > delenDoor = delenDoorBR > > Else > > delenDoor = delenDoorHO > > End If > > > > imgShow = New Bitmap(CInt(CDbl(imgOrg.Width) / delenDoor), > > CInt(CDbl(imgOrg.Height) / delenDoor)) > > imgShow.SetResolution(imgOrg.HorizontalResolution, > > imgOrg.VerticalResolution) > > g = Graphics.FromImage(imgShow) > > g.InterpolationMode = > > Drawing2D.InterpolationMode.HighQualityBicubic > > g.DrawImage(imgOrg, New Rectangle(0, 0, > > CInt(CDbl(imgOrg.Width) / delenDoor), CInt(CDbl(imgOrg.Height) / > > delenDoor)), 0, 0, imgOrg.Width, imgOrg.Height, GraphicsUnit.Pixel) > > g.Dispose() > > Else > > imgShow = New Bitmap(imgOrg.Width, imgOrg.Height) > > imgShow.SetResolution(imgOrg.HorizontalResolution, > > imgOrg.VerticalResolution) > > g = Graphics.FromImage(imgShow) > > g.InterpolationMode = > > Drawing2D.InterpolationMode.HighQualityBicubic > > g.DrawImage(imgOrg, New Rectangle(0, 0, imgOrg.Width, > > imgOrg.Height), 0, 0, imgOrg.Width, imgOrg.Height, _ GraphicsUnit.Pixel) > > g.Dispose() > > End If > > imgOrg.Dispose() > > > > Me.BackgroundImage = imgShow > > Me.Refresh() > > > > Catch ex As Exception > > MsgBox(ex.ToString) > > End Try > > > > End Sub > > > > Private Sub form1_Load(ByVal sender As Object, ByVal e As > > System.EventArgs) Handles MyBase.Load > > 'pass the image file you want to load > > loadimage("c:\2_1024x768.jpg") > > End Sub > > > > -- > > Programming today is a race between software engineers striving to build > > bigger and better idiot-proof programs, and the Universe trying to produce > > bigger and better idiots. So far, the Universe is winning. (Rich Cook) > > > > "mcnewsxp" <mcour***@mindspring.com> schreef in bericht > > news:OtCj4ipTGHA.3976@TK2MSFTNGP10.phx.gbl... > >> how can i set a back ground image property on an MDI main form to > >> stretch? > >> > >> > > > > > >
Installation Error: Application validation did not succeed. Unable to continue
what is Xtreme Sample Database Data Source with ReportViewer DataGrid Custom Styles Learning - displaying selection in pictureboxes Help needed using sample RS232 class to read from serial port Small bit of code from VB6 to VB.net - desperate need of help How display Result from sqlCommand select in the Datagridview Multithreading and ActiveX Icon |
|||||||||||||||||||||||