summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-20 19:38:58 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-20 19:38:58 +0000
commitbfc7f00a09d0e845f182b0b69642d63be18c7f91 (patch)
treeda503a6d950ca417306547d0240faa2b6f9a7cbb
parentb34e591a4ba1785cdd658b8dd1a492a3f9569d19 (diff)
tabbed control validator
git-svn-id: http://svn.miranda-ng.org/main/trunk@13722 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--bin10/lib/mir_core.libbin333084 -> 333844 bytes
-rw-r--r--bin10/lib/mir_core64.libbin335498 -> 335740 bytes
-rw-r--r--bin12/lib/mir_core.libbin333084 -> 333844 bytes
-rw-r--r--bin12/lib/mir_core64.libbin335498 -> 335740 bytes
-rw-r--r--include/m_gui.h3
-rw-r--r--src/mir_core/src/mir_core.def3
-rw-r--r--src/mir_core/src/mir_core64.def3
-rw-r--r--src/mir_core/src/ui_utils.cpp191
8 files changed, 106 insertions, 94 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index d9349e8b5a..1aea680e90 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index ebeb8bac0b..b3b192e407 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin12/lib/mir_core.lib b/bin12/lib/mir_core.lib
index d9349e8b5a..1220aa4709 100644
--- a/bin12/lib/mir_core.lib
+++ b/bin12/lib/mir_core.lib
Binary files differ
diff --git a/bin12/lib/mir_core64.lib b/bin12/lib/mir_core64.lib
index ebeb8bac0b..4f8caba771 100644
--- a/bin12/lib/mir_core64.lib
+++ b/bin12/lib/mir_core64.lib
Binary files differ
diff --git a/include/m_gui.h b/include/m_gui.h
index 01d5f1808f..fe2a0e66a3 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -275,6 +275,7 @@ public:
__forceinline bool IsInitialized() const { return m_initialized; }
__forceinline void SetParent(HWND hwnd) { m_hwndParent = hwnd; }
__forceinline void Close() { SendMessage(m_hwnd, WM_CLOSE, 0, 0); }
+ __forceinline void Fail() { m_lresult = false; }
static CDlgBase* Find(HWND hwnd);
@@ -308,7 +309,7 @@ protected:
// main dialog procedure
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
- // resister controls
+ // register controls
void AddControl(CCtrlBase *ctrl);
// win32 stuff
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 0373655320..b2157d77e4 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1090,3 +1090,6 @@ Proto_RegisterModule @1074 NONAME
?UnselectAll@CCtrlTreeView@@QAEXXZ @1093 NONAME
?MoveItemAbove@CCtrlTreeView@@AAEPAU_TREEITEM@@PAU2@0@Z @1094 NONAME
?GetCurrPage@CCtrlPages@@AAEPAUTPageInfo@1@XZ @1095 NONAME
+?Fail@CDlgBase@@QAEXXZ @1096 NONAME
+?OnApply@CCtrlPages@@MAEXXZ @1097 NONAME
+?OnReset@CCtrlPages@@MAEXXZ @1098 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 29ae97a79f..3b8d10cae3 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1090,3 +1090,6 @@ Proto_RegisterModule @1074 NONAME
?UnselectAll@CCtrlTreeView@@QEAAXXZ @1093 NONAME
?MoveItemAbove@CCtrlTreeView@@AEAAPEAU_TREEITEM@@PEAU2@0@Z @1094 NONAME
?GetCurrPage@CCtrlPages@@AEAAPEAUTPageInfo@1@XZ @1095 NONAME
+?Fail@CDlgBase@@QEAAXXZ @1096 NONAME
+?OnApply@CCtrlPages@@MEAAXXZ @1097 NONAME
+?OnReset@CCtrlPages@@MEAAXXZ @1098 NONAME
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp
index 53b4cc5f0e..c560d78643 100644
--- a/src/mir_core/src/ui_utils.cpp
+++ b/src/mir_core/src/ui_utils.cpp
@@ -178,8 +178,10 @@ INT_PTR CDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
NMHDR *pnmh = (NMHDR *)lParam;
if (pnmh->idFrom == 0) {
if (pnmh->code == PSN_APPLY) {
+ m_lresult = true;
NotifyControls(&CCtrlBase::OnApply);
- OnApply();
+ if (m_lresult)
+ OnApply();
}
else if (pnmh->code == PSN_RESET) {
NotifyControls(&CCtrlBase::OnReset);
@@ -2063,8 +2065,8 @@ void CCtrlPages::OnInit()
CSuper::OnInit();
Subclass();
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
+ for (int i = 0; i < m_pages.getCount(); i++) {
+ TPageInfo *p = m_pages[i];
TCITEM tci = { 0 };
tci.mask = TCIF_PARAM | TCIF_TEXT;
tci.lParam = (LPARAM)p;
@@ -2082,25 +2084,25 @@ void CCtrlPages::OnInit()
p->m_pageId = TabCtrl_InsertItem(m_hwnd, TabCtrl_GetItemCount(m_hwnd), &tci);
}
- ::SetWindowLong(m_hwnd, GWL_EXSTYLE, ::GetWindowLong(m_hwnd, GWL_EXSTYLE) | WS_EX_CONTROLPARENT);
+ ::SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_CONTROLPARENT);
TPageInfo *info = GetCurrPage();
if (info) {
m_pActivePage = info->m_pDlg;
ShowPage(m_pActivePage);
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_INFOCHANGED;
- pshn.hdr.hwndFrom = m_pActivePage->GetHwnd();
- pshn.hdr.idFrom = 0;
- pshn.lParam = 0;
- SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
- }
+ PSHNOTIFY pshn;
+ pshn.hdr.code = PSN_INFOCHANGED;
+ pshn.hdr.hwndFrom = m_pActivePage->GetHwnd();
+ pshn.hdr.idFrom = 0;
+ pshn.lParam = 0;
+ SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
+ }
}
LRESULT CCtrlPages::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- PSHNOTIFY pshn;
+ PSHNOTIFY pshn;
switch (msg) {
case WM_SIZE:
@@ -2108,28 +2110,28 @@ LRESULT CCtrlPages::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
GetClientRect(m_hwnd, &rc);
TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
- if (p->m_pDlg->GetHwnd() != NULL)
+ for (int i = 0; i < m_pages.getCount(); i++) {
+ TPageInfo *p = m_pages[i];
+ if (p->m_pDlg->GetHwnd() != NULL)
SetWindowPos(m_pActivePage->GetHwnd(), HWND_TOP, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
- }
+ }
break;
- case PSM_CHANGED:
+ case PSM_CHANGED:
if (TPageInfo *info = GetCurrPage())
- info->m_bChanged = TRUE;
- return TRUE;
-
- case PSM_FORCECHANGED:
- pshn.hdr.code = PSN_INFOCHANGED;
- pshn.hdr.idFrom = 0;
- pshn.lParam = 0;
- for (int i = 0; i < m_pages.getCount(); i++) {
- pshn.hdr.hwndFrom = m_pages[i]->m_pDlg->GetHwnd();
- if (pshn.hdr.hwndFrom != NULL)
- SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
- }
- break;
+ info->m_bChanged = TRUE;
+ return TRUE;
+
+ case PSM_FORCECHANGED:
+ pshn.hdr.code = PSN_INFOCHANGED;
+ pshn.hdr.idFrom = 0;
+ pshn.lParam = 0;
+ for (int i = 0; i < m_pages.getCount(); i++) {
+ pshn.hdr.hwndFrom = m_pages[i]->m_pDlg->GetHwnd();
+ if (pshn.hdr.hwndFrom != NULL)
+ SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
+ }
+ break;
}
return CSuper::CustomWndProc(msg, wParam, lParam);
@@ -2182,32 +2184,32 @@ void CCtrlPages::ShowPage(CDlgBase *pDlg)
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);
- }
- ShowWindow(pDlg->GetHwnd(), SW_SHOW);
+ 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);
}
BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
{
TPageInfo *info;
- PSHNOTIFY pshn;
+ PSHNOTIFY pshn;
switch (pnmh->code) {
case TCN_SELCHANGING:
if (info = GetCurrPage()) {
- pshn.hdr.code = PSN_KILLACTIVE;
- pshn.hdr.hwndFrom = info->m_pDlg->GetHwnd();
- pshn.hdr.idFrom = 0;
- pshn.lParam = 0;
- if (SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn)) {
- SetWindowLongPtr(GetParent()->GetHwnd(), DWLP_MSGRESULT, TRUE);
- return TRUE;
- }
+ pshn.hdr.code = PSN_KILLACTIVE;
+ pshn.hdr.hwndFrom = info->m_pDlg->GetHwnd();
+ pshn.hdr.idFrom = 0;
+ pshn.lParam = 0;
+ if (SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn)) {
+ SetWindowLongPtr(GetParent()->GetHwnd(), DWLP_MSGRESULT, TRUE);
+ return TRUE;
+ }
}
return TRUE;
@@ -2229,51 +2231,54 @@ BOOL CCtrlPages::OnNotify(int /*idCtrl*/, NMHDR *pnmh)
void CCtrlPages::OnReset()
{
CSuper::OnReset();
-
- PSHNOTIFY pshn;
- pshn.hdr.code = PSN_INFOCHANGED;
- pshn.hdr.idFrom = 0;
- pshn.lParam = 0;
-
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
- if (p->m_pDlg->GetHwnd() == NULL || !p->m_bChanged)
- continue;
-
- pshn.hdr.hwndFrom = p->m_pDlg->GetHwnd();
- SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
+
+ PSHNOTIFY pshn;
+ pshn.hdr.code = PSN_INFOCHANGED;
+ pshn.hdr.idFrom = 0;
+ pshn.lParam = 0;
+
+ for (int i = 0; i < m_pages.getCount(); i++) {
+ TPageInfo *p = m_pages[i];
+ if (p->m_pDlg->GetHwnd() == NULL || !p->m_bChanged)
+ continue;
+
+ pshn.hdr.hwndFrom = p->m_pDlg->GetHwnd();
+ SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
}
}
void CCtrlPages::OnApply()
{
- PSHNOTIFY pshn;
- pshn.hdr.idFrom = 0;
- pshn.lParam = 0;
-
- if (m_pActivePage != NULL) {
- pshn.hdr.code = PSN_KILLACTIVE;
- pshn.hdr.hwndFrom = m_pActivePage->GetHwnd();
- if (SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn))
- return;
- }
-
- pshn.hdr.code = PSN_APPLY;
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
- if (p->m_pDlg->GetHwnd() == NULL || !p->m_bChanged)
- continue;
-
- pshn.hdr.hwndFrom = p->m_pDlg->GetHwnd();
- SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
- if (GetWindowLongPtr(pshn.hdr.hwndFrom, DWLP_MSGRESULT) == PSNRET_INVALID_NOCHANGEPAGE) {
- TabCtrl_SetCurSel(m_hwnd, p->m_pageId);
- if (m_pActivePage != NULL)
- ShowWindow(m_pActivePage->GetHwnd(), SW_HIDE);
- m_pActivePage = p->m_pDlg;
- ShowWindow(m_pActivePage->GetHwnd(), SW_SHOW);
- return;
- }
+ PSHNOTIFY pshn;
+ pshn.hdr.idFrom = 0;
+ pshn.lParam = 0;
+
+ if (m_pActivePage != NULL) {
+ pshn.hdr.code = PSN_KILLACTIVE;
+ pshn.hdr.hwndFrom = m_pActivePage->GetHwnd();
+ if (SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn)) {
+ m_parentWnd->Fail();
+ return;
+ }
+ }
+
+ pshn.hdr.code = PSN_APPLY;
+ for (int i = 0; i < m_pages.getCount(); i++) {
+ TPageInfo *p = m_pages[i];
+ if (p->m_pDlg->GetHwnd() == NULL || !p->m_bChanged)
+ continue;
+
+ pshn.hdr.hwndFrom = p->m_pDlg->GetHwnd();
+ SendMessage(pshn.hdr.hwndFrom, WM_NOTIFY, 0, (LPARAM)&pshn);
+ if (GetWindowLongPtr(pshn.hdr.hwndFrom, DWLP_MSGRESULT) == PSNRET_INVALID_NOCHANGEPAGE) {
+ TabCtrl_SetCurSel(m_hwnd, p->m_pageId);
+ if (m_pActivePage != NULL)
+ ShowWindow(m_pActivePage->GetHwnd(), SW_HIDE);
+ m_pActivePage = p->m_pDlg;
+ ShowWindow(m_pActivePage->GetHwnd(), SW_SHOW);
+ m_parentWnd->Fail();
+ return;
+ }
}
CSuper::OnApply();
@@ -2281,12 +2286,12 @@ void CCtrlPages::OnApply()
void CCtrlPages::OnDestroy()
{
- for (int i = 0; i < m_pages.getCount(); i++) {
- TPageInfo *p = m_pages[i];
- if (p->m_pDlg->GetHwnd())
- p->m_pDlg->Close();
- delete p;
- }
+ for (int i = 0; i < m_pages.getCount(); i++) {
+ TPageInfo *p = m_pages[i];
+ if (p->m_pDlg->GetHwnd())
+ p->m_pDlg->Close();
+ delete p;
+ }
TabCtrl_DeleteAllItems(m_hwnd);