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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output int variable to screen??

Status
Not open for further replies.

lora

Programmer
Dec 1, 1999
43
US
i'm in a c++ class and in way over my head with no help because its a holiday!! simple problem create an mfc app which displays the client coordinates on the screen for a WM_LBUTTONDOWN message handler. i've got a variable defined and initialized in the view class to hold the point variable sent to the handler but can't figure how to output to the screen...i've got a cclientdc and am using textout to print "test"...do i have to convert the int variable to text to output to the screen?? if so how do you combine strings to send them to the screen...THANKS!!
 
hey thats quite simple see what you can do is<br>
Declare 2 global variables or u can make them members of the Doc if u do not like globals.<br>
char szBuff[20];<br>
POINT pt;<br>
<br>
then in MouseMove what u can do is this<br>
void CMouseView::OnMouseMove(UINT nFlags, CPoint point) <br>
{ <br>
pt=point ;//Copy the values of point in the global pt object<br>
wsprintf(szBuff,&quot;X=%d,Y=%d&quot;,point.x,point.y);//convert it to String and copy it into the global szBuff array<br>
Invalidate();//call it to call OnDraw(CDC *pdc)<br>
CView::OnMouseMove(nFlags, point);<br>
}<br>
Calling Invalidate calls OnDraw(CDC* pDC)<br>
which already has a pointer to the Device context so u do not need CClientDC<br>
then in on draw u do<br>
pDC-&gt;TextOut(pt.x,pt.y,szBuff);<br>
that's all<br>
Hope this works out.<br>
<br>
All the best =)<br>
Sun<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top