source: trunk/Utilities/Miscellaneous/PolyTextOut/PolyTextOut.cpp @ 406

Last change on this file since 406 was 406, checked in by roman, 9 years ago
File size: 1.9 KB
Line 
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
11HDC hDc;
12POINT Position = { 2000, 750 };
13SIZE Extent = { 400, 50 };
14
15VOID 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
32int _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        Do(L"Мама мыла раму");
47        Position.y += Extent.cy;
48        Do(L"Mother washed window");
49        Position.y += Extent.cy;
50        Do(L"ママソープフレーム");
51        Position.y -= 2 * Extent.cy;
52        Position.x += Extent.cx;
53        Do(L"Мама мыла раму", TRUE);
54        Position.y += Extent.cy;
55        Do(L"Mother washed window", TRUE);
56        Position.y += Extent.cy;
57        Do(L"ママソープフレーム", TRUE);
58        // NOTE: Resource disposal ignored
59        ReleaseDC(NULL, hDc);
60        return 0;
61}
62
Note: See TracBrowser for help on using the repository browser.