Solved

Need Help Freezing a Background Image On A Dialog Box With A Vertical Scroller in VB.NET

Posted on 2011-09-13
8
426 Views
Last Modified: 2012-08-14
Hello,

I am developing a PC application using Visual Studio 2008 with Visual Basic and .NET Framework 3.5.

My main form has a button which pops a dialog box.  The dialog box has a vertical scroller.  When I scroll, the background inage is leaving traces of itself where I scroll to.  The background image only has a small design at the upper left, and the rest of it is a solid color.  The background color of the dialog box has been set to that color in case the dialog contains more content than the background image can accomodate vertically.  The background image is loaded programmatically by the handler for the button on the main form that instantiates and pops the dialog.

Any help would be appreciated.

Thanks, Stu Engelman
0
Comment
Question by:stuengelman
  • 5
  • 2
8 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 36528532
Can you post your code and, better of all, the image?
0
 

Author Comment

by:stuengelman
ID: 36528698
Hi Roland,

The code to pop the dialog is shown in the code snippet section.

The background image is attached.

The background color for the popup is set at design time.

The BackgroundImageLayout property for the popup is set to "None" at design time.

Thanks, Stu
Dim T As Type = Type.GetType(Application.ProductName & "." & dlgname, True, True)
Dim f As Form = CType(Activator.CreateInstance(T), Form)
f.BackgroundImage = Image.FromFile(apppath & "/images/popuptemplate.jpg")
f.ShowDialog(Me)

Open in new window

popuptemplate.jpg
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36529207
Put a PictureBox control at the upper left and load the image in that PictureBox instead of setting it as the BackgroundImage.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:stuengelman
ID: 36529602
Hi James,

As long as I execute a SendToBack on the PictureBox, will there be any issue trying to render content (User and native controls) over the PictureBox, continuing to use the "me" predicate in instantiating them.  The basic idea is whether or not the controls have to be children of the PictureBox.

Thanks, Stu
0
 
LVL 40
ID: 36529806
If the PictureBox is in the back, there should not be any problem. No need to attach the controls to the PictureBox, just add them to the form as usual.

But a few little design notes.

Personnally, instead of using a big image, I would have only the image of the upper left corner in a small square. By loading the small bitmap in any good drawing program, you could get the exact value to use for the blue and use it as the BackColor to take care of the blue.

Instead of loading the picture from file, I would also incorporate it in the resources in my application. You will be able to do it by importing the bitmap as a Project resource file when adding the Image to the PictureBox throught the Properties window. The image will then be incorporated in the .exe. You won't have to distribute it with your application, and are sure that it will be available and will not be modified when displaying it.

Both of those could improve loading and display time, and using a smaller bitmap may make scrolling smoother.

0
 

Author Comment

by:stuengelman
ID: 36530372
James, great ideas, thanks.

Will try everything out.

Have been working since very early AM (US EST), and may need to get some rest.  If I don't reply back today, you'll hear from me tomorrow.

Thanks again for all your help.

Stu
0
 

Author Comment

by:stuengelman
ID: 36553824
James,

Your 09/13/11 08:05 AM post solved the problem!!

Great job.

Thanks, Stu
0
 

Author Closing Comment

by:stuengelman
ID: 36553827
Great solution, worked perfectly.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question