Index: rostests/apitests/shell32/CMakeLists.txt =================================================================== --- rostests/apitests/shell32/CMakeLists.txt (revision 73453) +++ rostests/apitests/shell32/CMakeLists.txt (working copy) @@ -12,8 +12,9 @@ ShellExecuteEx.cpp shelltest.cpp SHParseDisplayName.cpp + WMSettingChange.cpp testlist.c) target_link_libraries(shell32_apitest wine uuid ${PSEH_LIB}) set_module_type(shell32_apitest win32cui) -add_importlibs(shell32_apitest user32 gdi32 shell32 ole32 oleaut32 advapi32 shlwapi msvcrt kernel32 ntdll) +add_importlibs(shell32_apitest user32 gdi32 shell32 ole32 oleaut32 comctl32 advapi32 shlwapi msvcrt kernel32 ntdll) add_cd_file(TARGET shell32_apitest DESTINATION reactos/bin FOR all) Index: rostests/apitests/shell32/testlist.c =================================================================== --- rostests/apitests/shell32/testlist.c (revision 73453) +++ rostests/apitests/shell32/testlist.c (working copy) @@ -10,6 +10,7 @@ extern void func_menu(void); extern void func_ShellExecuteEx(void); extern void func_SHParseDisplayName(void); +extern void func_WMSettingChange(void); const struct test winetest_testlist[] = { @@ -20,5 +21,6 @@ { "menu", func_menu }, { "ShellExecuteEx", func_ShellExecuteEx }, { "SHParseDisplayName", func_SHParseDisplayName }, + { "WMSettingChange", func_WMSettingChange }, { 0, 0 } }; Index: rostests/apitests/shell32/WMSettingChange.cpp =================================================================== --- rostests/apitests/shell32/WMSettingChange.cpp (nonexistent) +++ rostests/apitests/shell32/WMSettingChange.cpp (working copy) @@ -0,0 +1,154 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for WM_SETTINGCHANGE + * PROGRAMMER: Mark Jansen + */ + +#include "shelltest.h" +#include +#include +#include +#include + +#define NDEBUG +#include +#include + +#define ok_hr(status, expected) ok_hex(status, expected) + +static HWND g_Window; + + + +static void run_tests() +{ + char buf[100]; + DWORD dwRet = GetEnvironmentVariableA("apitest_var", buf, _countof(buf)); + DWORD dwErr = GetLastError(); + ok_hex(dwRet, 0); + ok_hex(dwErr, ERROR_ENVVAR_NOT_FOUND); + + // Set the variable in the env. + SetEnvironmentVariableA("apitest_var", "some randome value"); + dwRet = GetEnvironmentVariableA("apitest_var", buf, _countof(buf)); + ok_hex(dwRet, 0x12); + ok_str(buf, "some randome value"); + + SendMessageW(g_Window, WM_SETTINGCHANGE, NULL, (LPARAM)L"Environment"); + + dwRet = GetEnvironmentVariableA("apitest_var", buf, _countof(buf)); + dwErr = GetLastError(); + ok_hex(dwRet, 0); + ok_hex(dwErr, ERROR_ENVVAR_NOT_FOUND); +} + +const GUID IID_IShellDesktopTray = { 0x213e2df9, 0x9a14, 0x4328, { 0x99, 0xb1, 0x69, 0x61, 0xf9, 0x14, 0x3c, 0xe9 } }; + +class IShellDesktopTray +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) + { + if (riid == IID_IUnknown || riid == IID_IShellDesktopTray) + { + *ppvObject = this; + return S_OK; + } + return E_NOINTERFACE; + } + STDMETHOD_(ULONG, AddRef) (THIS) { return 2; } + STDMETHOD_(ULONG, Release) (THIS) { return 1; } + + /*** ITrayWindow methods ***/ + STDMETHOD_(HRESULT, Open) (THIS) { return E_NOTIMPL; } + STDMETHOD_(HRESULT, Close) (THIS) { return E_NOTIMPL; } + STDMETHOD_(HWND, GetHWND) (THIS) { return NULL; } + STDMETHOD_(BOOL, IsSpecialHWND) (THIS_ HWND hWnd) { return E_NOTIMPL; } + STDMETHOD_(BOOL, IsHorizontal) (THIS) { return E_NOTIMPL; } + STDMETHOD_(HFONT, GetCaptionFonts) (THIS_ HFONT *phBoldCaption) { return NULL; } + STDMETHOD_(HWND, DisplayProperties) (THIS) { return NULL; } + STDMETHOD_(BOOL, ExecContextMenuCmd) (THIS_ UINT uiCmd) { return TRUE; } + STDMETHOD_(BOOL, Lock) (THIS_ BOOL bLock) { return TRUE; } +}; + +static UINT g_TestMessage; + +LRESULT CALLBACK test_SubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) +{ + if (uMsg == WM_NCDESTROY) + RemoveWindowSubclass(hWnd, test_SubClassProc, uIdSubclass); + + if (uMsg == g_TestMessage) + { + run_tests(); + PostQuitMessage(0); + } + + return DefSubclassProc(hWnd, uMsg, wParam, lParam); +} + +typedef HANDLE(WINAPI * PSHCREATEDESKTOP)(IShellDesktopTray *ShellDesk); + +struct CCoInit +{ + CCoInit() { hres = CoInitialize(NULL); } + ~CCoInit() { if (SUCCEEDED(hres)) { CoUninitialize(); } } + HRESULT hres; +}; + +START_TEST(WMSettingChange) +{ + CCoInit init; + + PSHCREATEDESKTOP SHCreateDesktop = (PSHCREATEDESKTOP) GetProcAddress(LoadLibraryA("shell32.dll"), MAKEINTRESOURCEA(200)); + + IShellDesktopTray tray; + CComPtr browser; + browser.Attach(static_cast(SHCreateDesktop(&tray))); + ok(browser.p != NULL, "Expected an IShellBrowser\n"); + if (!browser.p) + return; + + CComPtr shellView; + HRESULT hr = browser->QueryActiveShellView(&shellView); + ok_hr(hr, S_OK); + if (!SUCCEEDED(hr)) + return; + + hr = browser->GetWindow(&g_Window); + ok_hr(hr, S_OK); + if (!SUCCEEDED(hr)) + return; + + char buf[100]; + GetWindowTextA(g_Window, buf, 100); + ok_str(buf, "Program Manager"); + + RealGetWindowClassA(g_Window, buf, 100); + ok_str(buf, "Progman"); + + DWORD pid; + GetWindowThreadProcessId(g_Window, &pid); + ok_hex(pid, GetCurrentProcessId()); + + g_TestMessage = RegisterWindowMessageW(L"apitest_cb_msg"); + SetWindowSubclass(g_Window, test_SubClassProc, 1, 0); + + // kick off the test loop + PostMessage(g_Window, g_TestMessage, 0, 0); + + MSG Msg; + BOOL bRet; + while ((bRet = GetMessageW(&Msg, NULL, 0, 0)) != 0) + { + if (bRet != -1) + { + if (shellView->TranslateAccelerator(&Msg) != S_OK) + { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } + } +}