-
-
Notifications
You must be signed in to change notification settings - Fork 565
/
SetPgBase.cpp
629 lines (550 loc) · 16.3 KB
/
SetPgBase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
/*
Copyright (c) 2016-2017 Maximus5
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define HIDE_USE_EXCEPTION_INFO
#define SHOWDEBUGSTR
#include "Header.h"
#include "../common/MSetter.h"
#include "ConEmu.h"
#include "DlgItemHelper.h"
#include "DynDialog.h"
#include "LngRc.h"
#include "Options.h"
#include "OptionsClass.h"
#include "OptionsHelp.h"
#include "RealConsole.h"
#include "SearchCtrl.h"
#include "SetDlgColors.h"
#include "SetPgApps.h"
#include "SetPgBase.h"
#include "SetPgDebug.h"
#include "SetPgFonts.h"
#include "SetPgKeys.h"
bool CSetPgBase::mb_IgnoreEditChanged = false;
CSetPgBase::CSetPgBase()
: mh_Dlg(NULL)
, mh_Parent(NULL)
, mb_SkipSelChange(false)
, mb_DpiChanged(false)
, mn_ActivateTabMsg(WM_APP)
, mp_DpiAware(NULL)
, mp_DynDialog(NULL)
, mp_ParentDpi(NULL)
, mp_InfoPtr(NULL)
{
mb_IgnoreEditChanged = false;
}
CSetPgBase::~CSetPgBase()
{
if (mp_DpiAware)
{
mp_DpiAware->Detach();
SafeDelete(mp_DpiAware);
}
SafeDelete(mp_DynDialog);
}
HWND CSetPgBase::CreatePage(ConEmuSetupPages* p, HWND ahParent, UINT anActivateTabMsg, const CDpiForDialog* apParentDpi)
{
wchar_t szLog[80]; _wsprintf(szLog, SKIPCOUNT(szLog) L"Creating child dialog ID=%u", p->DialogID);
LogString(szLog);
SafeDelete(p->pPage);
p->pPage = p->CreateObj();
p->pPage->InitObject(ahParent, anActivateTabMsg, apParentDpi, p);
p->pPage->mp_DynDialog = CDynDialog::ShowDialog(p->DialogID, ahParent, pageOpProc, (LPARAM)p->pPage);
p->hPage = p->pPage->Dlg();
return p->hPage;
}
void CSetPgBase::InitObject(HWND ahParent, UINT anActivateTabMsg, const CDpiForDialog* apParentDpi, ConEmuSetupPages* apInfoPtr)
{
mh_Parent = ahParent;
mn_ActivateTabMsg = anActivateTabMsg;
mp_ParentDpi = apParentDpi;
mp_InfoPtr = apInfoPtr;
if (apParentDpi)
{
CDpiForDialog::Create(mp_DpiAware);
mb_DpiChanged = false;
}
else
{
SafeDelete(mp_DpiAware);
}
}
void CSetPgBase::OnDpiChanged(const CDpiForDialog* apDpi)
{
if (!this || !mh_Dlg || !mp_DpiAware || !apDpi)
return;
mb_DpiChanged = true;
if (IsWindowVisible(mh_Dlg))
{
ProcessDpiChange(apDpi);
}
}
void CSetPgBase::ProcessDpiChange(const CDpiForDialog* apDpi)
{
if (!this || !mh_Dlg || !mp_DpiAware || !apDpi)
return;
HWND hPlace = GetDlgItem(mh_Parent, tSetupPagePlace);
RECT rcClient; GetWindowRect(hPlace, &rcClient);
MapWindowPoints(NULL, mh_Parent, (LPPOINT)&rcClient, 2);
mb_DpiChanged = false;
mp_DpiAware->SetDialogDPI(apDpi->GetCurDpi(), &rcClient);
}
INT_PTR CSetPgBase::OnComboBox(HWND hDlg, WORD nCtrlId, WORD code)
{
_ASSERTE(FALSE && "ComboBox was not processed!");
return 0;
}
INT_PTR CSetPgBase::OnCtlColorStatic(HWND hDlg, HDC hdc, HWND hCtrl, WORD nCtrlId)
{
if ((nCtrlId >= c0 && nCtrlId <= CSetDlgColors::MAX_COLOR_EDT_ID) || (nCtrlId >= c32 && nCtrlId <= c38))
{
return CSetDlgColors::ColorCtlStatic(hDlg, nCtrlId, hCtrl);
}
else if (CDlgItemHelper::isHyperlinkCtrl(nCtrlId))
{
_ASSERTE(hCtrl!=NULL);
// Check appropriate flags
DWORD nStyle = GetWindowLong(hCtrl, GWL_STYLE);
if (!(nStyle & SS_NOTIFY))
SetWindowLong(hCtrl, GWL_STYLE, nStyle|SS_NOTIFY);
// And the colors
SetTextColor(hdc, GetSysColor(COLOR_HOTLIGHT));
SetBkMode(hdc, TRANSPARENT);
HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE);
return (INT_PTR)hBrush;
}
/*
SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE);
SetBkMode((HDC)wParam, TRANSPARENT);
return (INT_PTR)hBrush;
*/
return FALSE;
}
INT_PTR CSetPgBase::OnSetCursor(HWND hDlg, HWND hCtrl, WORD nCtrlId, WORD nHitTest, WORD nMouseMsg)
{
if (nHitTest != HTCLIENT)
return FALSE;
#ifdef _DEBUG
LONG_PTR wId = GetWindowLongPtr(hCtrl, GWLP_ID);
#endif
if (CDlgItemHelper::isHyperlinkCtrl(nCtrlId))
{
SetCursor(LoadCursor(NULL, IDC_HAND));
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
return TRUE;
}
return FALSE;
}
INT_PTR CSetPgBase::OnButtonClicked(HWND hDlg, HWND hBtn, WORD nCtrlId)
{
return gpSetCls->OnButtonClicked(hDlg, MAKELONG(nCtrlId, BN_CLICKED), (LPARAM)hBtn);
}
// Общая DlgProc на _все_ вкладки
INT_PTR CSetPgBase::pageOpProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam)
{
TabHwndIndex pgId = thi_Last;
CSetPgBase* pObj = NULL;
if (messg != WM_INITDIALOG)
{
ConEmuSetupPages* pPage = NULL;
pgId = gpSetCls->GetPageId(hDlg, &pPage);
if ((pgId == thi_Last) || !pPage || !pPage->pPage)
{
_ASSERTE(FALSE && "Page was not created properly yet");
return TRUE;
}
pObj = pPage->pPage;
_ASSERTE(pObj && (pObj->mn_ActivateTabMsg != WM_APP));
if (!pObj)
{
return TRUE;
}
if (pObj && pObj->mp_DpiAware && pObj->mp_DpiAware->ProcessDpiMessages(hDlg, messg, wParam, lParam))
{
return TRUE;
}
}
if ((messg == WM_INITDIALOG) || (pObj && (messg == pObj->mn_ActivateTabMsg)))
{
bool bInitial = (messg == WM_INITDIALOG);
if (bInitial)
{
if (!lParam)
{
_ASSERTE(lParam != 0);
return 0;
}
pObj = (CSetPgBase*)lParam;
}
if (!pObj || (pObj->GetPageType() < thi_Fonts) || (pObj->GetPageType() >= thi_Last))
{
_ASSERTE(pObj && (pObj->GetPageType() >= thi_Fonts && pObj->GetPageType() < thi_Last));
return 0;
}
_ASSERTE(pObj->Dlg() == NULL || pObj->Dlg() == hDlg);
pgId = pObj->GetPageType();
if (bInitial)
{
_ASSERTE(pObj->mp_InfoPtr && pObj->mp_InfoPtr->PageIndex >= 0 && pObj->mp_InfoPtr->hPage == NULL);
pObj->mp_InfoPtr->hPage = hDlg;
pObj->mh_Dlg = hDlg;
CDynDialog* pDynDialog = CDynDialog::GetDlgClass(hDlg);
_ASSERTE(pObj->mp_DynDialog==NULL || pObj->mp_DynDialog==pDynDialog);
#ifdef _DEBUG
// pObj->mp_DynDialog is NULL on first WM_INIT
if (pObj->mp_DynDialog)
{
_ASSERTE(pObj->mp_DynDialog->mh_Dlg == hDlg);
}
#endif
HWND hPlace = GetDlgItem(pObj->mh_Parent, tSetupPagePlace);
RECT rcClient; GetWindowRect(hPlace, &rcClient);
MapWindowPoints(NULL, pObj->mh_Parent, (LPPOINT)&rcClient, 2);
if (pObj->mp_DpiAware)
pObj->mp_DpiAware->Attach(hDlg, pObj->mh_Parent, pDynDialog);
MoveWindowRect(hDlg, rcClient);
}
else
{
_ASSERTE(pObj->mp_InfoPtr->PageIndex >= 0 && pObj->mp_InfoPtr->hPage == hDlg);
}
MSetter lockSelChange(&pObj->mb_SkipSelChange);
pObj->OnInitDialog(hDlg, bInitial);
if (bInitial)
{
EditIconHint_Subclass(hDlg, pObj->mh_Parent);
gpSetCls->RegisterTipsFor(hDlg);
}
pObj->OnPostLocalize(hDlg);
}
else if ((messg == WM_HELP) || (messg == HELP_WM_HELP))
{
_ASSERTE(messg == WM_HELP);
if ((wParam == 0) && (lParam != 0))
{
// Open wiki page
HELPINFO* hi = (HELPINFO*)lParam;
if (hi->cbSize >= sizeof(HELPINFO))
{
CEHelpPopup::OpenSettingsWiki(hDlg, hi->iCtrlId);
}
}
return TRUE;
}
else if (pgId == thi_Apps)
{
// Страничка "App distinct" в некотором смысле особенная.
// У многих контролов ИД дублируются с другими вкладками.
CSetPgApps* pAppsPg;
if (gpSetCls->GetPageObj(pAppsPg))
{
return pAppsPg->PageDlgProc(hDlg, messg, wParam, lParam);
}
else
{
_ASSERTE(pAppsPg!=NULL);
return 0;
}
}
else if (pgId == thi_Integr)
{
return pObj->PageDlgProc(hDlg, messg, wParam, lParam);
}
else if (pgId == thi_Startup)
{
return pObj->PageDlgProc(hDlg, messg, wParam, lParam);
}
else
// All other messages
switch (messg)
{
#ifdef _DEBUG
case WM_INITDIALOG:
// Должно быть обработано выше
_ASSERTE(messg != WM_INITDIALOG);
break;
#endif
case WM_COMMAND:
{
switch (HIWORD(wParam))
{
case BN_CLICKED:
return CSetDlgButtons::OnButtonClicked(hDlg, wParam, lParam);
case EN_CHANGE:
// TODO: Remove duplicate condition!
if (!pObj->mb_SkipSelChange && !pObj->mb_IgnoreEditChanged)
pObj->OnEditChanged(hDlg, LOWORD(wParam));
return 0;
case CBN_EDITCHANGE:
case CBN_SELCHANGE/*LBN_SELCHANGE*/:
if (!pObj->mb_SkipSelChange)
pObj->OnComboBox(hDlg, LOWORD(wParam), HIWORD(wParam));
return 0;
case LBN_DBLCLK:
gpSetCls->OnListBoxDblClk(hDlg, wParam, lParam);
return 0;
case CBN_KILLFOCUS:
if (gpSetCls->mn_LastChangingFontCtrlId && (LOWORD(wParam) == gpSetCls->mn_LastChangingFontCtrlId))
{
_ASSERTE(pgId == thi_Fonts);
PostMessage(hDlg, gpSetCls->mn_MsgRecreateFont, gpSetCls->mn_LastChangingFontCtrlId, 0);
gpSetCls->mn_LastChangingFontCtrlId = 0;
return 0;
}
break;
default:
if (HIWORD(wParam) == 0xFFFF && LOWORD(wParam) == lbConEmuHotKeys)
{
dynamic_cast<CSetPgKeys*>(pObj)->OnHotkeysNotify(hDlg, wParam, 0);
}
} // switch (HIWORD(wParam))
} // WM_COMMAND
break;
case WM_MEASUREITEM:
return gpSetCls->OnMeasureFontItem(hDlg, messg, wParam, lParam);
case WM_DRAWITEM:
return gpSetCls->OnDrawFontItem(hDlg, messg, wParam, lParam);
case WM_CTLCOLORSTATIC:
return pObj->OnCtlColorStatic(hDlg, (HDC)wParam, (HWND)lParam, GetDlgCtrlID((HWND)lParam));
case WM_SETCURSOR:
return pObj->OnSetCursor(hDlg, (HWND)wParam, GetDlgCtrlID((HWND)wParam), LOWORD(lParam), HIWORD(lParam));
case WM_HSCROLL:
{
if ((pgId == thi_Backgr) && (HWND)lParam == GetDlgItem(hDlg, slDarker))
{
int newV = SendDlgItemMessage(hDlg, slDarker, TBM_GETPOS, 0, 0);
if (newV != gpSet->bgImageDarker)
{
gpSetCls->SetBgImageDarker(newV, true);
//gpSet->bgImageDarker = newV;
//TCHAR tmp[10];
//_wsprintf(tmp, SKIPLEN(countof(tmp)) L"%i", gpSet->bgImageDarker);
//SetDlgItemText(hDlg, tDarker, tmp);
//// Картинку может установить и плагин
//if (gpSet->isShowBgImage && gpSet->sBgImage[0])
// gpSetCls->LoadBackgroundFile(gpSet->sBgImage);
//else
// gpSetCls->NeedBackgroundUpdate();
//gpConEmu->Update(true);
}
}
else if ((pgId == thi_Transparent) && (HWND)lParam == GetDlgItem(hDlg, slTransparent))
{
int newV = SendDlgItemMessage(hDlg, slTransparent, TBM_GETPOS, 0, 0);
if (newV != gpSet->nTransparent)
{
CSettings::checkDlgButton(hDlg, cbTransparent, (newV != MAX_ALPHA_VALUE) ? BST_CHECKED : BST_UNCHECKED);
gpSet->nTransparent = newV;
if (!gpSet->isTransparentSeparate)
SendDlgItemMessage(hDlg, slTransparentInactive, TBM_SETPOS, (WPARAM)true, (LPARAM)gpSet->nTransparent);
gpConEmu->OnTransparent();
}
}
else if ((pgId == thi_Transparent) && (HWND)lParam == GetDlgItem(hDlg, slTransparentInactive))
{
int newV = SendDlgItemMessage(hDlg, slTransparentInactive, TBM_GETPOS, 0, 0);
if (gpSet->isTransparentSeparate && (newV != gpSet->nTransparentInactive))
{
//checkDlgButton(hDlg, cbTransparentInactive, (newV!=MAX_ALPHA_VALUE) ? BST_CHECKED : BST_UNCHECKED);
gpSet->nTransparentInactive = newV;
gpConEmu->OnTransparent();
}
}
} // WM_HSCROLL
break;
case WM_NOTIFY:
{
if (((NMHDR*)lParam)->code == TTN_GETDISPINFO)
{
return gpSetCls->ProcessTipHelp(hDlg, messg, wParam, lParam);
}
else switch (((NMHDR*)lParam)->idFrom)
{
case lbActivityLog:
if (!pObj->mb_SkipSelChange)
return ((CSetPgDebug*)pObj)->OnActivityLogNotify(wParam, lParam);
break;
case lbConEmuHotKeys:
if (!pObj->mb_SkipSelChange)
return dynamic_cast<CSetPgKeys*>(pObj)->OnHotkeysNotify(hDlg, wParam, lParam);
break;
}
return 0;
} // WM_NOTIFY
break;
case WM_TIMER:
if (wParam == BALLOON_MSG_TIMERID)
{
KillTimer(hDlg, BALLOON_MSG_TIMERID);
SendMessage(gpSetCls->hwndBalloon, TTM_TRACKACTIVATE, FALSE, (LPARAM)&gpSetCls->tiBalloon);
SendMessage(gpSetCls->hwndTip, TTM_ACTIVATE, TRUE, 0);
}
break;
default:
{
if (messg == gpSetCls->mn_MsgRecreateFont)
{
gpSetCls->RecreateFont(LOWORD(wParam));
}
else if (messg == gpSetCls->mn_MsgLoadFontFromMain)
{
CSetPgFonts* pFonts = NULL;
if (gpSetCls->GetPageObj(pFonts))
{
if (pgId == thi_Views)
pFonts->CopyFontsTo(hDlg, tThumbsFontName, tTilesFontName, 0);
else if (pgId == thi_Tabs)
pFonts->CopyFontsTo(hDlg, tTabFontFace, 0);
else if (pgId == thi_Status)
pFonts->CopyFontsTo(hDlg, tStatusFontFace, 0);
}
}
else if (messg == gpSetCls->mn_MsgUpdateCounter)
{
gpSetCls->PostUpdateCounters(true);
}
else if (messg == DBGMSG_LOG_ID && pgId == thi_Debug)
{
MSetter lockSelChange(&pObj->mb_SkipSelChange);
((CSetPgDebug*)pObj)->debugLog(wParam, lParam);
} // if (messg == DBGMSG_LOG_ID && hDlg == gpSetCls->hDebug)
else
{
pObj->PageDlgProc(hDlg, messg, wParam, lParam);
}
} // default:
} //switch (messg)
return 0;
}
void CSetPgBase::setHotkeyCheckbox(HWND hDlg, WORD nCtrlId, int iHotkeyId, LPCWSTR pszFrom, LPCWSTR pszTo, UINT uChecked)
{
wchar_t szKeyFull[128] = L"";
gpSet->GetHotkeyNameById(iHotkeyId, szKeyFull, false);
if (szKeyFull[0] == 0)
{
EnableWindow(GetDlgItem(hDlg, nCtrlId), FALSE);
checkDlgButton(hDlg, nCtrlId, BST_UNCHECKED);
}
else
{
if (pszFrom)
{
wchar_t* ptr = (wchar_t*)wcsstr(szKeyFull, pszFrom);
if (ptr)
{
*ptr = 0;
if (pszTo)
{
wcscat_c(szKeyFull, pszTo);
}
}
}
CEStr lsText(GetDlgItemTextPtr(hDlg, nCtrlId));
LPCWSTR pszTail = lsText.IsEmpty() ? NULL : wcsstr(lsText, L" - ");
if (pszTail)
{
CEStr lsNew(szKeyFull, pszTail);
SetDlgItemText(hDlg, nCtrlId, lsNew);
}
checkDlgButton(hDlg, nCtrlId, uChecked);
}
}
/// Update GroupBox title, replacing text *between* pszFrom and pszTo with current HotKey
/// Examples:
/// gbPasteM1 has title "Paste mode #1 (Shift+Ins)", pszFrom=L"(", pszTo=L")"
/// cbMouseDragWindow has title "Ctrl+Alt - drag ConEmu window", pszFrom=NULL, pszTo=L" - "
/// Than `Shift+Ins` would be replaced with current user defined hotkey value
void CSetPgBase::setCtrlTitleByHotkey(HWND hDlg, WORD nCtrlId, int iHotkeyId, LPCWSTR pszFrom, LPCWSTR pszTo)
{
if (!hDlg || !nCtrlId || (nCtrlId == (WORD)IDC_STATIC) || (iHotkeyId <= 0))
{
_ASSERTE(FALSE && "Invalid identifiers");
return;
}
wchar_t szKeyFull[128] = L"";
gpSet->GetHotkeyNameById(iHotkeyId, szKeyFull, true);
if (szKeyFull[0] == 0)
{
_ASSERTE(FALSE && "Failed to acquire HotKey");
wcscpy_c(szKeyFull, L"???");
}
CEStr lsLoc;
if (!CLngRc::getControl(nCtrlId, lsLoc))
{
if (GetString(hDlg, nCtrlId, &lsLoc.ms_Val) <= 0)
{
_ASSERTE(FALSE && "No title?");
return;
}
}
if (pszFrom && *pszFrom)
{
// "Paste mode #1 (Shift+Ins)"
LPCWSTR ptr1, ptr2 = NULL;
ptr1 = wcsstr(lsLoc, pszFrom);
if (!ptr1)
{
_ASSERTE(ptr1 && "pszFrom not found");
return;
}
ptr1 += wcslen(pszFrom);
if (pszTo && *pszTo)
{
ptr2 = wcsstr(ptr1, pszTo);
}
if (!ptr2 || (ptr2 == ptr1))
{
_ASSERTE(ptr2 && (ptr2 != ptr1) && "Invalid source string");
return;
}
// Trim to hotkey beginning
lsLoc.ms_Val[(ptr1 - lsLoc.ms_Val)] = 0;
// And create new title
CEStr lsNew(lsLoc.ms_Val, szKeyFull, ptr2);
// Update control text
SetDlgItemText(hDlg, nCtrlId, lsNew);
}
else if (pszTo && *pszTo)
{
// "Ctrl+Alt - drag ConEmu window"
LPCWSTR ptr;
ptr = wcsstr(lsLoc, pszTo);
if (!ptr)
{
_ASSERTE(ptr && "pszTo not found");
return;
}
// Create new title
CEStr lsNew(szKeyFull, ptr);
// Update control text
SetDlgItemText(hDlg, nCtrlId, lsNew);
}
else
{
_ASSERTE(FALSE && "Invalid anchors");
}
}