Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking variable values, CString conversion, and DC pointers

Status
Not open for further replies.

joelwenzel

Programmer
Jun 28, 2002
448
Hi,

I am wondering how I can check what is in certain variables in my program. I want to be able to just convert whatever variable I have and print it to the screen. So I have two problems

1. I need to somehow get a pointer to the device context from any function so that I can write using TextOut(0,0, mystring).

2. I need to be able to convert any kind of variable to a CString

Any ideas. I'm sure this is an easy question but I cannot find the answer.

 
It sounds like you could just use the debugger if all you need to do is check the value of a variable. If you don't know how to use the debugger, you should definately learn; it will save you hours of debugging time.

But if that's not all you really need to do, you can get a pointer to the DC with the CView::GetDC() method. Don't forget to release it with ReleaseDC() when you are done. To convert any other data type to a CString, just use the CString::Format method. If you've never used it before, it is basically sprintf for a CString and is very handy.
 
Thanks a lot. I will looking into using the debugger more.

Plus, I need to know all that conversion stuff anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top