1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2015 |
---|
3 | // Created by Roman Ryltsov roman@alax.info |
---|
4 | // |
---|
5 | // A permission to use the source code is granted as long as reference to |
---|
6 | // source website http://alax.info is retained. |
---|
7 | |
---|
8 | #include "stdafx.h" |
---|
9 | #include <windows.h> |
---|
10 | |
---|
11 | HDC hDc; |
---|
12 | POINT Position = { 2000, 750 }; |
---|
13 | SIZE Extent = { 400, 50 }; |
---|
14 | |
---|
15 | VOID Do(LPCTSTR pszText, BOOL bExtTextOut = FALSE) |
---|
16 | { |
---|
17 | POLYTEXT pPolyTexts[1]; |
---|
18 | pPolyTexts[0].x = Position.x; |
---|
19 | pPolyTexts[0].y = Position.y; |
---|
20 | pPolyTexts[0].n = (INT) _tcslen(pszText); |
---|
21 | pPolyTexts[0].lpstr = pszText; |
---|
22 | pPolyTexts[0].uiFlags = 0; |
---|
23 | SetRect(&pPolyTexts[0].rcl, Position.x, Position.y, Extent.cx, Extent.cy); |
---|
24 | pPolyTexts[0].pdx = NULL; |
---|
25 | if(bExtTextOut) |
---|
26 | for(auto&& PolyText: pPolyTexts) |
---|
27 | ExtTextOut(hDc, PolyText.x, PolyText.y, PolyText.uiFlags, &PolyText.rcl, PolyText.lpstr, PolyText.n, PolyText.pdx); |
---|
28 | else |
---|
29 | PolyTextOut(hDc, pPolyTexts, _countof(pPolyTexts)); |
---|
30 | } |
---|
31 | |
---|
32 | int _tmain(int argc, _TCHAR* argv[]) |
---|
33 | { |
---|
34 | LOGFONT FontFormat; |
---|
35 | ZeroMemory(&FontFormat, sizeof FontFormat); |
---|
36 | FontFormat.lfHeight = -28; |
---|
37 | FontFormat.lfWeight = FW_SEMIBOLD; |
---|
38 | FontFormat.lfCharSet = DEFAULT_CHARSET; |
---|
39 | _tcscpy_s(FontFormat.lfFaceName, _T("Arial")); |
---|
40 | HFONT hFont = CreateFontIndirect(&FontFormat); |
---|
41 | hDc = GetDC(NULL); |
---|
42 | SelectObject(hDc, hFont); |
---|
43 | SetBkMode(hDc, OPAQUE); |
---|
44 | SetBkColor(hDc, RGB(0x00, 0x00, 0x00)); |
---|
45 | SetTextColor(hDc, RGB(0x44, 0xFF, 0x44)); |
---|
46 | static LPCTSTR g_ppszTexts[] = |
---|
47 | { |
---|
48 | L"Мама мыла раму", // Russian |
---|
49 | L"Mother washed window", |
---|
50 | L"ママソープフレーム", // Japanese |
---|
51 | L"დედა საპნის კარკასი", // Georgean |
---|
52 | }; |
---|
53 | for(auto&& pszText: g_ppszTexts) |
---|
54 | { |
---|
55 | Do(pszText); |
---|
56 | Position.y += Extent.cy; |
---|
57 | } |
---|
58 | Position.y -= _countof(g_ppszTexts) * Extent.cy; |
---|
59 | Position.x += Extent.cx; |
---|
60 | for(auto&& pszText: g_ppszTexts) |
---|
61 | { |
---|
62 | Do(pszText, TRUE); |
---|
63 | Position.y += Extent.cy; |
---|
64 | } |
---|
65 | // NOTE: Resource disposal ignored |
---|
66 | ReleaseDC(NULL, hDc); |
---|
67 | return 0; |
---|
68 | } |
---|
69 | |
---|