[GDI32_APITEST]
[reactos.git] / rostests / apitests / gdi32 / GdiGetCharDimensions.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for GdiGetCharDimensions
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include <apitest.h>
9
10 #include <wingdi.h>
11
12 void Test_GdiGetCharDimensions()
13 {
14 LOGFONT logfont = {-11, 0, 0, 0, 400,
15 0, 0, 0, 0, 0, 0, 0, 0,
16 "MS Shell Dlg 2"};
17 HFONT hFont, hOldFont;
18 HDC hdc;
19 LONG x, y, x2;
20 TEXTMETRICW tm;
21 SIZE size;
22 static const WCHAR alphabet[] = {
23 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
24 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
25 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
26
27 hFont = CreateFontIndirect(&logfont);
28 hdc = CreateCompatibleDC(NULL);
29 hOldFont = SelectObject(hdc, hFont);
30
31 x = GdiGetCharDimensions(hdc, &tm, &y);
32 GetTextExtentPointW(hdc, alphabet, 52, &size);
33 x2 = (size.cx / 26 + 1) / 2;
34
35 ok(x == x2, "x=%ld, x2=%ld\n", x, x2);
36 ok(y == tm.tmHeight, "y = %ld, tm.tmHeight = %ld\n", y, tm.tmHeight);
37
38 SelectObject(hdc, hOldFont);
39 DeleteObject(hFont);
40 DeleteDC(hdc);
41 }
42
43 START_TEST(GdiGetCharDimensions)
44 {
45 Test_GdiGetCharDimensions();
46 }
47