Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-13
8
Medium Priority
?
450 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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 response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

876 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