Solved

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

Posted on 2011-09-13
8
423 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
Comment Utility
Can you post your code and, better of all, the image?
0
 

Author Comment

by:stuengelman
Comment Utility
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
Comment Utility
Put a PictureBox control at the upper left and load the image in that PictureBox instead of setting it as the BackgroundImage.
0
 

Author Comment

by:stuengelman
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
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
Comment Utility
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
Comment Utility
James,

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

Great job.

Thanks, Stu
0
 

Author Closing Comment

by:stuengelman
Comment Utility
Great solution, worked perfectly.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now