ReactOS 0.4.15-dev-8222-g9164419
SHLimitInputEdit.cpp File Reference
#include "shelltest.h"
#include <shobjidl.h>
#include <shlwapi.h>
Include dependency graph for SHLimitInputEdit.cpp:

Go to the source code of this file.

Classes

class  CShellFolder
 

Functions

 STDMETHODIMP_ (ULONG) CShellFolder
 
static BOOL CALLBACK PropEnumProc (HWND hwnd, LPCWSTR lpszString, HANDLE hData)
 
static void DoNullFolderTest (HWND hEdt1)
 
static INT_PTR CALLBACK DialogProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 START_TEST (SHLimitInputEdit)
 

Function Documentation

◆ DialogProc()

static INT_PTR CALLBACK DialogProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 260 of file SHLimitInputEdit.cpp.

261{
262 if (uMsg != WM_INITDIALOG)
263 return FALSE;
264
265 HWND hEdt1 = GetDlgItem(hwnd, edt1);
266 INT n;
267 HRESULT hr;
268 WCHAR szText[64];
269
270 DoNullFolderTest(hEdt1);
271
272 {
273 CShellFolder sf(123, FALSE);
274
275 ok_long(sf.m_cRefs, 1);
276
277 SendMessageW(hEdt1, EM_LIMITTEXT, 234, 0);
278
279 trace("GWLP_WNDPROC: %p\n", (void *)GetWindowLongPtr(hEdt1, GWLP_WNDPROC));
280
281 hr = SHLimitInputEdit(hEdt1, &sf);
282 ok_int(hr, S_OK);
283
284 ok_long(sf.m_cRefs, 1);
285
286 trace("GWLP_WNDPROC: %p\n", (void *)GetWindowLongPtr(hEdt1, GWLP_WNDPROC));
287
288 EnumPropsW(hEdt1, PropEnumProc);
289
290 n = (INT)SendMessageW(hEdt1, EM_GETLIMITTEXT, 0, 0);
291 ok_int(n, 234);
292 }
293
294 {
295 CShellFolder sf(345, TRUE);
296
297 hr = SHLimitInputEdit(hEdt1, &sf);
299
300 n = (INT)SendMessageW(hEdt1, EM_GETLIMITTEXT, 0, 0);
301 ok_int(n, 234);
302 }
303
304 {
305 CShellFolder sf(999, FALSE);
306
307 ok_long(sf.m_cRefs, 1);
308
309 SetWindowTextW(hEdt1, L"TEST/TEST");
310 hr = SHLimitInputEdit(hEdt1, &sf);
311 ok_int(hr, S_OK);
312 GetWindowTextW(hEdt1, szText, _countof(szText));
313 ok_wstr(szText, L"TEST/TEST");
314
315 ok_long(sf.m_cRefs, 1);
316
317 n = (INT)SendMessageW(hEdt1, EM_GETLIMITTEXT, 0, 0);
318 ok_int(n, 234);
319
320 SetWindowTextW(hEdt1, L"");
321 SendMessageW(hEdt1, WM_CHAR, L'A', 1);
322 GetWindowTextW(hEdt1, szText, _countof(szText));
323 ok_wstr(szText, L"A");
324
325 SendMessageW(hEdt1, WM_CHAR, L'/', 1);
326 GetWindowTextW(hEdt1, szText, _countof(szText));
327 ok_wstr(szText, L"A");
328
329 SendMessageW(hEdt1, WM_CHAR, L'/', 1);
330 GetWindowTextW(hEdt1, szText, _countof(szText));
331 ok_wstr(szText, L"A");
332
333 SendMessageW(hEdt1, WM_CHAR, L'A', 1);
334 GetWindowTextW(hEdt1, szText, _countof(szText));
335 ok_wstr(szText, L"AA");
336 }
337
338 {
339 CShellFolder sf(4, FALSE);
340
341 ok_long(sf.m_cRefs, 1);
342
343 SetWindowTextW(hEdt1, L"ABC");
344 hr = SHLimitInputEdit(hEdt1, &sf);
345
346 SendMessageW(hEdt1, WM_CHAR, L'D', 1);
347 GetWindowTextW(hEdt1, szText, _countof(szText));
348 ok_wstr(szText, L"DABC");
349
350 SendMessageW(hEdt1, WM_CHAR, L'E', 1);
351 GetWindowTextW(hEdt1, szText, _countof(szText));
352 ok_wstr(szText, L"DEABC");
353
354 ok_long(sf.m_cRefs, 1);
355 }
356
358 return TRUE;
359}
static void DoNullFolderTest(HWND hEdt1)
static BOOL CALLBACK PropEnumProc(HWND hwnd, LPCWSTR lpszString, HANDLE hData)
#define ok_long(expression, result)
Definition: atltest.h:133
#define trace
Definition: atltest.h:70
#define ok_wstr(x, y)
Definition: atltest.h:130
#define ok_int(expression, result)
Definition: atltest.h:134
#define E_NOTIMPL
Definition: ddrawi.h:99
#define edt1
Definition: dlgs.h:65
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLdouble n
Definition: glext.h:7729
#define S_OK
Definition: intsafe.h:52
#define L(x)
Definition: ntvdm.h:50
#define INT
Definition: polytest.cpp:20
#define EM_GETLIMITTEXT
Definition: richedit.h:74
HRESULT WINAPI SHLimitInputEdit(HWND hWnd, IShellFolder *psf)
Definition: shellord.c:2826
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:70
#define GetWindowLongPtr
Definition: treelist.c:73
#define GWLP_WNDPROC
Definition: treelist.c:66
int32_t INT
Definition: typedefs.h:58
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define EM_LIMITTEXT
Definition: winuser.h:2000
int WINAPI EnumPropsW(_In_ HWND, _In_ PROPENUMPROCW)
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define IDABORT
Definition: winuser.h:832
#define WM_CHAR
Definition: winuser.h:1717
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ DoNullFolderTest()

static void DoNullFolderTest ( HWND  hEdt1)
static

Definition at line 242 of file SHLimitInputEdit.cpp.

243{
244 HRESULT hr;
245
247 {
248 hr = SHLimitInputEdit(hEdt1, NULL);
249 }
251 {
252 hr = 0xDEAD;
253 }
254 _SEH2_END;
255
256 ok_int(hr, 0xDEAD);
257}
#define NULL
Definition: types.h:112
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66

Referenced by DialogProc().

◆ PropEnumProc()

static BOOL CALLBACK PropEnumProc ( HWND  hwnd,
LPCWSTR  lpszString,
HANDLE  hData 
)
static

Definition at line 232 of file SHLimitInputEdit.cpp.

236{
237 trace("PropEnumProc: '%S' --> %p\n", lpszString, hData);
238 return TRUE;
239}

Referenced by DialogProc().

◆ START_TEST()

START_TEST ( SHLimitInputEdit  )

Definition at line 361 of file SHLimitInputEdit.cpp.

362{
363 HRESULT hr;
364
366 {
368 }
370 {
371 hr = 0xDEAD;
372 }
373 _SEH2_END;
374 ok_int(hr, 0xDEAD);
375
377 {
378 hr = SHLimitInputEdit((HWND)0xDEAD, NULL);
379 }
381 {
382 hr = 0xDEAD;
383 }
384 _SEH2_END;
385 ok_int(hr, 0xDEAD);
386
388}
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399

◆ STDMETHODIMP_()

STDMETHODIMP_ ( ULONG  )

Definition at line 180 of file SHLimitInputEdit.cpp.

181{
182 trace("AddRef\n");
183 return ++m_cRefs;
184}