I've been searching around for a simple way to display a background
image in my MDI form's client area.
I want to be able to load the image from file on start up
and have it resize as the MDI form is resized.
It's the resizing part that I am having trouble with.
I've seen a few old posts that point in the right direction but
nothing simple.
I wondered if they has been any new ideas I have missed.
Working with an MDI child form is easy and the following code works a
treat.
Public Class Form2
Inherits System.Windows. Forms.Form
Private newImage As Image =
Image.FromFile( "D:\Pics\Backgr ound.bmp")
Private Sub Form2_Paint(ByV al sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
' Create a rectangle the size of the child form.
Dim destRect As New Rectangle(1, 1, Me.ClientSize.W idth,
Me.ClientSize.H eight)
' Draw image to screen.
e.Graphics.Draw Image(newImage, destRect)
End Sub
End Class
Is there anything as simple for the MDI form?
Failing that, anything at all that works?
Thank you in advance.
Matt 8 9269
"Matt" <mt*****@gladst onemrm.com> schrieb: I've been searching around for a simple way to display a background image in my MDI form's client area. I want to be able to load the image from file on start up and have it resize as the MDI form is resized. [...] Is there anything as simple for the MDI form? Failing that, anything at all that works?
Customizing the MDI frame background
<URL:http://www.bobpowell.n et/mdiback.htm>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
"Matt" <mt*****@gladst onemrm.com> schrieb: I've been searching around for a simple way to display a background image in my MDI form's client area. I want to be able to load the image from file on start up and have it resize as the MDI form is resized. [...] Is there anything as simple for the MDI form? Failing that, anything at all that works?
Customizing the MDI frame background
<URL:http://www.bobpowell.n et/mdiback.htm>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Hi Matt
The general technique is highlighted very well at Bob Powell's site: http://www.bobpowell.net/mdiback.htm
I've written the code that follows, and it works, but there is horrible
flashing when you resize - the background of the MdiClient control is painted
first, followed by the drawing of the Image on top. I can't see a way to
suppress the drawing of the background though - any ideas out there?
Hope it's some help anyway...
Nigel Armstrong
Code (Form called Form1.vb, with IsMdiContainer set to true...) :
Dim b As Bitmap
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' probably better to load this from a resource file, but this works for a
demo!
b = New Bitmap("C:\test .jpg")
For Each c As Control In Me.Controls
' Find the MdiClient control
If TypeOf c Is MdiClient Then
' Add in handlers for resize and paint
AddHandler c.Paint, AddressOf MyPaint
AddHandler c.SizeChanged, AddressOf MySizeChanged
End If
Next
End Sub
' Here are the handlers
Private Sub MyPaint(ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs)
e.Graphics.Draw Image(b, 0, 0, Me.ClientSize.W idth,
Me.ClientSize.H eight)
End Sub
Private Sub MySizeChanged(B yVal sender As Object, ByVal e As
System.EventArg s)
Me.Invalidate()
End Sub
"Matt" wrote: I've been searching around for a simple way to display a background image in my MDI form's client area. I want to be able to load the image from file on start up and have it resize as the MDI form is resized.
It's the resizing part that I am having trouble with.
I've seen a few old posts that point in the right direction but nothing simple. I wondered if they has been any new ideas I have missed.
Working with an MDI child form is easy and the following code works a treat.
Public Class Form2 Inherits System.Windows. Forms.Form
Private newImage As Image = Image.FromFile( "D:\Pics\Backgr ound.bmp")
Private Sub Form2_Paint(ByV al sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
' Create a rectangle the size of the child form. Dim destRect As New Rectangle(1, 1, Me.ClientSize.W idth, Me.ClientSize.H eight)
' Draw image to screen. e.Graphics.Draw Image(newImage, destRect) End Sub End Class
Is there anything as simple for the MDI form? Failing that, anything at all that works?
Thank you in advance.
Matt
Hi Matt
The general technique is highlighted very well at Bob Powell's site: http://www.bobpowell.net/mdiback.htm
I've written the code that follows, and it works, but there is horrible
flashing when you resize - the background of the MdiClient control is painted
first, followed by the drawing of the Image on top. I can't see a way to
suppress the drawing of the background though - any ideas out there?
Hope it's some help anyway...
Nigel Armstrong
Code (Form called Form1.vb, with IsMdiContainer set to true...) :
Dim b As Bitmap
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
' probably better to load this from a resource file, but this works for a
demo!
b = New Bitmap("C:\test .jpg")
For Each c As Control In Me.Controls
' Find the MdiClient control
If TypeOf c Is MdiClient Then
' Add in handlers for resize and paint
AddHandler c.Paint, AddressOf MyPaint
AddHandler c.SizeChanged, AddressOf MySizeChanged
End If
Next
End Sub
' Here are the handlers
Private Sub MyPaint(ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs)
e.Graphics.Draw Image(b, 0, 0, Me.ClientSize.W idth,
Me.ClientSize.H eight)
End Sub
Private Sub MySizeChanged(B yVal sender As Object, ByVal e As
System.EventArg s)
Me.Invalidate()
End Sub
"Matt" wrote: I've been searching around for a simple way to display a background image in my MDI form's client area. I want to be able to load the image from file on start up and have it resize as the MDI form is resized.
It's the resizing part that I am having trouble with.
I've seen a few old posts that point in the right direction but nothing simple. I wondered if they has been any new ideas I have missed.
Working with an MDI child form is easy and the following code works a treat.
Public Class Form2 Inherits System.Windows. Forms.Form
Private newImage As Image = Image.FromFile( "D:\Pics\Backgr ound.bmp")
Private Sub Form2_Paint(ByV al sender As Object, ByVal e As System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
' Create a rectangle the size of the child form. Dim destRect As New Rectangle(1, 1, Me.ClientSize.W idth, Me.ClientSize.H eight)
' Draw image to screen. e.Graphics.Draw Image(newImage, destRect) End Sub End Class
Is there anything as simple for the MDI form? Failing that, anything at all that works?
Thank you in advance.
Matt
Thanks guys,
I'm sure it will do the job.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Thanks guys,
I'm sure it will do the job.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Works really well Nigel, thanks.
The flashing is odd though but not a big deal.
If time allows I'll mess about with it.
Let me know if you come up with anything.
Thanks again.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Works really well Nigel, thanks.
The flashing is odd though but not a big deal.
If time allows I'll mess about with it.
Let me know if you come up with anything.
Thanks again.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Theodore A. Jencks |
last post by:
Hi all,
I posted a question about a side navigation bar earlier where I was
encountering this problem. I thought I'd repost the question in a more
general format because I'm not sure people quite understood what I was
asking in my last post. Here is what I'd like to do:
1. Have a div tag that's soul purpose is to display a repeating background
image in the y-axis.
2. The div tag should also have a fixed width.
|
by: Greg Heilers |
last post by:
Hello everyone...
If one has a <div> that is completely filled with a
background-image; how does one style it so that the
image *continues* to fill the <div> top-to-bottom,
left-to-right; if the viewer adjusts the font-size
on his browser? I have everything sized in em's,
so that the actual <div> "box" resizes along with the
text, but the background-image will not resize if the
text is "zoomed". I can not find anything pertaining
|
by: Aku |
last post by:
Hello,
In my C# app I put a background image (.jpg) via the Properties
attributes.
The image appears several times, tiled - so if you resized the dialog,
more will appear!
This is not what I wanted; I meant to get one image, and it should be
stretched to full window size and automaticallly resize along with the
form.
Can you advise me please.
|
by: Matt |
last post by:
I've been searching around for a simple way to display a background
image in my MDI form's client area.
I want to be able to load the image from file on start up
and have it resize as the MDI form is resized.
It's the resizing part that I am having trouble with.
I've seen a few old posts that point in the right direction but
nothing simple.
I wondered if they has been any new ideas I have missed.
|
by: Patrick |
last post by:
Hi All,
I am trying more and more to incorporate CSS into my work here. I have
currently been playing around with fluid design and tableless layout.
Currently I am trying to make a background image show up in a div that
is designated by an id. The image is not appearing and after doing some
googling I'm still a bit lost. Is it possible to display a background
image in a div ID? Can someone school me a bit on this? I have supplied
a...
| |
by: paul.denlinger |
last post by:
Hi--
Things have gone well for me on this page design, but when I added a
background image, it pushed everything down and messed up my page
layout.
Before I added the navigation background image, here is the CSS code:
body {
font-family:Verdana, Arial, Helvetica, sans-serif;
|
by: swc76801 |
last post by:
I desperately need help. My understanding of CSS is non-existent. I have a store http://astore.amazon.com/texasheat-20 with Amazon.com. According to the information from Amazon.com "Write your own overriding CSS to customize your aStore." Their setup page is divided into two sections. On the right they show the existing CSS. On the left there is a box where you can add the new code. They have tabs for "Global", "Category Page", "Detail Page",...
|
by: summiyashaheen |
last post by:
i want the button to resize on a window form in vb.net when the window is maximized or resotered. there is an image as background. buttons are placed according to the image parts. when the window is maximized, image portion expands but the buttin size is fixed. how to fix the size of the button according to the image portion.......
|
by: ramesh1210 |
last post by:
Hi all,
Actually my requirement is to place an image in the text box and it should stand over the data in the text box.
And i made it as
------------------------------------------------------------------------------------------
<html>
<head>
<style>
.formlabel
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |