@@ -372,59 +372,52 @@ void MultiReplace::initializeCtrlMap() {
372
372
}
373
373
374
374
bool MultiReplace::createAndShowWindows () {
375
+ // IDs of all controls in the “Replace/Find in Files” panel
376
+ static const std::vector<int > repInFilesIds = {
377
+ IDC_REPLACE_IN_FILES_GROUP,
378
+ IDC_FILTER_STATIC, IDC_FILTER_EDIT, IDC_FILTER_HELP,
379
+ IDC_DIR_STATIC, IDC_DIR_EDIT, IDC_BROWSE_DIR_BUTTON,
380
+ IDC_SUBFOLDERS_CHECKBOX, IDC_HIDDENFILES_CHECKBOX,
381
+ IDC_CANCEL_REPLACE_BUTTON
382
+ };
383
+
384
+ const bool twoButtonsMode = (IsDlgButtonChecked (_hSelf, IDC_2_BUTTONS_MODE) == BST_CHECKED);
385
+ const bool initialShow = (isReplaceInFiles || isFindAllInFiles) && !twoButtonsMode;
386
+
387
+ auto isRepInFilesId = [&](int id) {
388
+ return std::find (repInFilesIds.begin (), repInFilesIds.end (), id) != repInFilesIds.end ();
389
+ };
375
390
376
391
for (auto & pair : ctrlMap)
377
392
{
378
- HWND hwndControl = CreateWindowEx (
379
- 0 , // No additional window styles.
380
- pair.second .className , // Window class
381
- pair.second .windowName , // Window text
382
- pair.second .style | WS_CHILD | WS_VISIBLE, // Window style
383
- pair.second .x , // x position
384
- pair.second .y , // y position
385
- pair.second .cx , // width
386
- pair.second .cy , // height
387
- _hSelf, // Parent window
388
- (HMENU)(INT_PTR)pair.first , // Menu, or child-window identifier
389
- hInstance, // The window instance.
390
- NULL // Additional application data.
391
- );
393
+ const bool isFilesCtrl = isRepInFilesId (pair.first );
392
394
393
- if (hwndControl == NULL )
394
- {
395
- DWORD dwError = GetLastError ();
396
- std::wstring errorMsg = LM.get (L" msgbox_failed_create_control" , { std::to_wstring (pair.first ), std::to_wstring (dwError) });
397
- MessageBox (nppData._nppHandle , errorMsg.c_str (), LM.get (L" msgbox_title_error" ).c_str (), MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
398
- return false ;
395
+ // Create all controls as children, but only set WS_VISIBLE if needed
396
+ DWORD style = pair.second .style | WS_CHILD;
397
+ if (!isFilesCtrl || initialShow) {
398
+ style |= WS_VISIBLE;
399
399
}
400
400
401
- // Only create tooltips if enabled and text is available
402
- if ((tooltipsEnabled || pair.first == IDC_FILTER_HELP) && pair.second .tooltipText != nullptr && pair.second .tooltipText [0 ] != ' \0 ' )
403
- {
404
- HWND hwndTooltip = CreateWindowEx (
405
- NULL , TOOLTIPS_CLASS, NULL ,
406
- WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON | TTS_NOPREFIX,
407
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
408
- _hSelf, NULL , hInstance, NULL );
401
+ HWND hwndControl = CreateWindowEx (
402
+ 0 ,
403
+ pair.second .className ,
404
+ pair.second .windowName ,
405
+ style,
406
+ pair.second .x , pair.second .y , pair.second .cx , pair.second .cy ,
407
+ _hSelf,
408
+ (HMENU)(INT_PTR)pair.first ,
409
+ hInstance,
410
+ NULL
411
+ );
412
+ if (!hwndControl) {
413
+ return false ; // Handle creation error
414
+ }
409
415
410
- if (hwndTooltip)
411
- {
412
- // limit width only for the "?" help tooltip
413
- DWORD maxWidth = (pair.first == IDC_FILTER_HELP) ? 200 /* px*/ : 0 ; // 0 = unlimited
414
- SendMessage (hwndTooltip, TTM_SETMAXTIPWIDTH, 0 , maxWidth);
415
-
416
- TOOLINFO toolInfo = { 0 };
417
- toolInfo.cbSize = sizeof (toolInfo);
418
- toolInfo.hwnd = _hSelf;
419
- toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
420
- toolInfo.uId = (UINT_PTR)hwndControl;
421
- toolInfo.lpszText = (LPWSTR)pair.second .tooltipText ;
422
- SendMessage (hwndTooltip, TTM_ADDTOOL, 0 , (LPARAM)&toolInfo);
423
- }
424
- }
425
- // Show the window
426
- ShowWindow (hwndControl, SW_SHOW);
427
- UpdateWindow (hwndControl);
416
+ // Show/Update only if we really want the control visible
417
+ if (!isFilesCtrl || initialShow) {
418
+ ShowWindow (hwndControl, SW_SHOW);
419
+ UpdateWindow (hwndControl);
420
+ }
428
421
}
429
422
return true ;
430
423
}
0 commit comments