DrawText(hdc, tt, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS);

#include <windows.h> char tt[80]="Ele mesmo julgará o mundo com justiça; julgará os povos com retidão. Salmos 9:8"; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPI, PSTR szCL, int iCS) { static TCHAR nome[] = TEXT("DrawText"); HWND hwnd; MSG msg; WNDCLASS wcl; wcl.style = CS_HREDRAW | CS_VREDRAW; wcl.lpfnWndProc = WndProc; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hInstance = hI; wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.hbrBackground = GetSysColorBrush(COLOR_INFOBK); wcl.lpszMenuName = NULL; wcl.lpszClassName = nome; if(!RegisterClass(&wcl)) { MessageBox(NULL, TEXT("Error!"), nome, MB_ICONERROR); return 0; } hwnd = CreateWindow( nome, nome, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 600, 300, NULL, NULL, hI, NULL ); ShowWindow(hwnd, iCS); UpdateWindow(hwnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); FreeConsole(); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lP) { HDC hdc; PAINTSTRUCT ps; RECT rect; switch(Msg) { case WM_PAINT: hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); DrawText(hdc, tt, -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS); EndPaint(hwnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, Msg, wParam, lP); }

Comentários