Solved

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

Posted on 2011-09-13
8
424 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
 

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

863 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

25 Experts available now in Live!

Get 1:1 Help Now