ReactOS 0.4.15-dev-8102-g108db8f
psmtest.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Tests
3 * FILE: rostests/win32/user32/psmtest/psmtest.c
4 * PURPOSE: Side by side comparison of the undocumented
5 * LpkPSMTextOut and UserLpkPSMTextOut functions
6 *
7 * PROGRAMMER: Program skeleton: https://github.com/TransmissionZero/MinGW-Win32-Application
8 * Test code by Baruch Rutman
9 */
10
11#include <windows.h>
12#include <commctrl.h>
13#include <strsafe.h>
14
15#define IDI_APPICON 101
16#define IDR_ACCELERATOR 103
18
19/* Prototypes */
20INT WINAPI LpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cString, DWORD dwFlags);
21INT WINAPI UserLpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cString, DWORD dwFlags);
22
23/* Main window class and title */
24static LPCWSTR MainWndClass = L"PSM Test";
25
26#define LPK 1
27#define USERLPK 2
28static void DrawTest(HDC hdc, int ypos, LPCWSTR str, DWORD dwFlags, int testtype)
29{
30 WCHAR Result[100];
31 INT ret = 0;
32
33 if (testtype == LPK)
34 {
35 ret = LpkPSMTextOut(hdc, 0, ypos, str, (!str) ? 10 : lstrlenW(str), dwFlags);
36 StringCchPrintfW(Result, 100, L"Return Value = %d", ret);
37 TextOutW(hdc, 200, ypos, Result, lstrlenW(Result));
38 }
39 else if (testtype == USERLPK)
40 {
42 StringCchPrintfW(Result, 100, L"Return Value = %d", ret);
43 TextOutW(hdc, 600, ypos, Result, lstrlenW(Result));
44 }
45
46}
47
48/* Our application entry point */
49int WINAPI
51 HINSTANCE hPrevInstance,
52 LPTSTR lpszCmdLine,
53 int nCmdShow)
54{
56 HWND hWnd;
57 HACCEL hAccelerators;
58 MSG msg;
59 WNDCLASSEXW wc;
60
61 /* Class for our main window */
62 wc.cbSize = sizeof(wc);
63 wc.style = 0;
65 wc.cbClsExtra = 0;
66 wc.cbWndExtra = 0;
71 wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
74
75 /* Initialise common controls */
76 icc.dwSize = sizeof(icc);
79
80 /* Register our main window class, or error */
81 if (!RegisterClassExW(&wc))
82 {
83 MessageBoxW(NULL, L"Error registering main window class.", L"Error", MB_ICONERROR | MB_OK);
84 return 0;
85 }
86
89
90 /* Create our main window, or error */
91 if (!hWnd)
92 {
93 MessageBoxW(NULL, L"Error creating main window.", L"Error", MB_ICONERROR | MB_OK);
94 return 0;
95 }
96
97 /* Load accelerators */
99
100 /* Show main window and force a paint */
101 ShowWindow(hWnd, nCmdShow | SW_MAXIMIZE);
103
104 /* Main message loop */
105 while (GetMessageW(&msg, NULL, 0, 0) > 0)
106 {
107 if (!TranslateAcceleratorW(hWnd, hAccelerators, &msg))
108 {
111 }
112 }
113
114 return (int)msg.wParam;
115}
116
117/* Window procedure for our main window */
119{
120 switch (msg)
121 {
122
123 case WM_GETMINMAXINFO:
124 {
125 /* Prevent our window from being sized too small */
126 MINMAXINFO *minMax = (MINMAXINFO*)lParam;
127 minMax->ptMinTrackSize.x = 220;
128 minMax->ptMinTrackSize.y = 110;
129
130 return 0;
131 }
132
133 case WM_PAINT:
134 {
135 PAINTSTRUCT ps;
136 HDC hdc = BeginPaint(hWnd, &ps);
137
138 enum {
139 ALEF = 0x5D0,
140 BET,
141 GIMEL,
142 DALET,
143 HEY,
144 VAV,
145 ZAYIN,
146 HET,
147 TET,
148 YUD,
149 KAF_SOFIT,
150 KAF,
151 LAMED,
152 MEM_SOFIT,
153 MEM,
154 NUN_SOFIT,
155 NUN,
156 SAMEKH,
157 AYIN,
158 PEY_SOFIT,
159 PEY,
161 TSADI,
162 QOF,
163 RESH,
164 SHIN,
165 TAV
166 };
167
169 HFONT hfont;
170 WCHAR Test[] = L"&Test Text";
171 WCHAR Test2[] = L"&Test\nText";
172 WCHAR Test3[] = L"&Test\tText";
173 WCHAR Test4[] = L"&Test T&ex&t";
174 WCHAR Test5[] = { TET, QOF, SAMEKH, TET, L' ', L'&', BET, DALET, YUD, QOF, HEY, 0 };
175 WCHAR Test6[] = L"Test&&Text";
176 WCHAR Test7[] = { BET, DALET, YUD, QOF, HEY, L'&', 'T','e','s','t', 0};
177 WCHAR Test8[] = L"TestText&";
178 WCHAR Test9[] = L"TestText&&";
179 WCHAR Test10[] = L"TestText";
180
181 ZeroMemory(&font, sizeof(LOGFONTW));
182 StringCchCopyW(font.lfFaceName, 32, L"Microsoft Sans Serif");
186
187 DrawTest(hdc, 0, Test, 0, LPK);
191 DrawTest(hdc, 80, Test2, 0, LPK);
193 DrawTest(hdc, 120, Test3, 0, LPK);
195 DrawTest(hdc, 160, NULL, 0, LPK);
196 DrawTest(hdc, 180, Test4, 0, LPK);
197 DrawTest(hdc, 200, Test4, DT_NOPREFIX, LPK);
198 DrawTest(hdc, 220, Test4, DT_HIDEPREFIX, LPK);
199 DrawTest(hdc, 240, Test5, 0, LPK);
200 DrawTest(hdc, 260, Test5, DT_NOPREFIX, LPK);
201 DrawTest(hdc, 280, Test5, DT_HIDEPREFIX, LPK);
202 DrawTest(hdc, 300, Test5, DT_PREFIXONLY, LPK);
203 DrawTest(hdc, 320, Test6, 0, LPK);
204 DrawTest(hdc, 340, Test6, DT_NOPREFIX, LPK);
205 DrawTest(hdc, 360, Test6, DT_HIDEPREFIX, LPK);
206 DrawTest(hdc, 380, Test6, DT_PREFIXONLY, LPK);
207 DrawTest(hdc, 400, Test7, 0, LPK);
208 DrawTest(hdc, 420, Test7, DT_NOPREFIX, LPK);
209 DrawTest(hdc, 440, Test7, DT_HIDEPREFIX, LPK);
210 DrawTest(hdc, 460, Test7, DT_PREFIXONLY, LPK);
211 DrawTest(hdc, 480, Test7, DT_RTLREADING, LPK);
213 DrawTest(hdc, 500, Test7, 0, LPK);
215 DrawTest(hdc, 520, Test8, 0, LPK);
216 DrawTest(hdc, 540, Test8, DT_NOPREFIX, LPK);
217 DrawTest(hdc, 560, Test8, DT_HIDEPREFIX, LPK);
218 DrawTest(hdc, 580, Test8, DT_PREFIXONLY, LPK);
219 DrawTest(hdc, 600, Test9, 0, LPK);
220 DrawTest(hdc, 620, Test9, DT_NOPREFIX, LPK);
221 DrawTest(hdc, 640, Test9, DT_HIDEPREFIX, LPK);
222 DrawTest(hdc, 660, Test9, DT_PREFIXONLY, LPK);
223 DrawTest(hdc, 680, Test10, 0, LPK);
224 DrawTest(hdc, 700, Test10, DT_NOPREFIX, LPK);
225 DrawTest(hdc, 720, Test10, DT_HIDEPREFIX, LPK);
226 DrawTest(hdc, 740, Test10, DT_PREFIXONLY, LPK);
227
228 TextOutW(hdc, 100, 760, L"LpkPSMTextOut", 13);
229
230 DrawTest(hdc, 0, Test, 0, USERLPK);
234 DrawTest(hdc, 80, Test2, 0, USERLPK);
236 DrawTest(hdc, 120, Test3, 0, USERLPK);
238 /* DrawTest(hdc, 160, NULL, 0, USERLPK); */ /* Crash on windows */
239 DrawTest(hdc, 180, Test4, 0, USERLPK);
240 DrawTest(hdc, 200, Test4, DT_NOPREFIX, USERLPK);
241 DrawTest(hdc, 220, Test4, DT_HIDEPREFIX, USERLPK);
242 DrawTest(hdc, 240, Test5, 0, USERLPK);
243 DrawTest(hdc, 260, Test5, DT_NOPREFIX, USERLPK);
244 DrawTest(hdc, 280, Test5, DT_HIDEPREFIX, USERLPK);
245 DrawTest(hdc, 300, Test5, DT_PREFIXONLY, USERLPK);
246 DrawTest(hdc, 320, Test6, 0, USERLPK);
247 DrawTest(hdc, 340, Test6, DT_NOPREFIX, USERLPK);
248 DrawTest(hdc, 360, Test6, DT_HIDEPREFIX, USERLPK);
249 DrawTest(hdc, 380, Test6, DT_PREFIXONLY, USERLPK);
250 DrawTest(hdc, 400, Test7, 0, USERLPK);
251 DrawTest(hdc, 420, Test7, DT_NOPREFIX, USERLPK);
252 DrawTest(hdc, 440, Test7, DT_HIDEPREFIX, USERLPK);
253 DrawTest(hdc, 460, Test7, DT_PREFIXONLY, USERLPK);
254 DrawTest(hdc, 480, Test7, DT_RTLREADING, USERLPK);
256 DrawTest(hdc, 500, Test7, 0, USERLPK);
258 DrawTest(hdc, 520, Test8, 0, USERLPK);
259 DrawTest(hdc, 540, Test8, DT_NOPREFIX, USERLPK);
260 DrawTest(hdc, 560, Test8, DT_HIDEPREFIX, USERLPK);
261 DrawTest(hdc, 580, Test8, DT_PREFIXONLY, USERLPK);
262 DrawTest(hdc, 600, Test9, 0, USERLPK);
263 DrawTest(hdc, 620, Test9, DT_NOPREFIX, USERLPK);
264 DrawTest(hdc, 640, Test9, DT_HIDEPREFIX, USERLPK);
265 DrawTest(hdc, 660, Test9, DT_PREFIXONLY, USERLPK);
266 DrawTest(hdc, 680, Test10, 0, USERLPK);
267 DrawTest(hdc, 700, Test10, DT_NOPREFIX, USERLPK);
268 DrawTest(hdc, 720, Test10, DT_HIDEPREFIX, USERLPK);
269 DrawTest(hdc, 740, Test10, DT_PREFIXONLY, USERLPK);
270
271 TextOutW(hdc, 500, 760, L"UserLpkPSMTextOut", 17);
272
273 EndPaint(hWnd, &ps);
274 break;
275 }
276
277 case WM_DESTROY:
278 {
280 return 0;
281 }
282 }
284}
static HFONT hfont
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
#define NULL
Definition: types.h:112
#define CALLBACK
Definition: compat.h:35
#define lstrlenW
Definition: compat.h:750
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
@ HET
Definition: kbdheb.c:77
@ NUN
Definition: kbdheb.c:86
@ YUD
Definition: kbdheb.c:79
@ VAV
Definition: kbdheb.c:75
@ TSADI
Definition: kbdheb.c:92
@ ZAYIN
Definition: kbdheb.c:76
@ MEM
Definition: kbdheb.c:84
@ LAMED
Definition: kbdheb.c:82
@ DALET
Definition: kbdheb.c:73
@ TET
Definition: kbdheb.c:78
@ BET
Definition: kbdheb.c:71
@ TAV
Definition: kbdheb.c:96
@ TSADI_SOFIT
Definition: kbdheb.c:91
@ SHIN
Definition: kbdheb.c:95
@ MEM_SOFIT
Definition: kbdheb.c:83
@ AYIN
Definition: kbdheb.c:88
@ PEY
Definition: kbdheb.c:90
@ PEY_SOFIT
Definition: kbdheb.c:89
@ HEY
Definition: kbdheb.c:74
@ KAF_SOFIT
Definition: kbdheb.c:80
@ QOF
Definition: kbdheb.c:93
@ ALEF
Definition: kbdheb.c:70
@ SAMEKH
Definition: kbdheb.c:87
@ RESH
Definition: kbdheb.c:94
@ KAF
Definition: kbdheb.c:81
@ GIMEL
Definition: kbdheb.c:72
@ NUN_SOFIT
Definition: kbdheb.c:85
void Test2(void)
Definition: terminate.cpp:76
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
Definition: mk_font.cpp:20
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
static void DrawTest(HDC hdc, int ypos, LPCWSTR str, DWORD dwFlags, int testtype)
Definition: psmtest.c:28
INT WINAPI LpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cString, DWORD dwFlags)
Definition: lpk.c:380
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmdLine, int nCmdShow)
Definition: psmtest.c:50
INT WINAPI UserLpkPSMTextOut(HDC hdc, int x, int y, LPCWSTR lpString, int cString, DWORD dwFlags)
Definition: font.c:413
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: psmtest.c:118
static LPCWSTR MainWndClass
Definition: psmtest.c:24
#define IDR_ACCELERATOR
Definition: psmtest.c:16
#define IDI_APPICON
Definition: psmtest.c:15
#define LPK
Definition: psmtest.c:26
#define USERLPK
Definition: psmtest.c:27
const WCHAR * str
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
LPCWSTR lpszClassName
Definition: winuser.h:3226
HBRUSH hbrBackground
Definition: winuser.h:3224
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
int cbWndExtra
Definition: winuser.h:3220
HCURSOR hCursor
Definition: winuser.h:3223
HICON hIconSm
Definition: winuser.h:3227
HINSTANCE hInstance
Definition: winuser.h:3221
UINT style
Definition: winuser.h:3217
int cbClsExtra
Definition: winuser.h:3219
HICON hIcon
Definition: winuser.h:3222
POINT ptMinTrackSize
Definition: winuser.h:3630
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
VOID Test3(PTEST Test, HANDLE hEvent)
Definition: tmrqueue.c:266
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT
Definition: typedefs.h:58
int ret
#define ZeroMemory
Definition: winbase.h:1712
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
HICON HCURSOR
Definition: windef.h:299
#define WINAPI
Definition: msvc.h:6
UINT WINAPI GetTextAlign(_In_ HDC)
Definition: text.c:838
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:883
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define TRANSPARENT
Definition: wingdi.h:950
#define TA_RTLREADING
Definition: wingdi.h:934
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
#define WM_PAINT
Definition: winuser.h:1620
#define DT_NOPREFIX
Definition: winuser.h:537
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DT_PREFIXONLY
Definition: winuser.h:548
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define IMAGE_ICON
Definition: winuser.h:212
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define DT_SINGLELINE
Definition: winuser.h:540
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2234
#define IDC_ARROW
Definition: winuser.h:687
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define DT_RTLREADING
Definition: winuser.h:539
#define MB_ICONERROR
Definition: winuser.h:787
#define WM_GETMINMAXINFO
Definition: winuser.h:1640
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
BOOL WINAPI UpdateWindow(_In_ HWND)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define LR_SHARED
Definition: winuser.h:1100
#define MB_OK
Definition: winuser.h:790
#define CW_USEDEFAULT
Definition: winuser.h:225
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define LoadImage
Definition: winuser.h:5815
#define IMAGE_CURSOR
Definition: winuser.h:213
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
#define LR_DEFAULTCOLOR
Definition: winuser.h:1087
#define WM_DESTROY
Definition: winuser.h:1609
#define LR_DEFAULTSIZE
Definition: winuser.h:1094
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define DT_EXPANDTABS
Definition: winuser.h:532
#define SW_MAXIMIZE
Definition: winuser.h:772
#define DT_CALCRECT
Definition: winuser.h:526
#define DT_HIDEPREFIX
Definition: winuser.h:547
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define COLOR_BTNFACE
Definition: winuser.h:928
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185