A
Ahmed El-Daly
Hi,
The code attached seems to create the pictureboxes but they fail to
display on the form. The items displayed are supposed to be cards from
cards.dll. The code works fine if I provide the hdc of the form
itself, or of a PictureBox that I create myself in the designer.
PictureBox[,] CardFrame = new PictureBox[4, 13];
//PictureBox pictureBox1 = new PictureBox();
private void button1_Click(object sender, System.EventArgs e)
{
int ypos;
Cards yarab = new Cards();
IntPtr hdc;
Graphics hdcobject;
for (int z=0; z<4; z++)
{
ypos = 0;
for (int y=0; y<13; y++)
{
this.CardFrame[z,y] = new PictureBox();
//this.CardFrame[z,y].Visible = true;
/*this.pictureBox1.Size = new Size(50,100);
this.pictureBox1.BorderStyle = BorderStyle.Fixed3D;*/
hdcobject = this.CardFrame[z,y].CreateGraphics();
hdc = hdcobject.GetHdc();
yarab.DrawCard(hdc, 0, 0, yarab.PlayerHand[z, y], 0, 0);
hdcobject.ReleaseHdc(hdc);
ypos += 30;
this.CardFrame[z,y].Location = new Point(z * 100, ypos);
this.Controls.Add(this.CardFrame[z,y]);
//MessageBox.Show((Convert.ToString(this.Controls.Count)));
if(y==5)
MessageBox.Show("5");
else if(y==10)
MessageBox.Show("10");
}
}
//this.Controls.AddRange(new Control[]{this.CardFrame});
MessageBox.Show("done!!");
//this.pictureBox1.CreateGraphics().ReleaseHdc(hdc);
//yarab.DrawCard(hdc, 0, 0, 22, 0, 0); works fine!
//yarab.DrawCard(hdc, 0, 100, 22, 60, 0); this is not working yet!
//yarab.DrawCard(hdc, 0, 200, 22, 2, 0); works fine!
}
}
}
Thank you very bery bery much!!
The code attached seems to create the pictureboxes but they fail to
display on the form. The items displayed are supposed to be cards from
cards.dll. The code works fine if I provide the hdc of the form
itself, or of a PictureBox that I create myself in the designer.
PictureBox[,] CardFrame = new PictureBox[4, 13];
//PictureBox pictureBox1 = new PictureBox();
private void button1_Click(object sender, System.EventArgs e)
{
int ypos;
Cards yarab = new Cards();
IntPtr hdc;
Graphics hdcobject;
for (int z=0; z<4; z++)
{
ypos = 0;
for (int y=0; y<13; y++)
{
this.CardFrame[z,y] = new PictureBox();
//this.CardFrame[z,y].Visible = true;
/*this.pictureBox1.Size = new Size(50,100);
this.pictureBox1.BorderStyle = BorderStyle.Fixed3D;*/
hdcobject = this.CardFrame[z,y].CreateGraphics();
hdc = hdcobject.GetHdc();
yarab.DrawCard(hdc, 0, 0, yarab.PlayerHand[z, y], 0, 0);
hdcobject.ReleaseHdc(hdc);
ypos += 30;
this.CardFrame[z,y].Location = new Point(z * 100, ypos);
this.Controls.Add(this.CardFrame[z,y]);
//MessageBox.Show((Convert.ToString(this.Controls.Count)));
if(y==5)
MessageBox.Show("5");
else if(y==10)
MessageBox.Show("10");
}
}
//this.Controls.AddRange(new Control[]{this.CardFrame});
MessageBox.Show("done!!");
//this.pictureBox1.CreateGraphics().ReleaseHdc(hdc);
//yarab.DrawCard(hdc, 0, 0, 22, 0, 0); works fine!
//yarab.DrawCard(hdc, 0, 100, 22, 60, 0); this is not working yet!
//yarab.DrawCard(hdc, 0, 200, 22, 2, 0); works fine!
}
}
}
Thank you very bery bery much!!