Prevent unnecessary refreshes that move focus.
Spillover from having more interactive controls. In WiX v3, showing a page moved the focus as a typical person might expect. When WiX v4 added interactivity, the same code was used to update controls (e.g., when checking a checkbox set a property used in a `VisibleCondition` or `EnableCondition` for another control on the same page). This change prevents the focus-setting behavior if the same page is being shown. Fixes https://github.com/wixtoolset/issues/issues/8144
Bob Arnson committed
Jul 9, 2024 at 15:07 UTC
69328a4ef1d7282aec356ee046f73bf914218b03
1 file changed
+9
-6
src/libs/dutil/WixToolset.DUtil/thmutil.cpp
+9
-6
@@ -312,13 +312,14 @@ static HRESULT ShowControl(
312
__in BOOL fSaveEditboxes,
313
__in THEME_SHOW_PAGE_REASON reason,
314
__in DWORD dwPageId,
315
- __out_opt HWND* phwndFocus
315
+ __inout_opt HWND* phwndFocus
316
);
317
static HRESULT ShowControls(
318
__in THEME* pTheme,
319
__in_opt const THEME_CONTROL* pParentControl,
320
__in int nCmdShow,
321
__in BOOL fSaveEditboxes,
322
+ __in BOOL fSetFocus,
323
__in THEME_SHOW_PAGE_REASON reason,
324
__in DWORD dwPageId
325
);
@@ -1192,8 +1193,9 @@ DAPI_(HRESULT) ThemeShowPageEx(
1193
BOOL fHide = SW_HIDE == nCmdShow;
1194
BOOL fSaveEditboxes = FALSE;
1195
THEME_SAVEDVARIABLE* pSavedVariable = NULL;
1195
- THEME_PAGE* pPage = ThemeGetPage(pTheme, dwPage);
1196
SIZE_T cb = 0;
1197
+ BOOL fSetFocus = dwPage != pTheme->dwCurrentPageId;
1198
+ THEME_PAGE* pPage = ThemeGetPage(pTheme, dwPage);
1199
1200
if (pPage)
1201
{
@@ -1257,7 +1259,7 @@ DAPI_(HRESULT) ThemeShowPageEx(
1259
}
1260
}
1261
1260
- hr = ShowControls(pTheme, NULL, nCmdShow, fSaveEditboxes, reason, dwPage);
1262
+ hr = ShowControls(pTheme, NULL, nCmdShow, fSaveEditboxes, fSetFocus, reason, dwPage);
1263
ThmExitOnFailure(hr, "Failed to show page controls.");
1264
1265
LExit:
@@ -5561,7 +5563,7 @@ static HRESULT ShowControl(
5563
__in BOOL fSaveEditboxes,
5564
__in THEME_SHOW_PAGE_REASON reason,
5565
__in DWORD dwPageId,
5564
- __out_opt HWND* phwndFocus
5566
+ __inout_opt HWND* phwndFocus
5567
)
5568
{
5569
HRESULT hr = S_OK;
@@ -5810,7 +5812,7 @@ static HRESULT ShowControl(
5812
5813
if (0 < pControl->cControls)
5814
{
5813
- ShowControls(pTheme, pControl, nCmdShow, fSaveEditboxes, reason, dwPageId);
5815
+ ShowControls(pTheme, pControl, nCmdShow, fSaveEditboxes, FALSE/*fSetFocus*/, reason, dwPageId);
5816
}
5817
5818
if (THEME_CONTROL_TYPE_BILLBOARD == pControl->type && pControl->wPageId)
@@ -5842,6 +5844,7 @@ static HRESULT ShowControls(
5844
__in_opt const THEME_CONTROL* pParentControl,
5845
__in int nCmdShow,
5846
__in BOOL fSaveEditboxes,
5847
+ __in BOOL fSetFocus,
5848
__in THEME_SHOW_PAGE_REASON reason,
5849
__in DWORD dwPageId
5850
)
@@ -5865,7 +5868,7 @@ static HRESULT ShowControls(
5868
}
5869
}
5870
5868
- if (hwndFocus)
5871
+ if (fSetFocus && hwndFocus)
5872
{
5873
::SendMessage(pTheme->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwndFocus, TRUE);
5874
}