10046 : converting a program from vb6 to vb.net. Everything seems to go fine, exept for the userdraw ackground part.

Question

i am converting a program from vb6 to vb.net. Everything seems to go fine, exept for the userdraw ackground part. I know how to create graphics in .net But the function returns a Hdc and how can i convert this to a graphic object (so i can paint a today line for example).

Answer

You can convert a Hdc to a Graphic object like in the sample below.

private void axphSchemaX1_OnUserDrawTime(object sender, AxphGantXControl.IphSchemaXEvents_OnUserDrawTimeEvent e)
{
  Graphics gr=System.Drawing.Graphics.FromHdc((IntPtr)e.theHDC);
 
gr.DrawLine(new Pen(Color.Beige,5),e.left,e.top,e.right,e.bottom);
  gr.DrawLine(
new Pen(Color.BlueViolet,5),e.right,e.top,e.left,e.bottom);
}

Leave a Reply