From a8ef07a8ac3cd25fae13f6b9174828310497d9b6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 28 Apr 2023 16:42:53 +0300 Subject: CCtrlPages: owned dialogs to be created from the very beginning --- include/m_gui.h | 1 + libs/win32/mir_core.lib | Bin 491386 -> 491728 bytes libs/win64/mir_core.lib | Bin 496588 -> 496940 bytes src/mir_core/src/Windows/CCtrlPages.cpp | 44 +++++++++++++++++++------------- src/mir_core/src/mir_core.def | 1 + src/mir_core/src/mir_core64.def | 1 + 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/include/m_gui.h b/include/m_gui.h index 0d13d5974a..d44fc9c434 100644 --- a/include/m_gui.h +++ b/include/m_gui.h @@ -1418,6 +1418,7 @@ class MIR_CORE_EXPORT CCtrlPages : public CCtrlBase bool m_bOwnPages = false; struct TPageInfo; + void CreatePage(CDlgBase *pDlg); void InsertPage(TPageInfo *pPage); void ShowPage(CDlgBase *pDlg); diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib index eb68307359..4c25d69d8c 100644 Binary files a/libs/win32/mir_core.lib and b/libs/win32/mir_core.lib differ diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib index c171b61385..90e132f525 100644 Binary files a/libs/win64/mir_core.lib and b/libs/win64/mir_core.lib differ diff --git a/src/mir_core/src/Windows/CCtrlPages.cpp b/src/mir_core/src/Windows/CCtrlPages.cpp index 7060c9b751..b5b70907eb 100644 --- a/src/mir_core/src/Windows/CCtrlPages.cpp +++ b/src/mir_core/src/Windows/CCtrlPages.cpp @@ -59,8 +59,11 @@ void CCtrlPages::OnInit() CSuper::OnInit(); Subclass(); - for (auto &it : m_pages) + for (auto &it : m_pages) { InsertPage(it); + if (m_bOwnPages) + CreatePage(it->m_pDlg); + } m_pages.destroy(); ::SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_CONTROLPARENT); @@ -180,6 +183,26 @@ void CCtrlPages::CheckRowCount() } } +void CCtrlPages::CreatePage(CDlgBase *pDlg) +{ + pDlg->SetParent(m_bOwnPages ? m_hwnd : GetParent()->GetHwnd()); + pDlg->Create(); + + RECT rc; + GetClientRect(m_hwnd, &rc); + TabCtrl_AdjustRect(m_hwnd, FALSE, &rc); + SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE); + + EnableThemeDialogTexture(pDlg->GetHwnd(), ETDT_ENABLETAB); + + PSHNOTIFY pshn; + pshn.hdr.code = PSN_INFOCHANGED; + pshn.hdr.hwndFrom = pDlg->GetHwnd(); + pshn.hdr.idFrom = 0; + pshn.lParam = 0; + SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn); +} + int CCtrlPages::GetCount() { return TabCtrl_GetItemCount(m_hwnd); @@ -265,24 +288,9 @@ void CCtrlPages::RemovePage(int iPage) void CCtrlPages::ShowPage(CDlgBase *pDlg) { - if (pDlg->GetHwnd() == nullptr) { - pDlg->SetParent(m_bOwnPages ? m_hwnd : GetParent()->GetHwnd()); - pDlg->Create(); - - RECT rc; - GetClientRect(m_hwnd, &rc); - TabCtrl_AdjustRect(m_hwnd, FALSE, &rc); - SetWindowPos(pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE); - - EnableThemeDialogTexture(pDlg->GetHwnd(), ETDT_ENABLETAB); + if (pDlg->GetHwnd() == nullptr) + CreatePage(pDlg); - PSHNOTIFY pshn; - pshn.hdr.code = PSN_INFOCHANGED; - pshn.hdr.hwndFrom = pDlg->GetHwnd(); - pshn.hdr.idFrom = 0; - pshn.lParam = 0; - SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn); - } ShowWindow(pDlg->GetHwnd(), SW_SHOW); } diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 64c5ef15f4..c0a444d6ec 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1552,3 +1552,4 @@ db_event_updateId @1772 ?db_get_usm@@YG?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPBD00@Z @1773 NONAME ?SetPageOwner@CCtrlPages@@QAEXXZ @1774 NONAME ?db_event_setJson@@YGHIPBDPAUDBVARIANT@@@Z @1775 NONAME +?CreatePage@CCtrlPages@@AAEXPAVCDlgBase@@@Z @1776 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 023b1b23b8..b68c98f66d 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1552,3 +1552,4 @@ db_event_updateId @1772 ?db_get_usm@@YA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@IPEBD00@Z @1773 NONAME ?SetPageOwner@CCtrlPages@@QEAAXXZ @1774 NONAME ?db_event_setJson@@YAHIPEBDPEAUDBVARIANT@@@Z @1775 NONAME +?CreatePage@CCtrlPages@@AEAAXPEAVCDlgBase@@@Z @1776 NONAME -- cgit v1.2.3