Module: wine Branch: master Commit: d645cd149b538900d26d4e5d4ff351410f2d2a95 URL: https://gitlab.winehq.org/wine/wine/-/commit/d645cd149b538900d26d4e5d4ff3514...
Author: Rémi Bernon rbernon@codeweavers.com Date: Sun Nov 27 21:31:59 2022 +0100
joy.cpl: Use designated initializers in display_cpl_sheets.
---
dlls/joy.cpl/main.c | 118 ++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 64 deletions(-)
diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index 279b5c07e22..f0620b1e3fa 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -950,73 +950,63 @@ static int CALLBACK propsheet_callback(HWND hwnd, UINT msg, LPARAM lparam) return 0; }
-/****************************************************************************** - * display_cpl_sheets [internal] - * - * Build and display the dialog with all control panel propertysheets - * - */ -static void display_cpl_sheets(HWND parent, struct JoystickData *data) +static void display_cpl_sheets( HWND parent, struct JoystickData *data ) { - INITCOMMONCONTROLSEX icex; - BOOL activated = FALSE; - PROPSHEETPAGEW psp[2]; - PROPSHEETHEADERW psh; + INITCOMMONCONTROLSEX init = + { + .dwSize = sizeof(INITCOMMONCONTROLSEX), + .dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES, + }; + PROPSHEETPAGEW pages[] = + { + { + .dwSize = sizeof(PROPSHEETPAGEW), + .hInstance = hcpl, + .u.pszTemplate = MAKEINTRESOURCEW( IDD_LIST ), + .pfnDlgProc = list_dlgproc, + .lParam = (INT_PTR)data, + }, + { + .dwSize = sizeof(PROPSHEETPAGEW), + .hInstance = hcpl, + .u.pszTemplate = MAKEINTRESOURCEW( IDD_TEST_DI ), + .pfnDlgProc = test_dlgproc, + .lParam = (INT_PTR)data, + }, + }; + PROPSHEETHEADERW header = + { + .dwSize = sizeof(PROPSHEETHEADERW), + .dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK, + .hwndParent = parent, + .hInstance = hcpl, + .pszCaption = MAKEINTRESOURCEW( IDS_CPL_NAME ), + .nPages = ARRAY_SIZE(pages), + .u3.ppsp = pages, + .pfnCallback = propsheet_callback, + }; + ACTCTXW context_desc = + { + .cbSize = sizeof(ACTCTXW), + .hModule = hcpl, + .lpResourceName = MAKEINTRESOURCEW( 124 ), + .dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID, + }; ULONG_PTR cookie; - ACTCTXW actctx; HANDLE context; - DWORD id = 0; - - OleInitialize(NULL); - /* Activate context */ - memset(&actctx, 0, sizeof(actctx)); - actctx.cbSize = sizeof(actctx); - actctx.hModule = hcpl; - actctx.lpResourceName = MAKEINTRESOURCEW(124); - actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID; - context = CreateActCtxW(&actctx); - if (context != INVALID_HANDLE_VALUE) - activated = ActivateActCtx(context, &cookie); - - /* Initialize common controls */ - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES; - InitCommonControlsEx(&icex); - - ZeroMemory(&psh, sizeof(psh)); - ZeroMemory(psp, sizeof(psp)); - - /* Fill out all PROPSHEETPAGE */ - psp[id].dwSize = sizeof (PROPSHEETPAGEW); - psp[id].hInstance = hcpl; - psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_LIST); - psp[id].pfnDlgProc = list_dlgproc; - psp[id].lParam = (INT_PTR) data; - id++; - - psp[id].dwSize = sizeof (PROPSHEETPAGEW); - psp[id].hInstance = hcpl; - psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_TEST_DI); - psp[id].pfnDlgProc = test_dlgproc; - psp[id].lParam = (INT_PTR) data; - id++; - - /* Fill out the PROPSHEETHEADER */ - psh.dwSize = sizeof (PROPSHEETHEADERW); - psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK; - psh.hwndParent = parent; - psh.hInstance = hcpl; - psh.pszCaption = MAKEINTRESOURCEW(IDS_CPL_NAME); - psh.nPages = id; - psh.u3.ppsp = psp; - psh.pfnCallback = propsheet_callback; - - /* display the dialog */ - PropertySheetW(&psh); - - if (activated) - DeactivateActCtx(0, cookie); - ReleaseActCtx(context); + BOOL activated; + + OleInitialize( NULL ); + + context = CreateActCtxW( &context_desc ); + if (context == INVALID_HANDLE_VALUE) activated = FALSE; + else activated = ActivateActCtx( context, &cookie ); + + InitCommonControlsEx( &init ); + PropertySheetW( &header ); + + if (activated) DeactivateActCtx( 0, cookie ); + ReleaseActCtx( context ); OleUninitialize(); }