N
NewSun
I draw a grid on a panel.And panel1' property AutoScroll is set true.When
HScroollBar is Scroolling,the grid is error.
I have rewritten the mathod of WndProc.But the effect is unexpected.
How can i do? Thx a lot.
Main codes go here:
class frm
private MyApp.Panel panel1;
this.panel1.Paint += new
System.Windows.Forms.PaintEventHandler(this.OnPaint);
private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics grPaint = e.Graphics;
grPaint.Flush(System.Drawing.Drawing2D.FlushIntention.Sync);
SolidBrush brushWhite = new SolidBrush(Color.White);
Pen blackpen = new Pen(Color.Black,2);
// Clear the screen
grPaint.FillRectangle(brushWhite, e.ClipRectangle);
// Draw the grid
grPaint.DrawString("testsdsdsadssadadafsewr3wqr32r", new
Font("Arial",12), new SolidBrush(Color.Black),_RECTSIZE_,10);
grPaint.DrawString("testsdsdsadssadadafsewr3wqr32r", new
Font("Arial",12), new SolidBrush(Color.Black),_RECTSIZE_,30);
for(int i=0;i<iCols;i++)
{
for(int j=0;j<iRows;j++)
{
grPaint.DrawRectangle(blackpen, 5 * _RECTSIZE_ + (i* _RECTSIZE_), 3 *
_RECTSIZE_ + (j*_RECTSIZE_),_RECTSIZE_,_RECTSIZE_);
}
}
brushWhite.Dispose();
blackpen.Dispose();
}
class Panel :System.Windows.Forms.Panel
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{
if(m.Msg == 0x0114)
{
Invalidate();
}
else if(m.Msg == 0x0115)
{
Invalidate();
}
else if(m.Msg == 0x020A)
{
Invalidate();
}
else
{
}
base.WndProc(ref m);
}
}
HScroollBar is Scroolling,the grid is error.
I have rewritten the mathod of WndProc.But the effect is unexpected.
How can i do? Thx a lot.
Main codes go here:
class frm
private MyApp.Panel panel1;
this.panel1.Paint += new
System.Windows.Forms.PaintEventHandler(this.OnPaint);
private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics grPaint = e.Graphics;
grPaint.Flush(System.Drawing.Drawing2D.FlushIntention.Sync);
SolidBrush brushWhite = new SolidBrush(Color.White);
Pen blackpen = new Pen(Color.Black,2);
// Clear the screen
grPaint.FillRectangle(brushWhite, e.ClipRectangle);
// Draw the grid
grPaint.DrawString("testsdsdsadssadadafsewr3wqr32r", new
Font("Arial",12), new SolidBrush(Color.Black),_RECTSIZE_,10);
grPaint.DrawString("testsdsdsadssadadafsewr3wqr32r", new
Font("Arial",12), new SolidBrush(Color.Black),_RECTSIZE_,30);
for(int i=0;i<iCols;i++)
{
for(int j=0;j<iRows;j++)
{
grPaint.DrawRectangle(blackpen, 5 * _RECTSIZE_ + (i* _RECTSIZE_), 3 *
_RECTSIZE_ + (j*_RECTSIZE_),_RECTSIZE_,_RECTSIZE_);
}
}
brushWhite.Dispose();
blackpen.Dispose();
}
class Panel :System.Windows.Forms.Panel
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{
if(m.Msg == 0x0114)
{
Invalidate();
}
else if(m.Msg == 0x0115)
{
Invalidate();
}
else if(m.Msg == 0x020A)
{
Invalidate();
}
else
{
}
base.WndProc(ref m);
}
}