-2

so ive heard of %d, but i dont know how to use it. here is what i want to do:

DrawText (hdcWindow, "PLACE IN QUESTION" , -1, &rc, DT_SINGLELINE);

at the "PLACE IN QUESTION" i want to display text and a variable like "text %d" or something, but I don't know the syntax, and how do I dictate what %d will represent when it is displayed?

George
  • 2,034
  • 1
  • 15
  • 16

1 Answers1

0

DrawText doesn't work like printf or something like that. I advise you to look at the MSDN: MSDN: DrawText

int DrawText(
  _In_     HDC hDC,
  _Inout_  LPCTSTR lpchText,
  _In_     int nCount,
  _Inout_  LPRECT lpRect,
  _In_     UINT uFormat
);

You need to make a conversion to LPCTSTR, you can have a look into Google, if I find a link i will give it to you, but it make long time i haven't do C++.

Edit: I found :

int number = 1;
CString t;
t.Format(_T("Text: %d"), number);

and then DrawText(XXX, t, XXX, ...);

Pierre Lebon
  • 445
  • 1
  • 5
  • 12
  • WOOH the real answer here! i didnt have any clue what the other guys up there are talking about because im a noob - but wait! nooby question #2: what do i include? – Jacob Padgett Jul 08 '13 at 05:36
  • You can use: `#include #include ` As always i advise you to have regular look at the MSDN, you simply type the function name in your favorite search engine, they are often the first or second link, and you will find the all the needed library and structure of a function. [MSDN CString](http://msdn.microsoft.com/fr-fr/library/ms174288%28v=vs.80%29.aspx) – Pierre Lebon Jul 08 '13 at 22:30