Example for DrawText?

Hi, new to win32 application?

I want to know how to write text in a specific window at the top of the window, for example, for example (x, y) = (40,10) in this coordinate of a specific window. I have to write a text.

+4
source share
1 answer

Suppose your window name is "hwnd" and the text you want to write in this window at the x, y coordinate is stored in the "message", where

LPCWSTR message=L"My First Window"; then

 RECT rect; HDC wdc = GetWindowDC(hwnd); GetClientRect (bgHandle, &rect) ; SetTextColor(wdc, 0x00000000); SetBkMode(wdc,TRANSPARENT); rect.left=40; rect.top=10; DrawText( wdc, message, -1, &rect, DT_SINGLELINE | DT_NOCLIP ) ; DeleteDC(wdc); 

Here it is .. remember that this is just one example.

+6
source

All Articles