hDC problem
-
I am trying to supply an hDC to a dll that needs a picture drawing area. I think i have 2 choices: 1. Use Form1 itself and just specify where the dll should draw the object. 2. Use a PictureBox1. I do not understand the structures well enough to know if i can: a. use the windowHandle of Form1 as an hDC. --- Does the windowHandle qualify as an hDC? If not, how can i get a suitable hDC for Form1? b. get the hDC of pictureBox1. --- I need the hDC in an event-handler (a Form1 keypress event) that does not have access to an e argument that allows: hdc = e.Graphics.GetHdc(); . All suggestions are welcome. Thank you.
-
I am trying to supply an hDC to a dll that needs a picture drawing area. I think i have 2 choices: 1. Use Form1 itself and just specify where the dll should draw the object. 2. Use a PictureBox1. I do not understand the structures well enough to know if i can: a. use the windowHandle of Form1 as an hDC. --- Does the windowHandle qualify as an hDC? If not, how can i get a suitable hDC for Form1? b. get the hDC of pictureBox1. --- I need the hDC in an event-handler (a Form1 keypress event) that does not have access to an e argument that allows: hdc = e.Graphics.GetHdc(); . All suggestions are welcome. Thank you.
A window handle cannot be used as a hDC (device context). If you want to get the hDC for any control or form, use something similar to this:
Graphics g = [this/pictureBox1].CreateGraphics();
g.GetHdc(); //returns handle to device context