diff options
author | George Hazan <ghazan@miranda.im> | 2016-12-19 14:52:57 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2016-12-19 14:52:57 +0300 |
commit | 8938b3ee67fb60553864a019fdb2f22d734f3120 (patch) | |
tree | 8a5ba4d6b717d3a037649a8315523787878075f9 /src/core/stdmsg | |
parent | 63f6579e56af870fa9ad7289a1a71cd5a27f5d76 (diff) |
- fix for a dialog blinking on start;
- crash fix
Diffstat (limited to 'src/core/stdmsg')
-rw-r--r-- | src/core/stdmsg/src/chat_util.cpp | 31 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/stdafx.h | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 81 |
4 files changed, 51 insertions, 67 deletions
diff --git a/src/core/stdmsg/src/chat_util.cpp b/src/core/stdmsg/src/chat_util.cpp index 4b8317b9e6..fb1837beb5 100644 --- a/src/core/stdmsg/src/chat_util.cpp +++ b/src/core/stdmsg/src/chat_util.cpp @@ -388,30 +388,19 @@ void ValidateFilename(wchar_t *filename) } } -int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, char *szModule, char *szNamePrefix, UINT showCmd) +int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, bool bHide) { - char szSettingName[64]; - mir_snprintf(szSettingName, "%sx", szNamePrefix); - int x = db_get_dw(hContact, szModule, szSettingName, -1); + int x = db_get_dw(hContact, CHAT_MODULE, "roomx", -1); if (x == -1) return 0; - mir_snprintf(szSettingName, "%sy", szNamePrefix); - int y = (int)db_get_dw(hContact, szModule, szSettingName, -1); - mir_snprintf(szSettingName, "%swidth", szNamePrefix); - int width = db_get_dw(hContact, szModule, szSettingName, -1); - mir_snprintf(szSettingName, "%sheight", szNamePrefix); - int height = db_get_dw(hContact, szModule, szSettingName, -1); - - WINDOWPLACEMENT wp; - wp.length = sizeof(wp); - GetWindowPlacement(hwnd, &wp); - - wp.rcNormalPosition.left = x; - wp.rcNormalPosition.top = y; - wp.rcNormalPosition.right = wp.rcNormalPosition.left + width; - wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + height; - wp.showCmd = showCmd; - SetWindowPlacement(hwnd, &wp); + int y = (int)db_get_dw(hContact, CHAT_MODULE, "roomy", -1); + int width = db_get_dw(hContact, CHAT_MODULE, "roomwidth", -1); + int height = db_get_dw(hContact, CHAT_MODULE, "roomheight", -1); + + DWORD dwFlags = SWP_NOACTIVATE | SWP_NOZORDER; + if (bHide) + dwFlags |= SWP_HIDEWINDOW; + SetWindowPos(hwnd, NULL, x, y, width, height, dwFlags); return 1; } diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 241e230c70..febbeb7a60 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -1143,8 +1143,10 @@ void CChatRoomDlg::SetWindowPosition() } if (db_get_b(NULL, CHAT_MODULE, "SavePosition", 0)) { - if (RestoreWindowPosition(m_hwnd, m_si->hContact, CHAT_MODULE, "room", SW_HIDE)) + if (RestoreWindowPosition(m_hwnd, m_si->hContact, true)) { + ShowWindow(m_hwnd, SW_HIDE); return; + } SetWindowPos(m_hwnd, 0, (screen.right - screen.left) / 2 - (550) / 2, (screen.bottom - screen.top) / 2 - (400) / 2, (550), (400), SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); } else SetWindowPos(m_hwnd, 0, (screen.right - screen.left) / 2 - (550) / 2, (screen.bottom - screen.top) / 2 - (400) / 2, (550), (400), SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 09d77d8a83..7fb974d23c 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -149,7 +149,7 @@ UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO void DestroyGCMenu(HMENU *hMenu, int iIndex);
bool LoadMessageFont(LOGFONT *lf, COLORREF *colour);
void SetButtonsPos(HWND hwndDlg, bool bIsChat);
-int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, char *szModule, char *szNamePrefix, UINT showCmd);
+int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, bool bHide);
// message.cpp
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 136b512fef..6eb59da245 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -182,7 +182,7 @@ void CTabbedWindow::OnInitDialog() mir_subclassWindow(m_tab.GetHwnd(), TabSubclassProc); if (db_get_b(NULL, CHAT_MODULE, "SavePosition", 0)) - RestoreWindowPosition(m_hwnd, NULL, CHAT_MODULE, "room", SW_NORMAL); + RestoreWindowPosition(m_hwnd, NULL, false); LONG_PTR mask = GetWindowLongPtr(m_tab.GetHwnd(), GWL_STYLE); if (g_Settings.bTabsAtBottom) @@ -268,22 +268,24 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) case GC_FIXTABICONS: if (CChatRoomDlg *pDlg = (CChatRoomDlg*)lParam) { int idx = m_tab.GetDlgIndex(pDlg); - if (idx != -1) { - int image = 0; - if (!(pDlg->m_si->wState & GC_EVENT_HIGHLIGHT)) { - MODULEINFO *mi = pci->MM_FindModule(pDlg->m_si->pszModule); - image = (pDlg->m_si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex; - if (pDlg->m_si->wState & STATE_TALK) - image++; - } + if (idx == -1) + break; - TCITEM tci = {}; - tci.mask = TCIF_IMAGE; - TabCtrl_GetItem(m_tab.GetHwnd(), idx, &tci); - if (tci.iImage != image) { - tci.iImage = image; - TabCtrl_SetItem(m_tab.GetHwnd(), idx, &tci); - } + SESSION_INFO *si = pDlg->m_si; + int image = 0; + if (!(si->wState & GC_EVENT_HIGHLIGHT)) { + MODULEINFO *mi = pci->MM_FindModule(si->pszModule); + image = (si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex; + if (si->wState & STATE_TALK) + image++; + } + + TCITEM tci = {}; + tci.mask = TCIF_IMAGE; + TabCtrl_GetItem(m_tab.GetHwnd(), idx, &tci); + if (tci.iImage != image) { + tci.iImage = image; + TabCtrl_SetItem(m_tab.GetHwnd(), idx, &tci); } } else RedrawWindow(m_tab.GetHwnd(), NULL, NULL, RDW_INVALIDATE); @@ -437,17 +439,14 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) if ((i = TabCtrl_HitTest(((LPNMHDR)lParam)->hwndFrom, &tci)) == -1) break; - TCITEM id = {}; - id.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(m_hwnd, IDC_TAB), i, &id); + SESSION_INFO *si = ((CChatRoomDlg*)m_tab.GetNthPage(i))->m_si; ClientToScreen(GetDlgItem(m_hwnd, IDC_TAB), &tci.pt); HMENU hSubMenu = GetSubMenu(g_hMenu, 5); TranslateMenu(hSubMenu); - SESSION_INFO *s = (SESSION_INFO*)id.lParam; - if (s) { - WORD w = db_get_w(s->hContact, s->pszModule, "TabPosition", 0); + if (si) { + WORD w = db_get_w(si->hContact, si->pszModule, "TabPosition", 0); if (w == 0) CheckMenuItem(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND | MF_UNCHECKED); else @@ -457,35 +456,29 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, tci.pt.x, tci.pt.y, 0, m_hwnd, NULL)) { case ID_CLOSE: - if (TabCtrl_GetCurSel(GetDlgItem(m_hwnd, IDC_TAB)) == i) - PostMessage(m_hwnd, GC_CLOSEWINDOW, 0, 0); - else - m_tab.RemovePage(i); + SendMessage(m_hwnd, GC_REMOVETAB, 0, (LPARAM)m_tab.GetNthPage(i)); break; - case ID_CLOSEOTHER: - { - int tabCount = m_tab.GetCount()-1; - if (tabCount > 0) { - for (tabCount; tabCount >= 0; tabCount--) { - if (tabCount == i) - continue; - - m_tab.RemovePage(tabCount); - } - m_tab.ActivatePage(0); + case ID_LOCKPOSITION: + if (si != 0) { + if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) { + if (si->hContact) + db_set_w(si->hContact, si->pszModule, "TabPosition", (WORD)(i + 1)); } + else db_unset(si->hContact, si->pszModule, "TabPosition"); } break; - case ID_LOCKPOSITION: - TabCtrl_GetItem(GetDlgItem(m_hwnd, IDC_TAB), i, &id); - if (s != 0) { - if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) { - if (s->hContact) - db_set_w(s->hContact, s->pszModule, "TabPosition", (WORD)(i + 1)); + case ID_CLOSEOTHER: + int tabCount = m_tab.GetCount() - 1; + if (tabCount > 0) { + for (tabCount; tabCount >= 0; tabCount--) { + if (tabCount == i) + continue; + + m_tab.RemovePage(tabCount); } - else db_unset(s->hContact, s->pszModule, "TabPosition"); + m_tab.ActivatePage(0); } break; } |