Reputation: 674
I out text but he climbed by region of my window, how I can fix it? Here part of my code
PAINTSTRUCT ps;
hdc=BeginPaint(hWnd3,&ps);
LOGFONT lf;
lf.lfWidth=0;
lf.lfHeight=14;
strcpy(lf.lfFaceName,"Times New Roman");
lf.lfEscapement=lf.lfStrikeOut=lf.lfUnderline=0;
lf.lfClipPrecision=CLIP_DEFAULT_PRECIS;
lf.lfCharSet=1251;
lf.lfOrientation=0;
hf=CreateFontIndirect(&lf);
SelectObject(hdc,hf);
SetTextAlign(hdc,TA_CENTER);
GetClientRect(hWnd,&r);
TextOut(hdc,r.right/2,r.bottom/2,"Some text",strlen("Some text"));
DeleteObject(hf);
EndPaint(hWnd3,&ps);
Text will be much longer than "Some text".
Upvotes: 2
Views: 142
Reputation: 20609
Use DrawText()
instead on TextOut()
. DrawText lets you specify a rectangle for clipping the text. DrawText()
can also be used to calculate the size of the rectangle that will be needed.
Upvotes: 2