diff options
Diffstat (limited to 'plugins/Sessions')
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 672 | ||||
-rw-r--r-- | plugins/Sessions/Src/Resource.h | 4 | ||||
-rw-r--r-- | plugins/Sessions/Src/version.h | 2 | ||||
-rw-r--r-- | plugins/Sessions/res/Sessions.rc | 30 |
4 files changed, 355 insertions, 353 deletions
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index aaa987388a..0467c50705 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -27,39 +27,13 @@ HWND hComboBoxEdit = nullptr; HWND hOpClistControl = nullptr;
-static BOOL bOptionsInit;
-int opses_count;
+int iSessionId;
BOOL bSesssionNameChanged = 0;
MCONTACT session_list_t[255] = { 0 };
-HWND g_opHdlg;
-
-int width;
-HDC hdc = nullptr;
-RECT lprect;
-RECT rc;
-POINT pt;
BOOL bChecked = FALSE;
-int OpLoadSessionContacts(WPARAM, LPARAM lparam)
-{
- memset(session_list_t, 0, sizeof(session_list_t));
-
- for (auto &hContact : Contacts()) {
- if (LoadContactsFromMask(hContact, 1, lparam)) {
- int i = GetInSessionOrder(hContact, 1, lparam);
- session_list_t[i] = hContact;
- }
- }
-
- int i;
- for (i = 0; session_list_t[i] != 0; i++)
- SendDlgItemMessage(g_opHdlg, IDC_OPCLIST, LB_ADDSTRING, 0, (LPARAM)Clist_GetContactDisplayName(session_list_t[i]));
-
- return i;
-}
-
static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -97,13 +71,13 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_NCLBUTTONDBLCLK:
case WM_NCLBUTTONDOWN:
if (!bChecked) {
- MarkUserDefSession(opses_count, 1);
+ MarkUserDefSession(iSessionId, 1);
hIcon = hMarked;
bChecked = TRUE;
RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME);
}
else {
- MarkUserDefSession(opses_count, 0);
+ MarkUserDefSession(iSessionId, 0);
hIcon = hNotMarked;
bChecked = FALSE;
RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME);
@@ -118,13 +92,16 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return TRUE;
case WM_NCPAINT:
- hdc = GetDC(hwnd);
+ RECT rc;
GetClientRect(hwnd, &rc);
rc.left = rc.right;
rc.right = rc.left + 16;
- FillRect(hdc, &rc, (HBRUSH)GetSysColor(COLOR_WINDOW));
- DrawIconEx(hdc, rc.left, 0, hIcon, 16, 16, 0, nullptr, DI_NORMAL);
- ReleaseDC(hwnd, hdc);
+ {
+ HDC hdc = GetDC(hwnd);
+ FillRect(hdc, &rc, (HBRUSH)GetSysColor(COLOR_WINDOW));
+ DrawIconEx(hdc, rc.left, 0, hIcon, 16, 16, 0, nullptr, DI_NORMAL);
+ ReleaseDC(hwnd, hdc);
+ }
break;
case WM_NCCALCSIZE:
@@ -143,359 +120,372 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return mir_callNextSubclass(hwnd, ComboBoxSubclassProc, msg, wParam, lParam);
}
-static INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+class COptionsDlg : public CDlgBase
{
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hdlg);
- {
- COMBOBOXINFO cbi = { 0 };
- cbi.cbSize = sizeof(cbi);
-
- opses_count = 0;
- g_opHdlg = hdlg;
- bOptionsInit = TRUE;
- hMarked = IcoLib_GetIconByHandle(iconList[1].hIcolib);
- hNotMarked = IcoLib_GetIconByHandle(iconList[2].hIcolib);
-
- hIcon = (bChecked = IsMarkedUserDefSession(opses_count)) ? hMarked : hNotMarked;
-
- SetDlgItemInt(hdlg, IDC_TRACK, g_ses_limit = g_plugin.getByte("TrackCount", 10), FALSE);
- SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1));
- SendDlgItemMessage(hdlg, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(hdlg, IDC_TRACK, nullptr, FALSE));
-
- SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
- SetDlgItemInt(hdlg, IDC_STARTDELAY, g_plugin.getWord("StartupModeDelay", 1500), FALSE);
- int startupmode = g_plugin.getByte("StartupMode", 3);
- int exitmode = g_plugin.getByte("ShutdownMode", 2);
-
- g_bExclHidden = g_plugin.getByte("ExclHidden", 0) != 0;
- g_bWarnOnHidden = g_plugin.getByte("WarnOnHidden", 0) != 0;
- g_bOtherWarnings = g_plugin.getByte("OtherWarnings", 1) != 0;
- g_bCrashRecovery = g_plugin.getByte("CrashRecovery", 0) != 0;
-
- CheckDlgButton(hdlg, IDC_EXCLHIDDEN, g_bExclHidden ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_LASTHIDDENWARN, g_bWarnOnHidden ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_WARNINGS, g_bOtherWarnings ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hdlg, IDC_CRASHRECOVERY, g_bCrashRecovery ? BST_CHECKED : BST_UNCHECKED);
-
- if (startupmode == 1)
- CheckDlgButton(hdlg, IDC_STARTDIALOG, BST_CHECKED);
- else if (startupmode == 3) {
- CheckDlgButton(hdlg, IDC_STARTDIALOG, BST_CHECKED);
- CheckDlgButton(hdlg, IDC_CHECKLAST, BST_CHECKED);
- }
- else if (startupmode == 2) {
- CheckDlgButton(hdlg, IDC_RLOADLAST, BST_CHECKED);
- EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
- }
- else if (startupmode == 0) {
- CheckDlgButton(hdlg, IDC_RNOTHING, BST_CHECKED);
- EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
- }
-
- if (exitmode == 0) {
- CheckDlgButton(hdlg, IDC_REXDSAVE, BST_CHECKED);
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC1), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC2), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_TRACK), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_SPIN1), FALSE);
- }
- else if (exitmode == 1)
- CheckDlgButton(hdlg, IDC_REXASK, BST_CHECKED);
- else if (exitmode == 2)
- CheckDlgButton(hdlg, IDC_REXSAVE, BST_CHECKED);
-
- LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", 0);
- if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
- EnableWindow(GetDlgItem(hdlg, IDC_EDIT), TRUE);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
- if (!OpLoadSessionContacts(0, opses_count))
- EnableWindow(GetDlgItem(hdlg, IDC_DEL), FALSE);
+ // returns number of contacts in a session
+ int LoadSessionContacts()
+ {
+ memset(session_list_t, 0, sizeof(session_list_t));
+
+ for (auto &hContact : Contacts()) {
+ if (LoadContactsFromMask(hContact, 1, iSessionId)) {
+ int i = GetInSessionOrder(hContact, 1, iSessionId);
+ session_list_t[i] = hContact;
}
+ }
- GetComboBoxInfo(GetDlgItem(hdlg, IDC_LIST), &cbi);
- mir_subclassWindow(cbi.hwndItem, ComboBoxSubclassProc);
+ int i;
+ for (i = 0; session_list_t[i] != 0; i++)
+ m_opclist.AddString(Clist_GetContactDisplayName(session_list_t[i]));
- hComboBoxEdit = cbi.hwndItem;
- hComboBox = cbi.hwndCombo;
+ return i;
+ }
- SetWindowPos(hComboBoxEdit, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+ CCtrlClc m_clist;
+ CCtrlCombo m_list;
+ CCtrlListBox m_opclist;
+
+ CCtrlCheck chkStartDialog, chkLoadLast, chkLast, chkNothing;
+ CCtrlCheck chkExitAsk, chkExitSave, chkExitNothing;
+ CCtrlButton btnSave, btnEdit, btnDel;
+
+public:
+ COptionsDlg() :
+ CDlgBase(g_plugin, IDD_OPTIONS),
+ m_list(this, IDC_LIST),
+ m_clist(this, IDC_EMCLIST),
+ m_opclist(this, IDC_OPCLIST),
+ btnDel(this, IDC_DEL),
+ btnEdit(this, IDC_EDIT),
+ btnSave(this, IDC_SAVE),
+ chkLast(this, IDC_CHECKLAST),
+ chkExitAsk(this, IDC_REXASK),
+ chkNothing(this, IDC_RNOTHING),
+ chkExitSave(this, IDC_REXSAVE),
+ chkLoadLast(this, IDC_RLOADLAST),
+ chkExitNothing(this, IDC_REXDSAVE),
+ chkStartDialog(this, IDC_STARTDIALOG)
+ {
+ btnDel.OnClick = Callback(this, &COptionsDlg::onClick_Del);
+ btnEdit.OnClick = Callback(this, &COptionsDlg::onClick_Edit);
+ btnSave.OnClick = Callback(this, &COptionsDlg::onClick_Save);
+
+ chkNothing.OnChange = Callback(this, &COptionsDlg::onChange_Nothing);
+ chkLoadLast.OnChange = Callback(this, &COptionsDlg::onChange_LoadLast);
+ chkStartDialog.OnChange = Callback(this, &COptionsDlg::onChange_StartDialog);
+
+ chkExitAsk.OnChange = Callback(this, &COptionsDlg::onChange_ExAsk);
+ chkExitSave.OnChange = Callback(this, &COptionsDlg::onChange_ExSave);
+ chkExitNothing.OnChange = Callback(this, &COptionsDlg::onChange_ExNothing);
+
+ m_list.OnChange = Callback(this, &COptionsDlg::onEditChange_List);
+
+ m_clist.OnCheckChanged = Callback(this, &COptionsDlg::onCheckChanged_Clist);
+ }
- bOptionsInit = FALSE;
+ bool OnInitDialog() override
+ {
+ COMBOBOXINFO cbi = { 0 };
+ cbi.cbSize = sizeof(cbi);
+
+ iSessionId = 0;
+ hMarked = IcoLib_GetIconByHandle(iconList[1].hIcolib);
+ hNotMarked = IcoLib_GetIconByHandle(iconList[2].hIcolib);
+
+ SetWindowLongPtr(m_clist.GetHwnd(), GWL_STYLE,
+ GetWindowLongPtr(m_clist.GetHwnd(), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
+ m_clist.SetExStyle(CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT);
+ m_clist.AutoRebuild();
+
+ hIcon = (bChecked = IsMarkedUserDefSession(iSessionId)) ? hMarked : hNotMarked;
+
+ SetDlgItemInt(m_hwnd, IDC_TRACK, g_ses_limit = g_plugin.getByte("TrackCount", 10), FALSE);
+ SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(10, 1));
+ SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETPOS, 0, GetDlgItemInt(m_hwnd, IDC_TRACK, nullptr, FALSE));
+
+ m_opclist.ResetContent();
+ SetDlgItemInt(m_hwnd, IDC_STARTDELAY, g_plugin.getWord("StartupModeDelay", 1500), FALSE);
+ int startupmode = g_plugin.getByte("StartupMode", 3);
+ int exitmode = g_plugin.getByte("ShutdownMode", 2);
+
+ g_bExclHidden = g_plugin.getByte("ExclHidden", 0) != 0;
+ g_bWarnOnHidden = g_plugin.getByte("WarnOnHidden", 0) != 0;
+ g_bOtherWarnings = g_plugin.getByte("OtherWarnings", 1) != 0;
+ g_bCrashRecovery = g_plugin.getByte("CrashRecovery", 0) != 0;
+
+ CheckDlgButton(m_hwnd, IDC_EXCLHIDDEN, g_bExclHidden ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_LASTHIDDENWARN, g_bWarnOnHidden ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_WARNINGS, g_bOtherWarnings ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(m_hwnd, IDC_CRASHRECOVERY, g_bCrashRecovery ? BST_CHECKED : BST_UNCHECKED);
+
+ if (startupmode == 1)
+ chkStartDialog.SetState(true);
+ else if (startupmode == 3) {
+ chkStartDialog.SetState(true);
+ chkLast.SetState(true);
}
- break;
-
- case WM_CTLCOLORLISTBOX:
- switch (GetDlgCtrlID((HWND)lparam)) {
- case IDC_OPCLIST:
- SetBkMode((HDC)wparam, TRANSPARENT);
- return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_3DFACE));
+ else if (startupmode == 2)
+ chkLoadLast.SetState(true);
+ else if (startupmode == 0)
+ chkNothing.SetState(true);
+
+ if (exitmode == 0)
+ chkExitNothing.SetState(true);
+ else if (exitmode == 1)
+ chkExitAsk.SetState(true);
+ else if (exitmode == 2)
+ chkExitSave.SetState(true);
+
+ LoadSessionToCombobox(m_hwnd, 1, 255, "UserSessionDsc", 0);
+ if (m_list.GetCount()) {
+ btnEdit.Enable();
+ m_list.SetCurSel(0);
+ if (!LoadSessionContacts())
+ btnDel.Disable();
}
- break;
- case WM_NOTIFY:
- switch (((LPNMHDR)lparam)->code) {
- case PSN_APPLY:
- {
- int iDelay = GetDlgItemInt(hdlg, IDC_STARTDELAY, nullptr, FALSE);
- g_plugin.setWord("StartupModeDelay", (WORD)iDelay);
- g_plugin.setByte("TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(hdlg, IDC_TRACK, nullptr, FALSE)));
- if (IsDlgButtonChecked(hdlg, IDC_REXSAVE))
- g_plugin.setByte("ShutdownMode", 2);
- else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE))
- g_plugin.setByte("ShutdownMode", 0);
- else if (IsDlgButtonChecked(hdlg, IDC_REXASK))
- g_plugin.setByte("ShutdownMode", 1);
-
- if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG)) {
- if (BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
- g_plugin.setByte("StartupMode", 1);
- else
- g_plugin.setByte("StartupMode", 3);
- }
- else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST))
- g_plugin.setByte("StartupMode", 2);
- else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING))
- g_plugin.setByte("StartupMode", 0);
-
- g_plugin.setByte("ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
- g_plugin.setByte("WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
- g_plugin.setByte("OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
- g_plugin.setByte("CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
- }
- return 1;
-
- case CLN_CHECKCHANGED:
- if (((LPNMHDR)lparam)->idFrom == IDC_EMCLIST) {
- int iSelection = (INT_PTR)((NMCLISTCONTROL *)lparam)->hItem;
- MCONTACT hContact = db_find_first();
- for (; hContact; hContact = db_find_next(hContact))
- if (SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, hContact, 0) == iSelection)
- break;
- if (hContact)
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), TRUE);
- else
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
- }
+ GetComboBoxInfo(m_list.GetHwnd(), &cbi);
+ mir_subclassWindow(cbi.hwndItem, ComboBoxSubclassProc);
+
+ hComboBoxEdit = cbi.hwndItem;
+ hComboBox = cbi.hwndCombo;
+
+ SetWindowPos(hComboBoxEdit, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ int iDelay = GetDlgItemInt(m_hwnd, IDC_STARTDELAY, nullptr, FALSE);
+ g_plugin.setWord("StartupModeDelay", (WORD)iDelay);
+ g_plugin.setByte("TrackCount", (BYTE)(g_ses_limit = GetDlgItemInt(m_hwnd, IDC_TRACK, nullptr, FALSE)));
+ if (chkExitSave.IsChecked())
+ g_plugin.setByte("ShutdownMode", 2);
+ else if (IsDlgButtonChecked(m_hwnd, IDC_REXDSAVE))
+ g_plugin.setByte("ShutdownMode", 0);
+ else if (chkExitAsk.IsChecked())
+ g_plugin.setByte("ShutdownMode", 1);
+
+ if (chkStartDialog.IsChecked()) {
+ if (chkLast.IsChecked())
+ g_plugin.setByte("StartupMode", 1);
+ else
+ g_plugin.setByte("StartupMode", 3);
}
- break;
+ else if (chkLoadLast.IsChecked())
+ g_plugin.setByte("StartupMode", 2);
+ else if (chkNothing.IsChecked())
+ g_plugin.setByte("StartupMode", 0);
+
+ g_plugin.setByte("ExclHidden", (BYTE)(IsDlgButtonChecked(m_hwnd, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
+ g_plugin.setByte("WarnOnHidden", (BYTE)(IsDlgButtonChecked(m_hwnd, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
+ g_plugin.setByte("OtherWarnings", (BYTE)(IsDlgButtonChecked(m_hwnd, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
+ g_plugin.setByte("CrashRecovery", (BYTE)(IsDlgButtonChecked(m_hwnd, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
+ return true;
+ }
- case WM_COMMAND:
- switch (LOWORD(wparam)) {
- case IDC_LIST:
- switch (HIWORD(wparam)) {
- case CBN_EDITCHANGE:
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), TRUE);
- bSesssionNameChanged = TRUE;
- break;
-
- case CBN_SELCHANGE:
- {
- HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
- int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
- if (index != CB_ERR) {
- opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
- SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
- if (IsMarkedUserDefSession(opses_count)) {
- hIcon = hMarked;
- bChecked = TRUE;
- RedrawWindow(hComboBoxEdit, nullptr, nullptr, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
- }
- else {
- hIcon = hNotMarked;
- bChecked = FALSE;
- RedrawWindow(hComboBoxEdit, nullptr, nullptr, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
- }
- OpLoadSessionContacts(0, opses_count);
- if (!hOpClistControl)
- EnableWindow(GetDlgItem(hdlg, IDC_DEL), TRUE);
- else {
- for (auto &hContact : Contacts())
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 0);
-
- for (int i = 0; session_list_t[i] > 0; i++) {
- MCONTACT hContact = (MCONTACT)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 1);
- }
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
- }
- }
- }
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
+ {
+ switch (msg) {
+ case WM_CTLCOLORLISTBOX:
+ switch (GetDlgCtrlID((HWND)lParam)) {
+ case IDC_OPCLIST:
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_3DFACE));
}
break;
- case IDC_EDIT:
- if (!hOpClistControl) {
- ShowWindow(GetDlgItem(hdlg, IDC_OPCLIST), SW_HIDE);
- EnableWindow(GetDlgItem(hdlg, IDC_DEL), FALSE);
- //EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
- SetDlgItemText(hdlg, IDC_EDIT, TranslateT("View"));
- hOpClistControl = CreateWindowEx(WS_EX_STATICEDGE, CLISTCONTROL_CLASSW, L"",
- WS_TABSTOP | WS_VISIBLE | WS_CHILD,
- 14, 198, 161, 163, hdlg, (HMENU)IDC_EMCLIST, g_plugin.getInst(), nullptr);
-
- SetWindowLongPtr(hOpClistControl, GWL_STYLE,
- GetWindowLongPtr(hOpClistControl, GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
- SendMessage(hOpClistControl, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
- SendMessage(hOpClistControl, CLM_AUTOREBUILD, 0, 0);
-
- for (int i = 0; session_list_t[i] > 0; i++) {
- HANDLE hItem = (HANDLE)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
- SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
+ case WM_NOTIFY:
+ if (LOWORD(wParam) == IDC_LIST && !hOpClistControl) {
+ if (HIWORD(wParam) == CBN_DROPDOWN) {
+ SendMessage(hComboBoxEdit, EM_SETSEL, 0, 0);
+ SendMessage(hComboBoxEdit, EM_SCROLLCARET, 0, 0);
+ SendMessage(hComboBoxEdit, WM_KILLFOCUS, 0, 0);
}
- }
- else {
- ShowWindow(GetDlgItem(hdlg, IDC_OPCLIST), SW_SHOWNA);
- EnableWindow(GetDlgItem(hdlg, IDC_DEL), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
- SetDlgItemText(hdlg, IDC_EDIT, TranslateT("Edit"));
- DestroyWindow(hOpClistControl);
- hOpClistControl = nullptr;
- }
- break;
+ else SendMessage(hComboBoxEdit, EM_SCROLLCARET, 0, 0);
- case IDC_SAVE:
- {
- int i = 0;
- for (auto &hContact : Contacts()) {
- BYTE res = (BYTE)SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_GETCHECKMARK,
- SendDlgItemMessage(hdlg, IDC_EMCLIST, CLM_FINDCONTACT, hContact, 0), 0);
- if (res) {
- SetSessionMark(hContact, 1, '1', opses_count);
- SetInSessionOrder(hContact, 1, opses_count, i);
- i++;
- }
- else {
- SetSessionMark(hContact, 1, '0', opses_count);
- SetInSessionOrder(hContact, 1, opses_count, 0);
- }
- }
- if (bSesssionNameChanged) {
- if (GetWindowTextLength(hComboBoxEdit)) {
- wchar_t szUserSessionName[MAX_PATH] = { '\0' };
- GetWindowText(hComboBoxEdit, szUserSessionName, _countof(szUserSessionName));
- RenameUserDefSession(opses_count, szUserSessionName);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
- LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", 0);
- }
- bSesssionNameChanged = FALSE;
- }
- EnableWindow(GetDlgItem(hdlg, IDC_SAVE), FALSE);
+ HideCaret(hComboBoxEdit);
}
- break;
+ }
+
+ return CDlgBase::DlgProc(msg, wParam, lParam);
+ }
+
+ void onCheckChanged_Clist(CCtrlClc::TEventInfo*)
+ {
+ btnSave.Enable();
+ }
- case IDC_DEL:
- DelUserDefSession(opses_count);
+ void onEditChange_List(CCtrlCombo *)
+ {
+ btnSave.Enable();
+ bSesssionNameChanged = TRUE;
+ }
- SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
+ void onSelChange_List(CCtrlCombo *)
+ {
+ int index = m_list.GetCurSel();
+ if (index == CB_ERR)
+ return;
- LoadSessionToCombobox(hdlg, 1, 255, "UserSessionDsc", 0);
+ iSessionId = m_list.GetItemData(index);
+ m_opclist.ResetContent();
+ if (IsMarkedUserDefSession(iSessionId)) {
+ hIcon = hMarked;
+ bChecked = TRUE;
+ RedrawWindow(hComboBoxEdit, nullptr, nullptr, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
+ }
+ else {
+ hIcon = hNotMarked;
+ bChecked = FALSE;
+ RedrawWindow(hComboBoxEdit, nullptr, nullptr, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
+ }
+ LoadSessionContacts();
+ if (!hOpClistControl)
+ btnDel.Enable();
+ else {
+ for (auto &hContact : Contacts())
+ SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 0);
- opses_count = 0;
+ for (int i = 0; session_list_t[i] > 0; i++) {
+ MCONTACT hContact = (MCONTACT)SendMessage(hOpClistControl, CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
+ SendMessage(hOpClistControl, CLM_SETCHECKMARK, hContact, 1);
+ }
+ btnSave.Disable();
+ }
+ }
- if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
- EnableWindow(GetDlgItem(hdlg, IDC_EDIT), TRUE);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
- if (!OpLoadSessionContacts(0, opses_count))
- EnableWindow(GetDlgItem(hdlg, IDC_DEL), FALSE);
+ void onClick_Edit(CCtrlButton *)
+ {
+ if (!hOpClistControl) {
+ m_opclist.Hide();
+ m_clist.Show();
+ btnDel.Disable();
+ btnEdit.SetText(TranslateT("View"));
+ hOpClistControl = m_clist.GetHwnd();
+
+ for (int i = 0; session_list_t[i] > 0; i++)
+ m_clist.SetCheck(m_clist.FindContact(session_list_t[i]), true);
+ }
+ else {
+ m_clist.Hide();
+ m_opclist.Show();
+ btnDel.Enable();
+ btnSave.Disable();
+ btnEdit.SetText(TranslateT("Edit"));
+ hOpClistControl = nullptr;
+ }
+ }
+
+ void onClick_Save(CCtrlButton *)
+ {
+ int i = 0;
+ for (auto &hContact : Contacts()) {
+ BYTE res = m_clist.GetCheck(m_clist.FindContact(hContact));
+ if (res) {
+ SetSessionMark(hContact, 1, '1', iSessionId);
+ SetInSessionOrder(hContact, 1, iSessionId, i);
+ i++;
}
else {
- EnableWindow(GetDlgItem(hdlg, IDC_EDIT), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_DEL), FALSE);
+ SetSessionMark(hContact, 1, '0', iSessionId);
+ SetInSessionOrder(hContact, 1, iSessionId, 0);
}
- break;
+ }
+ if (bSesssionNameChanged) {
+ if (GetWindowTextLength(hComboBoxEdit)) {
+ wchar_t szUserSessionName[MAX_PATH] = { '\0' };
+ GetWindowText(hComboBoxEdit, szUserSessionName, _countof(szUserSessionName));
+ RenameUserDefSession(iSessionId, szUserSessionName);
+ m_list.ResetContent();
+ LoadSessionToCombobox(m_hwnd, 1, 255, "UserSessionDsc", 0);
+ }
+ bSesssionNameChanged = FALSE;
+ }
- case IDC_STARTDIALOG:
- EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), TRUE);
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
+ btnSave.Disable();
+ }
- case IDC_RLOADLAST:
- EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
+ void onClick_Del(CCtrlButton *)
+ {
+ DelUserDefSession(iSessionId);
- case IDC_RNOTHING:
- EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
+ m_opclist.ResetContent();
+ m_list.ResetContent();
- case IDC_REXSAVE:
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC1), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC2), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_TRACK), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_SPIN1), TRUE);
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
+ LoadSessionToCombobox(m_hwnd, 1, 255, "UserSessionDsc", 0);
- case IDC_REXDSAVE:
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC1), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC2), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_TRACK), FALSE);
- EnableWindow(GetDlgItem(hdlg, IDC_SPIN1), FALSE);
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
+ iSessionId = 0;
- case IDC_REXASK:
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC1), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_EXSTATIC2), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_TRACK), TRUE);
- EnableWindow(GetDlgItem(hdlg, IDC_SPIN1), TRUE);
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
+ if (m_list.GetCount()) {
+ btnEdit.Enable();
+ m_list.SetCurSel(0);
+ if (!LoadSessionContacts())
+ btnDel.Disable();
}
-
- if (HIWORD(wparam) == CBN_DROPDOWN && !hOpClistControl) {
- SendMessage(hComboBoxEdit, EM_SETSEL, 0, 0);
- SendMessage(hComboBoxEdit, EM_SCROLLCARET, 0, 0);
- SendMessage(hComboBoxEdit, WM_KILLFOCUS, 0, 0);
- HideCaret(hComboBoxEdit);
+ else {
+ btnEdit.Disable();
+ btnDel.Disable();
}
+ }
- if ((HIWORD(wparam) != CBN_DROPDOWN) && (LOWORD(wparam) == IDC_LIST) && !hOpClistControl) {
- SendMessage(hComboBoxEdit, EM_SCROLLCARET, 0, 0);
- HideCaret(hComboBoxEdit);
- }
+ void onChange_StartDialog(CCtrlCheck *)
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STARTDELAY), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STATICOP), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STATICMS), TRUE);
+ chkLast.Enable();
+ }
- if ((LOWORD(wparam) == IDC_STARTDELAY) && (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus()))
- return 0;
+ void onChange_LoadLast(CCtrlCheck *)
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STARTDELAY), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STATICOP), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STATICMS), TRUE);
+ chkLast.Disable();
+ }
- if (lparam && !bOptionsInit && (HIWORD(wparam) == BN_CLICKED) && (GetFocus() == (HWND)lparam) &&
- ((LOWORD(wparam) == IDC_CHECKLAST) || ((LOWORD(wparam) >= IDC_EXCLHIDDEN) && (LOWORD(wparam) <= IDC_CRASHRECOVERY))))
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ void onChange_Nothing(CCtrlCheck *)
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STARTDELAY), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STATICOP), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_STATICMS), FALSE);
+ chkLast.Disable();
+ }
- return 0;
+ void onChange_ExSave(CCtrlCheck *)
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC1), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC2), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_TRACK), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SPIN1), TRUE);
+ }
- case WM_CLOSE:
- EndDialog(hdlg, 0);
- return 0;
+ void onChange_ExNothing(CCtrlCheck *)
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC1), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC2), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_TRACK), FALSE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SPIN1), FALSE);
}
- return 0;
-}
+
+ void onChange_ExAsk(CCtrlCheck *)
+ {
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC1), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_EXSTATIC2), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_TRACK), TRUE);
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SPIN1), TRUE);
+ }
+};
int OptionsInit(WPARAM wparam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {};
- odp.position = 955000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
- odp.szTitle.a = MODULENAME;
- odp.pfnDlgProc = OptionsProc;
odp.szGroup.a = LPGEN("Message sessions");
+ odp.szTitle.a = MODULENAME;
odp.flags = ODPF_BOLDGROUPS;
+ odp.position = 955000000;
+ odp.pDialog = new COptionsDlg();
g_plugin.addOptions(wparam, &odp);
return 0;
}
diff --git a/plugins/Sessions/Src/Resource.h b/plugins/Sessions/Src/Resource.h index 0a70198bcf..b31b24e0ea 100644 --- a/plugins/Sessions/Src/Resource.h +++ b/plugins/Sessions/Src/Resource.h @@ -7,10 +7,8 @@ #define IDI_SESSIONS_LOAD 103
#define IDD_SESSIONS_SAVE 104
#define IDD_SESSIONS_LOADLAST 105
-
#define IDD_SESSION_CHECKED 106
#define IDD_SESSION_UNCHECKED 107
-
#define IDD_WLCMDIALOG 120
#define IDD_SAVEDIALOG 121
#define IDD_EXDIALOG 123
@@ -50,7 +48,7 @@ //
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 124
+#define _APS_NEXT_RESOURCE_VALUE 125
#define _APS_NEXT_COMMAND_VALUE 40015
#define _APS_NEXT_CONTROL_VALUE 1059
#define _APS_NEXT_SYMED_VALUE 1125
diff --git a/plugins/Sessions/Src/version.h b/plugins/Sessions/Src/version.h index 53300b236f..76ee24f1e2 100644 --- a/plugins/Sessions/Src/version.h +++ b/plugins/Sessions/Src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 4 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 #include <stdver.h> diff --git a/plugins/Sessions/res/Sessions.rc b/plugins/Sessions/res/Sessions.rc index 28a0f5ff14..bf5fc4cae0 100644 --- a/plugins/Sessions/res/Sessions.rc +++ b/plugins/Sessions/res/Sessions.rc @@ -16,10 +16,8 @@ // Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
-#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1251)
-#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@@ -59,16 +57,17 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN
GROUPBOX "Action on Startup",IDC_STATIC,6,11,157,75
CONTROL "Open Sessions Manager dialog",IDC_STARTDIALOG,"Button",BS_AUTORADIOBUTTON | WS_GROUP,9,21,144,10
- CONTROL "Restore Last Session",IDC_RLOADLAST,"Button",BS_AUTORADIOBUTTON,9,42,144,10
- CONTROL "Do nothing",IDC_RNOTHING,"Button",BS_AUTORADIOBUTTON,9,54,144,10
- CONTROL "Only if last session present",IDC_CHECKLAST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,31,126,10
+ CONTROL "Restore Last Session",IDC_RLOADLAST,"Button",BS_AUTORADIOBUTTON,9,43,144,10
+ CONTROL "Do nothing",IDC_RNOTHING,"Button",BS_AUTORADIOBUTTON,9,55,144,10
+ CONTROL "Only if last session present",IDC_CHECKLAST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,32,126,10
EDITTEXT IDC_STARTDELAY,105,70,26,12,ES_AUTOHSCROLL | ES_NUMBER
- LTEXT "Startup delay",IDC_STATICOP,51,72,54,8
+ LTEXT "Startup delay",IDC_STATICOP,9,72,93,8
LTEXT "ms",IDC_STATICMS,136,72,16,8
GROUPBOX "User Sessions Management",IDC_STATIC,6,96,157,129
PUSHBUTTON "Edit",IDC_EDIT,119,132,42,13,WS_DISABLED
COMBOBOX IDC_LIST,9,107,107,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_OPCLIST,9,122,107,100,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL
+ CONTROL "",IDC_EMCLIST,"CListControl",NOT WS_VISIBLE | WS_TABSTOP,9,122,107,100
PUSHBUTTON "Delete",IDC_DEL,119,107,42,13
PUSHBUTTON "Save",IDC_SAVE,119,145,42,13,WS_DISABLED
GROUPBOX "Action on Exit",IDC_STATIC,170,11,128,75
@@ -76,7 +75,7 @@ BEGIN CONTROL "Save Current Session",IDC_REXSAVE,"Button",BS_AUTORADIOBUTTON,173,37,122,10
CONTROL "Do nothing",IDC_REXDSAVE,"Button",BS_AUTORADIOBUTTON,173,50,122,10
EDITTEXT IDC_TRACK,224,70,27,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
- CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_TABSTOP,241,62,10,14
+ CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_TABSTOP,246,69,10,14
LTEXT "Save only last",IDC_EXSTATIC1,173,72,48,8
LTEXT "sessions",IDC_EXSTATIC2,253,72,28,8
GROUPBOX "Misc",IDC_STATIC,170,96,128,95
@@ -131,7 +130,7 @@ END //
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
+GUIDELINES DESIGNINFO
BEGIN
IDD_OPTIONS, DIALOG
BEGIN
@@ -183,13 +182,28 @@ END // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_SESSIONS ICON "sessions.ico"
+
IDI_SESSIONS_LOAD ICON "load.ico"
+
IDD_SESSIONS_SAVE ICON "save.ico"
+
IDD_SESSIONS_LOADLAST ICON "loadlast.ico"
+
IDD_SESSION_CHECKED ICON "checked.ico"
+
IDD_SESSION_UNCHECKED ICON "unchecked.ico"
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPTIONS AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
|