chevronrod
asked on
Double buffering produces 'PARAMETER NOT VALID' in Program code.
I'm trying to double buffer a form. I want to draw a bitmap on it for now. My goal is to get several bitmaps all moving around on the screen: that's why i want the double buffering.
IT WORKS ABSOLUTELY PERFECTLY without the Double Buffering.
When I set the Double Buffering property of the form, I get the error listed at the bottom fo this description.
I've set the form's Double Buffering property to true. Here is the code for the form. It's pretty simple right now as I test this:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --------
using System;
using System.Collections.Generic ;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Graphics objGraphics = e.Graphics)
{
System.Reflection.Assembly thisExe;
thisExe = System.Reflection.Assembly .GetExecut ingAssembl y();
System.IO.Stream file = thisExe.GetManifestResourc eStream("W indowsAppl ication1.R esources.L .png");
Size size = new Size(40, 40);
Bitmap newbitmap = new Bitmap(Image.FromStream(fi le), size);
e.Graphics.DrawImage(newbi tmap, new Point(40, 40));
//Dispose of the image files.
newbitmap.Dispose();
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------
Here is the Program code.
using System;
using System.Collections.Generic ;
using System.Windows.Forms;
namespace WindowsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualSt yles();
Application.SetCompatibleT extRenderi ngDefault( false);
Application.Run(new Form1());
}
}
}
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------
When I run the program with Double Buffering set to true I get this error on the line above that says, "Application.Run(new Form1());" :
PARAMETER IS NOT VALID.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
Any ideas? Why am I doing what I am doing in the code? I don't know. I've found trying to get bitmaps with transparent backgrounds to work and this finally does it. So I'm really happy with THAT. If the DB worked, I'd be ecstatic!
IT WORKS ABSOLUTELY PERFECTLY without the Double Buffering.
When I set the Double Buffering property of the form, I get the error listed at the bottom fo this description.
I've set the form's Double Buffering property to true. Here is the code for the form. It's pretty simple right now as I test this:
--------------------------
using System;
using System.Collections.Generic
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Graphics objGraphics = e.Graphics)
{
System.Reflection.Assembly
thisExe = System.Reflection.Assembly
System.IO.Stream file = thisExe.GetManifestResourc
Size size = new Size(40, 40);
Bitmap newbitmap = new Bitmap(Image.FromStream(fi
e.Graphics.DrawImage(newbi
//Dispose of the image files.
newbitmap.Dispose();
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
--------------------------
Here is the Program code.
using System;
using System.Collections.Generic
using System.Windows.Forms;
namespace WindowsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualSt
Application.SetCompatibleT
Application.Run(new Form1());
}
}
}
--------------------------
When I run the program with Double Buffering set to true I get this error on the line above that says, "Application.Run(new Form1());" :
PARAMETER IS NOT VALID.
--------------------------
Any ideas? Why am I doing what I am doing in the code? I don't know. I've found trying to get bitmaps with transparent backgrounds to work and this finally does it. So I'm really happy with THAT. If the DB worked, I'd be ecstatic!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER