22 * PROJECT: ReactOS API tests
33 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
44 * PURPOSE: Tests for ShowWindow
5- * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <[email protected] > 5+ * COPYRIGHT: Copyright 2021-2025 Katayama Hirofumi MZ <[email protected] > 66 */
77
88#include "precomp.h"
9+ #include <versionhelpers.h>
910
1011typedef struct TEST_ENTRY
1112{
@@ -164,7 +165,7 @@ WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
164165 return 0 ;
165166}
166167
167- START_TEST ( ShowWindow )
168+ static VOID Test_ShowWindow_Main ( VOID )
168169{
169170 WNDCLASSA wc ;
170171 UINT iTest ;
@@ -181,3 +182,164 @@ START_TEST(ShowWindow)
181182 DoTestEntry (& s_entries [iTest ]);
182183 }
183184}
185+
186+ #define RED RGB(255, 0, 0)
187+
188+ static COLORREF CheckColor (VOID )
189+ {
190+ HDC hDC = GetDC (NULL );
191+ COLORREF color = GetPixel (hDC , 100 , 100 );
192+ ReleaseDC (NULL , hDC );
193+ return color ;
194+ }
195+
196+ static DWORD WINAPI
197+ ForceMinimizeThreadFunc (LPVOID arg )
198+ {
199+ BOOL ret ;
200+ HWND hwnd = (HWND )arg ;
201+ DWORD style , exstyle ;
202+
203+ Sleep (100 );
204+ ok_long (CheckColor (), RED );
205+
206+ SetWindowLongPtrW (hwnd , GWL_EXSTYLE , WS_EX_MAKEVISIBLEWHENUNGHOSTED );
207+ ret = ShowWindow (hwnd , SW_FORCEMINIMIZE );
208+ Sleep (100 );
209+ ok (ret != FALSE, "ret was FALSE\n" );
210+ ok (CheckColor () != RED , "Color was red\n" );
211+ style = GetWindowLongPtrW (hwnd , GWL_STYLE );
212+ if (IsWindowsVistaOrGreater ())
213+ ok ((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE )) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE ), "style was 0x%08lX\n" , style );
214+ else
215+ ok ((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE )) == (WS_POPUP ), "style was 0x%08lX\n" , style );
216+ exstyle = GetWindowLongPtrW (hwnd , GWL_EXSTYLE );
217+ ok_long (exstyle , 0 );
218+
219+ ShowWindow (hwnd , SW_MINIMIZE );
220+ Sleep (100 );
221+ ok (CheckColor () != RED , "Color was red\n" );
222+
223+ SetWindowLongPtrW (hwnd , GWL_EXSTYLE , WS_EX_MAKEVISIBLEWHENUNGHOSTED );
224+ ret = ShowWindow (hwnd , SW_FORCEMINIMIZE );
225+ Sleep (100 );
226+ ok (ret != FALSE, "ret was FALSE\n" );
227+ ok (CheckColor () != RED , "Color was red\n" );
228+ style = GetWindowLongPtrW (hwnd , GWL_STYLE );
229+ ok ((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE )) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE ), "style was 0x%08lX\n" , style );
230+ exstyle = GetWindowLongPtrW (hwnd , GWL_EXSTYLE );
231+ ok_long (exstyle , 0 );
232+
233+ ShowWindow (hwnd , SW_SHOWNORMAL );
234+ Sleep (100 );
235+ ok_long (CheckColor (), RED );
236+
237+ SetWindowLongPtrW (hwnd , GWL_EXSTYLE , WS_EX_MAKEVISIBLEWHENUNGHOSTED );
238+ ret = ShowWindow (hwnd , SW_FORCEMINIMIZE );
239+ Sleep (100 );
240+ ok (ret != FALSE, "ret was FALSE\n" );
241+ ok (CheckColor () != RED , "Color was red\n" );
242+ style = GetWindowLongPtrW (hwnd , GWL_STYLE );
243+ if (IsWindowsVistaOrGreater ())
244+ ok ((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE )) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE ), "style was 0x%08lX\n" , style );
245+ else
246+ ok ((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE )) == (WS_POPUP ), "style was 0x%08lX\n" , style );
247+ exstyle = GetWindowLongPtrW (hwnd , GWL_EXSTYLE );
248+ ok_long (exstyle , 0 );
249+
250+ SetWindowLongPtrW (hwnd , GWL_EXSTYLE , WS_EX_MAKEVISIBLEWHENUNGHOSTED );
251+ ret = ShowWindow (hwnd , SW_FORCEMINIMIZE );
252+ Sleep (100 );
253+ if (IsWindowsVistaOrGreater ())
254+ ok (ret != FALSE, "ret was FALSE\n" );
255+ else
256+ ok_bool_false (ret , "Return was" );
257+ ok (CheckColor () != RED , "Color was red\n" );
258+ style = GetWindowLongPtrW (hwnd , GWL_STYLE );
259+ if (IsWindowsVistaOrGreater ())
260+ ok ((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE )) == (WS_POPUP | WS_MINIMIZE | WS_VISIBLE ), "style was 0x%08lX\n" , style );
261+ else
262+ ok ((style & (WS_POPUP | WS_MINIMIZE | WS_VISIBLE )) == (WS_POPUP ), "style was 0x%08lX\n" , style );
263+ exstyle = GetWindowLongPtrW (hwnd , GWL_EXSTYLE );
264+ ok_long (exstyle , 0 );
265+
266+ PostMessageW (hwnd , WM_CLOSE , 0 , 0 );
267+ return 0 ;
268+ }
269+
270+ static LRESULT CALLBACK
271+ ForceMinimizeWndProc (HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam )
272+ {
273+ switch (uMsg )
274+ {
275+ case WM_DESTROY :
276+ PostQuitMessage (0 );
277+ break ;
278+ default :
279+ return DefWindowProcW (hwnd , uMsg , wParam , lParam );
280+ }
281+ return 0 ;
282+ }
283+
284+ static VOID
285+ Test_WS_FORCEMINIMIZE_Sub (HBRUSH hbr )
286+ {
287+ WNDCLASSW wc ;
288+ HWND hwnd ;
289+ DWORD style ;
290+ HINSTANCE hInstance = GetModuleHandleW (NULL );
291+ DWORD dwThreadId ;
292+ HANDLE hThread ;
293+ MSG msg ;
294+
295+ ZeroMemory (& wc , sizeof (wc ));
296+ wc .lpfnWndProc = ForceMinimizeWndProc ;
297+ wc .hInstance = hInstance ;
298+ wc .hIcon = LoadIconW (NULL , (PCWSTR )IDI_APPLICATION );
299+ wc .hCursor = LoadCursorW (NULL , (PCWSTR )IDC_ARROW );
300+ wc .hbrBackground = hbr ;
301+ wc .lpszClassName = L"SW_FORCEMINIMIZE" ;
302+ if (!RegisterClassW (& wc ))
303+ {
304+ skip ("RegisterClassW failed\n" );
305+ return ;
306+ }
307+
308+ style = WS_POPUP | WS_VISIBLE ;
309+ hwnd = CreateWindowExW (0 , L"SW_FORCEMINIMIZE" , L"SW_FORCEMINIMIZE" , style ,
310+ 50 , 50 , 100 , 100 , NULL , NULL , hInstance , NULL );
311+ if (!hwnd )
312+ {
313+ skip ("CreateWindowExW failed\n" );
314+ return ;
315+ }
316+
317+ hThread = CreateThread (NULL , 0 , ForceMinimizeThreadFunc , hwnd , 0 , & dwThreadId );
318+ if (!hThread )
319+ {
320+ skip ("CreateThread failed\n" );
321+ DestroyWindow (hwnd );
322+ return ;
323+ }
324+ CloseHandle (hThread );
325+
326+ while (GetMessageW (& msg , NULL , 0 , 0 ))
327+ {
328+ TranslateMessage (& msg );
329+ DispatchMessageW (& msg );
330+ }
331+ }
332+
333+ static VOID
334+ Test_WS_FORCEMINIMIZE ()
335+ {
336+ HBRUSH hbr = CreateSolidBrush (RED );
337+ Test_WS_FORCEMINIMIZE_Sub (hbr );
338+ DeleteObject (hbr );
339+ }
340+
341+ START_TEST (ShowWindow )
342+ {
343+ Test_ShowWindow_Main ();
344+ Test_WS_FORCEMINIMIZE ();
345+ }
0 commit comments