Hi!
I solved it in another way:
private void DrawAll(Graphics g)
{
RectangleF srcRect = new Rectangle(0, 0, this.panel1.Width,
panel1.Height);
int nWidth = 802;
int nHeight = 1104;
RectangleF destRect = new Rectangle(0, 0, nWidth, nHeight);
float scalex = destRect.Width/this.panel1.Width;
float scaley = destRect.Height/this.panel1.Height;
GraphicsUnit gu = GraphicsUnit.Pixel;
RectangleF scaledRectangle;
Brush br = new
System.Drawing.SolidBrush(Color.FromArgb(((System.Byte)(74)),
((System.Byte)(74)), ((System.Byte)(74))));
scaledRectangle = GetScaledRectangle(scalex, scaley, pictureBox1.Bounds);
Image my1Image = (Image)pictureBox1.Image.Clone();
g.DrawImage(my1Image, scaledRectangle,pictureBox1.Image.GetBounds(ref
gu), GraphicsUnit.Pixel);
scaledRectangle = GetScaledRectangle(scalex, scaley, pictureBox2.Bounds);
Image my2Image = (Image)pictureBox2.Image.Clone();
g.DrawImage(my2Image, scaledRectangle,pictureBox2.Image.GetBounds(ref
gu), GraphicsUnit.Pixel);
scaledRectangle = GetScaledRectangle(scalex, scaley, pictureBox3.Bounds);
Image my3Image = (Image)pictureBox3.Image.Clone();
g.DrawImage(my3Image, scaledRectangle,pictureBox3.Image.GetBounds(ref
gu), GraphicsUnit.Pixel);
if(pictureBox4.Visible && pictureBox5.Visible)
{
scaledRectangle = GetScaledRectangle(scalex, scaley, pictureBox4.Bounds);
Image my4Image = (Image)pictureBox4.Image.Clone();
g.DrawImage(my4Image, scaledRectangle,pictureBox4.Image.GetBounds(ref
gu), GraphicsUnit.Pixel);
scaledRectangle = GetScaledRectangle(scalex, scaley, pictureBox5.Bounds);
Image my5Image = (Image)pictureBox5.Image.Clone();
g.DrawImage(my5Image, scaledRectangle,pictureBox5.Image.GetBounds(ref
gu), GraphicsUnit.Pixel);
}
foreach(Control x in this.panel1.Controls)
{
if(x.GetType().ToString() == "System.Windows.Forms.Label" && x.Visible)
{
Label theText = (Label)x;
x.BringToFront();
StringFormat drawFormat = new StringFormat();
if(theText.TextAlign.ToString() == "TopRight")
{
drawFormat.Alignment = StringAlignment.Far;
g.DrawString(theText.Text, theText.Font,br ,
(theText.Bounds.Left+theText.Width+2)*scalex, theText.Bounds.Top * scaley,
drawFormat);
}
else if(theText.TextAlign.ToString() == "TopCenter")
{
drawFormat.Alignment = StringAlignment.Center;
g.DrawString(theText.Text, theText.Font,br ,
(theText.Bounds.Left+(theText.Width/2))*scalex, theText.Bounds.Top * scaley,
drawFormat);
}
else
g.DrawString(theText.Text, theText.Font,br ,
theText.Bounds.Left*scalex, theText.Bounds.Top * scaley, drawFormat);
}
}
Hi Anders,
For defination in C#:
[DllImport("gdi32.dll", ExactSpelling=true, SetLastError=true)]
public static extern Bool BitBlt(
IntPtr hObject,
int nXDest, int nYDest,
int nWidth, int nHeight,
IntPtr hObjSource, int nXSrc, int nYSrc,
int dwRop);
Luke