diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-25 14:11:24 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-25 14:11:24 +0300 |
commit | 855ca62463d7cfc011228da38fadcd3c2b70fe8b (patch) | |
tree | 45bc4fab69dbce0d078278cbb66ecbeacae2ecaa /plugins/TabSRMM/src/msgdlgutils.cpp | |
parent | 19bf42ce996ea933dfbb234034ff317a7edd3bf0 (diff) |
code cleaning
Diffstat (limited to 'plugins/TabSRMM/src/msgdlgutils.cpp')
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 74a02425a0..2f16a2a7cc 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -438,6 +438,33 @@ void CTabBaseDlg::UpdateReadChars() const InvalidateRect(m_pContainer->hwndStatus, nullptr, FALSE);
}
+void CTabBaseDlg::UpdateSaveAndSendButton()
+{
+ GETTEXTLENGTHEX gtxl = { 0 };
+ gtxl.codepage = CP_UTF8;
+ gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMBYTES;
+
+ int len = SendDlgItemMessage(m_hwnd, IDC_SRMM_MESSAGE, EM_GETTEXTLENGTHEX, (WPARAM)>xl, 0);
+ if (len && GetSendButtonState(m_hwnd) == PBS_DISABLED)
+ EnableSendButton(true);
+ else if (len == 0 && GetSendButtonState(m_hwnd) != PBS_DISABLED)
+ EnableSendButton(false);
+
+ if (len) { // looks complex but avoids flickering on the button while typing.
+ if (!(m_dwFlags & MWF_SAVEBTN_SAV)) {
+ SendDlgItemMessage(m_hwnd, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_BUTTON_SAVE]);
+ SendDlgItemMessage(m_hwnd, IDC_SAVE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Save and close session"), BATF_UNICODE);
+ m_dwFlags |= MWF_SAVEBTN_SAV;
+ }
+ }
+ else {
+ SendDlgItemMessage(m_hwnd, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)PluginConfig.g_buttonBarIcons[ICON_BUTTON_CANCEL]);
+ SendDlgItemMessage(m_hwnd, IDC_SAVE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Close session"), BATF_UNICODE);
+ m_dwFlags &= ~MWF_SAVEBTN_SAV;
+ }
+ m_textLen = len;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// update all status bar fields and force a redraw of the status bar.
@@ -1600,11 +1627,9 @@ HICON CTabBaseDlg::GetXStatusIcon() const LRESULT TSAPI GetSendButtonState(HWND hwnd)
{
HWND hwndIDok = GetDlgItem(hwnd, IDOK);
-
if (hwndIDok)
- return(SendMessage(hwndIDok, BUTTONGETSTATEID, TRUE, 0));
- else
- return 0;
+ return SendMessage(hwndIDok, BUTTONGETSTATEID, TRUE, 0);
+ return 0;
}
void CTabBaseDlg::EnableSendButton(bool bMode) const
@@ -1617,6 +1642,13 @@ void CTabBaseDlg::EnableSendButton(bool bMode) const SendMessage(hwndOK, BUTTONSETASNORMAL, bMode, 0);
}
+void CTabBaseDlg::EnableSending(bool bMode) const
+{
+ m_message.SendMsg(EM_SETREADONLY, !bMode, 0);
+ Utils::enableDlgControl(m_hwnd, IDC_CLIST, bMode);
+ EnableSendButton(bMode);
+}
+
void CTabBaseDlg::SendNudge() const
{
if (ProtoServiceExists(m_cache->getActiveProto(), PS_SEND_NUDGE) && ServiceExists(MS_NUDGE_SEND))
|