ReactOS  0.4.15-dev-321-g2d9b385
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);
298  ok_int(hr, E_NOTIMPL);
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);
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);
323  ok_wstr(szText, L"A");
324 
325  SendMessageW(hEdt1, WM_CHAR, L'/', 1);
327  ok_wstr(szText, L"A");
328 
329  SendMessageW(hEdt1, WM_CHAR, L'/', 1);
331  ok_wstr(szText, L"A");
332 
333  SendMessageW(hEdt1, WM_CHAR, L'A', 1);
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);
348  ok_wstr(szText, L"DABC");
349 
350  SendMessageW(hEdt1, WM_CHAR, L'E', 1);
352  ok_wstr(szText, L"DEABC");
353 
354  ok_long(sf.m_cRefs, 1);
355  }
356 
358  return TRUE;
359 }
#define EM_LIMITTEXT
Definition: winuser.h:1982
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define IDABORT
Definition: winuser.h:826
HRESULT WINAPI SHLimitInputEdit(HWND hWnd, IShellFolder *psf)
Definition: shellord.c:2689
#define WM_CHAR
Definition: winuser.h:1699
HRESULT hr
Definition: shlfolder.c:183
UINT uMsg
Definition: menu.cpp:213
#define INT
Definition: polytest.cpp:20
GLdouble n
Definition: glext.h:7729
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define ok_long(expression, result)
Definition: atltest.h:133
int32_t INT
Definition: typedefs.h:57
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
static const WCHAR szText[]
Definition: dialog.c:139
#define ok_int(expression, result)
Definition: atltest.h:134
static BOOL CALLBACK PropEnumProc(HWND hwnd, LPCWSTR lpszString, HANDLE hData)
#define trace
Definition: atltest.h:70
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void DoNullFolderTest(HWND hEdt1)
LONG HRESULT
Definition: typedefs.h:78
#define _countof(array)
Definition: sndvol32.h:68
#define EM_GETLIMITTEXT
Definition: richedit.h:74
#define edt1
Definition: dlgs.h:65
static const WCHAR L[]
Definition: oid.c:1250
#define ok_wstr(x, y)
Definition: atltest.h:130
#define GWLP_WNDPROC
Definition: treelist.c:66
int WINAPI EnumPropsW(_In_ HWND, _In_ PROPENUMPROCW)
#define S_OK
Definition: intsafe.h:59
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define E_NOTIMPL
Definition: ddrawi.h:99
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_INITDIALOG
Definition: winuser.h:1721

Referenced by START_TEST().

◆ DoNullFolderTest()

static void DoNullFolderTest ( HWND  hEdt1)
static

Definition at line 242 of file SHLimitInputEdit.cpp.

243 {
244  HRESULT hr;
245 
246  _SEH2_TRY
247  {
248  hr = SHLimitInputEdit(hEdt1, NULL);
249  }
251  {
252  hr = 0xDEAD;
253  }
254  _SEH2_END;
255 
256  ok_int(hr, 0xDEAD);
257 }
HRESULT WINAPI SHLimitInputEdit(HWND hWnd, IShellFolder *psf)
Definition: shellord.c:2689
HRESULT hr
Definition: shlfolder.c:183
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
LONG HRESULT
Definition: typedefs.h:78
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

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 }
#define TRUE
Definition: types.h:120
#define trace
Definition: atltest.h:70

Referenced by DialogProc().

◆ START_TEST()

START_TEST ( SHLimitInputEdit  )

Definition at line 361 of file SHLimitInputEdit.cpp.

362 {
363  HRESULT hr;
364 
365  _SEH2_TRY
366  {
368  }
370  {
371  hr = 0xDEAD;
372  }
373  _SEH2_END;
374  ok_int(hr, 0xDEAD);
375 
376  _SEH2_TRY
377  {
378  hr = SHLimitInputEdit((HWND)0xDEAD, NULL);
379  }
381  {
382  hr = 0xDEAD;
383  }
384  _SEH2_END;
385  ok_int(hr, 0xDEAD);
386 
388 }
HRESULT WINAPI SHLimitInputEdit(HWND hWnd, IShellFolder *psf)
Definition: shellord.c:2689
HRESULT hr
Definition: shlfolder.c:183
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4374
LONG HRESULT
Definition: typedefs.h:78
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static const WCHAR L[]
Definition: oid.c:1250
_SEH2_END
Definition: create.c:4424
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

◆ STDMETHODIMP_()

STDMETHODIMP_ ( ULONG  )

Definition at line 180 of file SHLimitInputEdit.cpp.

181 {
182  trace("AddRef\n");
183  return ++m_cRefs;
184 }
#define trace
Definition: atltest.h:70