Programming language: Visual C# .Net
Hello!
My program have a form with a listbox, combobox, progressbar, groupbox and labels.
I want to have a background image (jpg) over the entire form.
The other controls have been set to Transparent BackColor.
BackgroundImage property isn't so good solution I think.
My program flicker if I open it or if another program is over and I set focus on my program.
Both the picture and all the other controls on the form flicker.
Can someone give me a better or perfect solution what I can do?
Should I use GDI or directx, how to do that?
Thanks!
Loading
mr.storkPosted Oct 4, 2005, 4:15 AM
Sondre GarmoPosted Aug 28, 2005, 3:47 PM
Here is how I do it.
//=================================================
public Form()Bitmap Background, BackgroundTemp;
{
// // Required for Windows Form Designer support //InitializeComponent();
initialize();
}
protected override void Dispose( bool disposing ){
if( disposing ){
if (components != null){
components.Dispose();
}
}
base.Dispose( disposing );BackgroundTemp.Dispose();
Background.Dispose();
}
private void initialize(){
SetStyle(ControlStyles.UserPaint,
true);SetStyle(ControlStyles.AllPaintingInWmPaint,
true);SetStyle(ControlStyles.DoubleBuffer,
true); string AppPath = Application.StartupPath;BackgroundTemp =
new Bitmap(@AppPath + "\\Backgroundimages\\Main.jpg");Background =
new Bitmap(BackgroundTemp, BackgroundTemp.Width, BackgroundTemp.Height);}
protected override void OnPaint(PaintEventArgs e){
Graphics dc = e.Graphics;
dc.DrawImageUnscaled(Background,0,0);
base.OnPaint(e);}
//==============================================
Mike GoldPosted Aug 19, 2005, 12:47 AM
Add this to your form constructor after initialization
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
-Mike G.