LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the hDC of a Canvas Control

Solved!
Go to solution

Hello,

 

I have a DLL that takes a hDC parameter which will then "draw" something into it using Windows API. An example of this might be the WinSDK function TextOut(HDC hdcint nXStartint nYStartLPCTSTR lpStringint cbString).

 

How would I get the hDC of a Canvas control, or another control (not the Panel) to be able to use these functions?

 

Also, are there any caveats to be aware of?

 

Regards,

Jason.

Message Edited by jcurl on 02-25-2010 08:36 PM
0 Kudos
Message 1 of 4
(3,443 Views)

Hi Jason,

 

Even if you get the handle you need, are you sure Windows API will be able to "directly" draw something on NI's canvas control?

 

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 4
(3,423 Views)
Solution
Accepted by topic author jcurl

As far as I am aware, CVI controls are not windowed controls, so they do not have their own window handles and you cannot get a device context handle for them. The same is true for CVI child panels. You will only able to get a device context handle for the enclosing main panel.

 

--
Martin
Certified CVI Developer
0 Kudos
Message 3 of 4
(3,412 Views)

Thanks Martin for your concise answer. At least this explains why it's possible to get the hWnd for a panel (for which there are examples from NI on how to get the hDC) and not from other controls.

 

Therefore, I'll start planning importing an ActiveX picture control or similar that can give me a hDC to write into. 

0 Kudos
Message 4 of 4
(3,397 Views)