summaryrefslogtreecommitdiff
path: root/plugins/DbEditorPP
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-04-29 19:27:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-04-29 19:27:21 +0300
commit2ad8065a86c821afade51c45c49b5127b0e6c117 (patch)
treeb539ef5fa06ab7ea788ba83f3b34f951a5563634 /plugins/DbEditorPP
parent48a415461c0fb80861a6bfdccdda3490947c74f1 (diff)
Dbeditor++: main window definition went to header file, so its methods could be implemented now in different modules
Diffstat (limited to 'plugins/DbEditorPP')
-rw-r--r--plugins/DbEditorPP/src/main.cpp2
-rw-r--r--plugins/DbEditorPP/src/main_window.cpp941
-rw-r--r--plugins/DbEditorPP/src/moduletree.cpp26
-rw-r--r--plugins/DbEditorPP/src/settinglist.cpp17
-rw-r--r--plugins/DbEditorPP/src/stdafx.h39
5 files changed, 513 insertions, 512 deletions
diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp
index 17dac20404..b7c9c4fc6b 100644
--- a/plugins/DbEditorPP/src/main.cpp
+++ b/plugins/DbEditorPP/src/main.cpp
@@ -74,7 +74,7 @@ INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM)
{
if (!hwnd2mainWindow) { // so only opens 1 at a time
hRestore = wParam;
- openMainWindow();
+ (new CMainDlg())->Create();
}
else {
ShowWindow(hwnd2mainWindow, SW_RESTORE);
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp
index 7b1b6ca197..a281640f1f 100644
--- a/plugins/DbEditorPP/src/main_window.cpp
+++ b/plugins/DbEditorPP/src/main_window.cpp
@@ -20,9 +20,6 @@ extern HWND hwnd2Tree;
void EditFinish(int selected);
void EditLabel(int item, int subitem);
-void moduleListRightClick(HWND hwnd, CContextMenuPos&);
-void SettingsListRightClick(HWND hwnd, CContextMenuPos&);
-
static LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -146,574 +143,540 @@ static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd, UINT msg, WPA
/////////////////////////////////////////////////////////////////////////////////////////
// Main window dialog
-class CMainDlg : public CDlgBase
+CMainDlg::CMainDlg() :
+ CDlgBase(g_plugin, IDD_MAIN),
+ m_modules(this, IDC_MODULES),
+ m_settings(this, IDC_SETTINGS),
+ m_splitter(this, IDC_SPLITTER),
+ splitterPos(g_plugin.getWord("Splitter", 200))
{
- int splitterPos;
- int lastColumn = -1;
-
- CSplitter m_splitter;
- CCtrlTreeView m_modules;
- CCtrlListView m_settings;
-
- UI_MESSAGE_MAP(CMainDlg, CDlgBase);
- UI_MESSAGE(WM_FINDITEM, OnFindItem);
- UI_MESSAGE(WM_COMMAND, OnCommand);
- UI_MESSAGE_MAP_END();
-
-public:
- CMainDlg() :
- CDlgBase(g_plugin, IDD_MAIN),
- m_modules(this, IDC_MODULES),
- m_settings(this, IDC_SETTINGS),
- m_splitter(this, IDC_SPLITTER),
- splitterPos(g_plugin.getWord("Splitter", 200))
- {
- SetMinSize(450, 300);
-
- m_autoClose = 0;
-
- m_splitter.OnChange = Callback(this, &CMainDlg::onChange_Splitter);
-
- m_modules.OnItemExpanding = Callback(this, &CMainDlg::onItemExpand_Modules);
- m_modules.OnSelChanged = Callback(this, &CMainDlg::onSelChanged_Modules);
- m_modules.OnBeginLabelEdit = Callback(this, &CMainDlg::onBeginLabelEdit_Modules);
- m_modules.OnEndLabelEdit = Callback(this, &CMainDlg::onEndLabelEdit_Modules);
- m_modules.OnBuildMenu = Callback(this, &CMainDlg::onContextMenu_Modules);
-
- m_settings.OnClick = Callback(this, &CMainDlg::onClick_Settings);
- m_settings.OnDoubleClick = Callback(this, &CMainDlg::onDblClick_Settings);
- m_settings.OnColumnClick = Callback(this, &CMainDlg::onColumnClick_Settings);
- m_settings.OnBuildMenu = Callback(this, &CMainDlg::onContextMenu_Settings);
- }
+ SetMinSize(450, 300);
- bool OnInitDialog() override
- {
- hwnd2mainWindow = m_hwnd;
- hwnd2Tree = GetDlgItem(m_hwnd, IDC_MODULES);
- hwnd2List = GetDlgItem(m_hwnd, IDC_SETTINGS);
+ m_autoClose = 0;
- LoadResidentSettings();
+ m_splitter.OnChange = Callback(this, &CMainDlg::onChange_Splitter);
- // image list
- hImg = LoadIcons();
+ m_modules.OnItemExpanding = Callback(this, &CMainDlg::onItemExpand_Modules);
+ m_modules.OnSelChanged = Callback(this, &CMainDlg::onSelChanged_Modules);
+ m_modules.OnBeginLabelEdit = Callback(this, &CMainDlg::onBeginLabelEdit_Modules);
+ m_modules.OnEndLabelEdit = Callback(this, &CMainDlg::onEndLabelEdit_Modules);
+ m_modules.OnBuildMenu = Callback(this, &CMainDlg::onContextMenu_Modules);
- // do the icon
- SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT)));
- SetWindowText(m_hwnd, TranslateT("Database Editor++"));
+ m_settings.OnClick = Callback(this, &CMainDlg::onClick_Settings);
+ m_settings.OnDoubleClick = Callback(this, &CMainDlg::onDblClick_Settings);
+ m_settings.OnColumnClick = Callback(this, &CMainDlg::onColumnClick_Settings);
+ m_settings.OnBuildMenu = Callback(this, &CMainDlg::onContextMenu_Settings);
+}
- // module tree
- mir_subclassWindow(hwnd2Tree, ModuleTreeSubclassProc);
- m_modules.SetImageList(hImg, TVSIL_NORMAL);
+bool CMainDlg::OnInitDialog()
+{
+ hwnd2mainWindow = m_hwnd;
+ hwnd2Tree = GetDlgItem(m_hwnd, IDC_MODULES);
+ hwnd2List = GetDlgItem(m_hwnd, IDC_SETTINGS);
- //setting list
- mir_subclassWindow(hwnd2List, SettingListSubclassProc);
- m_settings.SetExtendedListViewStyle(32 | LVS_EX_SUBITEMIMAGES | LVS_EX_LABELTIP); //LVS_EX_GRIDLINES
- loadListSettings(hwnd2List, csSettingList);
- m_settings.SetImageList(hImg, LVSIL_SMALL);
+ LoadResidentSettings();
- HMENU hMenu = GetMenu(m_hwnd);
- TranslateMenu(hMenu);
- for (int i = 0; i < 6; i++)
- TranslateMenu(GetSubMenu(hMenu, i));
+ // image list
+ hImg = LoadIcons();
- Utils_RestoreWindowPosition(m_hwnd, NULL, MODULENAME, "Main_");
- if (g_plugin.getByte("Maximized", 0))
- ShowWindow(m_hwnd, SW_SHOWMAXIMIZED);
+ // do the icon
+ SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT)));
+ SetWindowText(m_hwnd, TranslateT("Database Editor++"));
- g_Inline = !g_plugin.getByte("DontAllowInLineEdit", 1);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
+ // module tree
+ mir_subclassWindow(hwnd2Tree, ModuleTreeSubclassProc);
+ m_modules.SetImageList(hImg, TVSIL_NORMAL);
- g_Mode = MODE_ALL;
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_CHECKED);
+ //setting list
+ mir_subclassWindow(hwnd2List, SettingListSubclassProc);
+ m_settings.SetExtendedListViewStyle(32 | LVS_EX_SUBITEMIMAGES | LVS_EX_LABELTIP); //LVS_EX_GRIDLINES
+ loadListSettings(hwnd2List, csSettingList);
+ m_settings.SetImageList(hImg, LVSIL_SMALL);
- g_Hex = g_plugin.getByte("HexMode", 0);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((g_Hex & HEX_BYTE) ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_WORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
+ HMENU hMenu = GetMenu(m_hwnd);
+ TranslateMenu(hMenu);
+ for (int i = 0; i < 6; i++)
+ TranslateMenu(GetSubMenu(hMenu, i));
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (g_plugin.bRestoreOnOpen ? MF_CHECKED : MF_UNCHECKED));
+ Utils_RestoreWindowPosition(m_hwnd, NULL, MODULENAME, "Main_");
+ if (g_plugin.getByte("Maximized", 0))
+ ShowWindow(m_hwnd, SW_SHOWMAXIMIZED);
- g_Order = g_plugin.getByte("SortMode", 1);
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED));
+ g_Inline = !g_plugin.getByte("DontAllowInLineEdit", 1);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
- int restore;
- if (hRestore)
- restore = 3;
- else if (g_plugin.bRestoreOnOpen)
- restore = 2;
- else
- restore = 0;
+ g_Mode = MODE_ALL;
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_CHECKED);
- refreshTree(restore);
- return true;
- }
+ g_Hex = g_plugin.getByte("HexMode", 0);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((g_Hex & HEX_BYTE) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_WORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
- void OnDestroy() override
- {
- wchar_t text[256];
-
- if (g_plugin.bRestoreOnOpen) {
- HTREEITEM item;
- if (item = TreeView_GetSelection(hwnd2Tree)) {
- int type = MODULE;
- TVITEM tvi = {};
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
- tvi.pszText = text;
- tvi.cchTextMax = _countof(text);
- tvi.hItem = item;
- if (TreeView_GetItem(hwnd2Tree, &tvi)) {
- MCONTACT hContact = 0;
- if (tvi.lParam) {
- ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
- hContact = mtis->hContact;
- type = mtis->type;
- }
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (g_plugin.bRestoreOnOpen ? MF_CHECKED : MF_UNCHECKED));
- g_plugin.setDword("LastContact", hContact);
+ g_Order = g_plugin.getByte("SortMode", 1);
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED));
- if (type == CONTACT)
- g_plugin.setString("LastModule", "");
- else
- g_plugin.setString("LastModule", _T2A(text));
- }
- else {
- g_plugin.delSetting("LastContact");
- g_plugin.delSetting("LastModule");
- }
+ int restore;
+ if (hRestore)
+ restore = 3;
+ else if (g_plugin.bRestoreOnOpen)
+ restore = 2;
+ else
+ restore = 0;
- int pos = ListView_GetSelectionMark(hwnd2List);
+ refreshTree(restore);
+ return true;
+}
+
+void CMainDlg::OnDestroy()
+{
+ wchar_t text[256];
- if (pos != -1) {
- char data[FLD_SIZE];
- ListView_GetItemTextA(hwnd2List, pos, 0, data, _countof(data));
- g_plugin.setString("LastSetting", data);
+ if (g_plugin.bRestoreOnOpen) {
+ HTREEITEM item;
+ if (item = TreeView_GetSelection(hwnd2Tree)) {
+ int type = MODULE;
+ TVITEM tvi = {};
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
+ tvi.pszText = text;
+ tvi.cchTextMax = _countof(text);
+ tvi.hItem = item;
+ if (TreeView_GetItem(hwnd2Tree, &tvi)) {
+ MCONTACT hContact = 0;
+ if (tvi.lParam) {
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
+ hContact = mtis->hContact;
+ type = mtis->type;
}
+
+ g_plugin.setDword("LastContact", hContact);
+
+ if (type == CONTACT)
+ g_plugin.setString("LastModule", "");
else
- g_plugin.delSetting("LastSetting");
+ g_plugin.setString("LastModule", _T2A(text));
+ }
+ else {
+ g_plugin.delSetting("LastContact");
+ g_plugin.delSetting("LastModule");
}
- }
- g_plugin.setByte("HexMode", (byte)g_Hex);
- g_plugin.setByte("SortMode", (byte)g_Order);
- g_plugin.setByte("DontAllowInLineEdit", (byte)!g_Inline);
+ int pos = ListView_GetSelectionMark(hwnd2List);
- WINDOWPLACEMENT wp;
- wp.length = sizeof(WINDOWPLACEMENT);
- GetWindowPlacement(m_hwnd, &wp);
- if (wp.flags == WPF_RESTORETOMAXIMIZED) {
- g_plugin.setByte("Maximized", 1);
- ShowWindow(m_hwnd, SW_SHOWNOACTIVATE);
+ if (pos != -1) {
+ char data[FLD_SIZE];
+ ListView_GetItemTextA(hwnd2List, pos, 0, data, _countof(data));
+ g_plugin.setString("LastSetting", data);
+ }
+ else
+ g_plugin.delSetting("LastSetting");
}
- else g_plugin.setByte("Maximized", 0);
+ }
- Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "Main_");
- ShowWindow(m_hwnd, SW_HIDE);
+ g_plugin.setByte("HexMode", (byte)g_Hex);
+ g_plugin.setByte("SortMode", (byte)g_Order);
+ g_plugin.setByte("DontAllowInLineEdit", (byte)!g_Inline);
- saveListSettings(hwnd2List, csSettingList);
- ClearListView();
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(m_hwnd, &wp);
+ if (wp.flags == WPF_RESTORETOMAXIMIZED) {
+ g_plugin.setByte("Maximized", 1);
+ ShowWindow(m_hwnd, SW_SHOWNOACTIVATE);
+ }
+ else g_plugin.setByte("Maximized", 0);
- freeTree(0);
+ Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "Main_");
+ ShowWindow(m_hwnd, SW_HIDE);
- hwnd2mainWindow = nullptr;
- hwnd2Tree = nullptr;
- hwnd2List = nullptr;
+ saveListSettings(hwnd2List, csSettingList);
+ ClearListView();
- if (hImg) {
- ImageList_Destroy(hImg);
- hImg = nullptr;
- }
+ freeTree(0);
- FreeResidentSettings();
+ hwnd2mainWindow = nullptr;
+ hwnd2Tree = nullptr;
+ hwnd2List = nullptr;
- if (g_bServiceMode)
- PostQuitMessage(0);
+ if (hImg) {
+ ImageList_Destroy(hImg);
+ hImg = nullptr;
}
- int Resizer(UTILRESIZECONTROL *urc) override
- {
- switch (urc->wId) {
- case IDC_MODULES:
- urc->rcItem.right = splitterPos - 3;
- urc->rcItem.top = 0;
- urc->rcItem.left = 0;
- urc->rcItem.bottom = urc->dlgNewSize.cy;
- return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
-
- case IDC_SPLITTER:
- urc->rcItem.top = 0;
- urc->rcItem.bottom = urc->dlgNewSize.cy;
- urc->rcItem.right = splitterPos;
- urc->rcItem.left = splitterPos - 3;
- return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
-
- case IDC_SETTINGS:
- urc->rcItem.top = 0;
- urc->rcItem.bottom = urc->dlgNewSize.cy;
- urc->rcItem.left = splitterPos;
- urc->rcItem.right = urc->dlgNewSize.cx;
- return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
-
- case IDC_VARS:
- urc->rcItem.top = 0;
- urc->rcItem.bottom = urc->dlgNewSize.cy;
- urc->rcItem.left = 0;
- urc->rcItem.right = urc->dlgNewSize.cx;
- return RD_ANCHORY_CUSTOM | RD_ANCHORX_CUSTOM;
- }
- return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
- }
+ FreeResidentSettings();
- void onChange_Splitter(CSplitter *)
- {
- RECT rc2;
- GetWindowRect(m_hwnd, &rc2);
-
- RECT rc;
- GetClientRect(m_hwnd, &rc);
- POINT pt = { m_splitter.GetPos(), 0 };
- ScreenToClient(m_hwnd, &pt);
-
- splitterPos = rc.left + pt.x + 1;
- if (splitterPos < 150)
- splitterPos = 150;
- if (splitterPos > rc2.right - rc2.left - 150)
- splitterPos = rc2.right - rc2.left - 150;
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
- g_plugin.setWord("Splitter", (WORD)splitterPos);
-
- PostMessage(m_hwnd, WM_SIZE, 0, 0);
+ if (g_bServiceMode)
+ PostQuitMessage(0);
+}
+
+int CMainDlg::Resizer(UTILRESIZECONTROL *urc)
+{
+ switch (urc->wId) {
+ case IDC_MODULES:
+ urc->rcItem.right = splitterPos - 3;
+ urc->rcItem.top = 0;
+ urc->rcItem.left = 0;
+ urc->rcItem.bottom = urc->dlgNewSize.cy;
+ return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
+
+ case IDC_SPLITTER:
+ urc->rcItem.top = 0;
+ urc->rcItem.bottom = urc->dlgNewSize.cy;
+ urc->rcItem.right = splitterPos;
+ urc->rcItem.left = splitterPos - 3;
+ return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
+
+ case IDC_SETTINGS:
+ urc->rcItem.top = 0;
+ urc->rcItem.bottom = urc->dlgNewSize.cy;
+ urc->rcItem.left = splitterPos;
+ urc->rcItem.right = urc->dlgNewSize.cx;
+ return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
+
+ case IDC_VARS:
+ urc->rcItem.top = 0;
+ urc->rcItem.bottom = urc->dlgNewSize.cy;
+ urc->rcItem.left = 0;
+ urc->rcItem.right = urc->dlgNewSize.cx;
+ return RD_ANCHORY_CUSTOM | RD_ANCHORX_CUSTOM;
}
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+}
- LRESULT OnFindItem(UINT, WPARAM wParam, LPARAM)
- {
- ItemInfo *ii = (ItemInfo *)wParam;
- if (HTREEITEM hItem = findItemInTree(ii->hContact, ii->module)) {
- m_modules.SelectItem(hItem);
- m_modules.Expand(hItem, TVE_EXPAND);
- if (ii->type != FW_MODULE)
- SelectSetting(ii->setting);
- }
- return 0;
+void CMainDlg::onChange_Splitter(CSplitter *)
+{
+ RECT rc2;
+ GetWindowRect(m_hwnd, &rc2);
+
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+ POINT pt = { m_splitter.GetPos(), 0 };
+ ScreenToClient(m_hwnd, &pt);
+
+ splitterPos = rc.left + pt.x + 1;
+ if (splitterPos < 150)
+ splitterPos = 150;
+ if (splitterPos > rc2.right - rc2.left - 150)
+ splitterPos = rc2.right - rc2.left - 150;
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
+ g_plugin.setWord("Splitter", (WORD)splitterPos);
+
+ PostMessage(m_hwnd, WM_SIZE, 0, 0);
+}
+
+LRESULT CMainDlg::OnFindItem(UINT, WPARAM wParam, LPARAM)
+{
+ ItemInfo *ii = (ItemInfo *)wParam;
+ if (HTREEITEM hItem = findItemInTree(ii->hContact, ii->module)) {
+ m_modules.SelectItem(hItem);
+ m_modules.Expand(hItem, TVE_EXPAND);
+ if (ii->type != FW_MODULE)
+ SelectSetting(ii->setting);
}
+ return 0;
+}
- LRESULT OnCommand(UINT, WPARAM wParam, LPARAM)
- {
- if (GetKeyState(VK_ESCAPE) & 0x8000)
- return TRUE; // this needs to be changed to c if htere is a label edit happening..
+LRESULT CMainDlg::OnCommand(UINT, WPARAM wParam, LPARAM)
+{
+ if (GetKeyState(VK_ESCAPE) & 0x8000)
+ return TRUE; // this needs to be changed to c if htere is a label edit happening..
- wchar_t text[256];
+ wchar_t text[256];
- switch (LOWORD(wParam)) {
- case MENU_REFRESH_MODS:
- refreshTree(1);
- break;
+ switch (LOWORD(wParam)) {
+ case MENU_REFRESH_MODS:
+ refreshTree(1);
+ break;
- case MENU_REFRESH_SETS:
- TVITEM tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
- tvi.hItem = TreeView_GetSelection(hwnd2Tree);
- tvi.pszText = text; // modulename
- tvi.cchTextMax = _countof(text);
- if (TreeView_GetItem(hwnd2Tree, &tvi)) {
- ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
- if (mtis && (mtis->type == MODULE))
- PopulateSettings(mtis->hContact, _T2A(text));
- else
- ClearListView();
- }
- break;
-
- // watches
- case MENU_VIEW_WATCHES:
- openWatchedVarWindow();
- break;
- case MENU_REMALL_WATCHES:
- freeAllWatches();
- break;
- case MENU_EXPORTDB: // all db
- exportDB(INVALID_CONTACT_ID, nullptr);
- break;
- case MENU_EXPORTCONTACT: // all contacts
- exportDB(INVALID_CONTACT_ID, "");
- break;
- case MENU_EXPORTMODULE: // all settings
- exportDB(NULL, nullptr);
- break;
- case MENU_IMPORTFROMFILE:
- ImportSettingsFromFileMenuItem(NULL, nullptr);
- break;
- case MENU_IMPORTFROMTEXT:
- ImportSettingsMenuItem(NULL);
- break;
- case MENU_EXIT:
- case IDCANCEL:
- DestroyWindow(m_hwnd);
- break;
- case MENU_DELETE:
- deleteModuleDlg();
- break;
- case MENU_FINDANDREPLACE:
- newFindWindow();
- break;
- case MENU_FIX_RESIDENT:
- if (dlg(TranslateT("Delete resident settings from database?"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) {
- int cnt = fixResidentSettings();
- mir_snwprintf(text, TranslateT("%d items deleted."), cnt);
- msg(text);
- }
- break;
- case MENU_FILTER_ALL:
- if (g_Mode != MODE_ALL) {
- HMENU hMenu = GetMenu(m_hwnd);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_CHECKED);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_LOADED, MF_BYCOMMAND | MF_UNCHECKED);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_UNLOADED, MF_BYCOMMAND | MF_UNCHECKED);
- g_Mode = MODE_ALL;
- refreshTree(1);
- }
- break;
- case MENU_FILTER_LOADED:
- if (g_Mode != MODE_LOADED) {
- HMENU hMenu = GetMenu(m_hwnd);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_UNCHECKED);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_LOADED, MF_BYCOMMAND | MF_CHECKED);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_UNLOADED, MF_BYCOMMAND | MF_UNCHECKED);
- g_Mode = MODE_LOADED;
- refreshTree(1);
- }
- break;
- case MENU_FILTER_UNLOADED:
- if (g_Mode != MODE_UNLOADED) {
- HMENU hMenu = GetMenu(m_hwnd);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_UNCHECKED);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_LOADED, MF_BYCOMMAND | MF_UNCHECKED);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_UNLOADED, MF_BYCOMMAND | MF_CHECKED);
- g_Mode = MODE_UNLOADED;
- refreshTree(1);
- }
- break;
- case MENU_BYTE_HEX:
- g_Hex ^= HEX_BYTE;
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((g_Hex & HEX_BYTE) ? MF_CHECKED : MF_UNCHECKED));
- break;
- case MENU_WORD_HEX:
- g_Hex ^= HEX_WORD;
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_WORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED));
- break;
- case MENU_DWORD_HEX:
- g_Hex ^= HEX_DWORD;
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
- break;
- case MENU_SAVE_POSITION:
- {
- bool bSave = !g_plugin.bRestoreOnOpen;
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (bSave ? MF_CHECKED : MF_UNCHECKED));
- g_plugin.bRestoreOnOpen = bSave;
- }
- break;
- case MENU_INLINE_EDIT:
- g_Inline = !g_Inline;
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
- break;
- case MENU_SORT_ORDER:
- g_Order = !g_Order;
- CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED));
+ case MENU_REFRESH_SETS:
+ TVITEM tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
+ tvi.hItem = TreeView_GetSelection(hwnd2Tree);
+ tvi.pszText = text; // modulename
+ tvi.cchTextMax = _countof(text);
+ if (TreeView_GetItem(hwnd2Tree, &tvi)) {
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
+ if (mtis && (mtis->type == MODULE))
+ PopulateSettings(mtis->hContact, _T2A(text));
+ else
+ ClearListView();
+ }
+ break;
+
+ // watches
+ case MENU_VIEW_WATCHES:
+ openWatchedVarWindow();
+ break;
+ case MENU_REMALL_WATCHES:
+ freeAllWatches();
+ break;
+ case MENU_EXPORTDB: // all db
+ exportDB(INVALID_CONTACT_ID, nullptr);
+ break;
+ case MENU_EXPORTCONTACT: // all contacts
+ exportDB(INVALID_CONTACT_ID, "");
+ break;
+ case MENU_EXPORTMODULE: // all settings
+ exportDB(NULL, nullptr);
+ break;
+ case MENU_IMPORTFROMFILE:
+ ImportSettingsFromFileMenuItem(NULL, nullptr);
+ break;
+ case MENU_IMPORTFROMTEXT:
+ ImportSettingsMenuItem(NULL);
+ break;
+ case MENU_EXIT:
+ case IDCANCEL:
+ DestroyWindow(m_hwnd);
+ break;
+ case MENU_DELETE:
+ deleteModuleDlg();
+ break;
+ case MENU_FINDANDREPLACE:
+ newFindWindow();
+ break;
+ case MENU_FIX_RESIDENT:
+ if (dlg(TranslateT("Delete resident settings from database?"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) {
+ int cnt = fixResidentSettings();
+ mir_snwprintf(text, TranslateT("%d items deleted."), cnt);
+ msg(text);
+ }
+ break;
+ case MENU_FILTER_ALL:
+ if (g_Mode != MODE_ALL) {
+ HMENU hMenu = GetMenu(m_hwnd);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_CHECKED);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_LOADED, MF_BYCOMMAND | MF_UNCHECKED);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_UNLOADED, MF_BYCOMMAND | MF_UNCHECKED);
+ g_Mode = MODE_ALL;
refreshTree(1);
- break;
- case MENU_OPEN_OPTIONS:
- g_plugin.openOptions(L"Database", _A2W(modFullname));
- break;
}
- return TRUE;
+ break;
+ case MENU_FILTER_LOADED:
+ if (g_Mode != MODE_LOADED) {
+ HMENU hMenu = GetMenu(m_hwnd);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_UNCHECKED);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_LOADED, MF_BYCOMMAND | MF_CHECKED);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_UNLOADED, MF_BYCOMMAND | MF_UNCHECKED);
+ g_Mode = MODE_LOADED;
+ refreshTree(1);
+ }
+ break;
+ case MENU_FILTER_UNLOADED:
+ if (g_Mode != MODE_UNLOADED) {
+ HMENU hMenu = GetMenu(m_hwnd);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_UNCHECKED);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_LOADED, MF_BYCOMMAND | MF_UNCHECKED);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_UNLOADED, MF_BYCOMMAND | MF_CHECKED);
+ g_Mode = MODE_UNLOADED;
+ refreshTree(1);
+ }
+ break;
+ case MENU_BYTE_HEX:
+ g_Hex ^= HEX_BYTE;
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((g_Hex & HEX_BYTE) ? MF_CHECKED : MF_UNCHECKED));
+ break;
+ case MENU_WORD_HEX:
+ g_Hex ^= HEX_WORD;
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_WORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED));
+ break;
+ case MENU_DWORD_HEX:
+ g_Hex ^= HEX_DWORD;
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
+ break;
+ case MENU_SAVE_POSITION:
+ {
+ bool bSave = !g_plugin.bRestoreOnOpen;
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (bSave ? MF_CHECKED : MF_UNCHECKED));
+ g_plugin.bRestoreOnOpen = bSave;
+ }
+ break;
+ case MENU_INLINE_EDIT:
+ g_Inline = !g_Inline;
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
+ break;
+ case MENU_SORT_ORDER:
+ g_Order = !g_Order;
+ CheckMenuItem(GetSubMenu(GetMenu(m_hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED));
+ refreshTree(1);
+ break;
+ case MENU_OPEN_OPTIONS:
+ g_plugin.openOptions(L"Database", _A2W(modFullname));
+ break;
}
+ return TRUE;
+}
- void onItemExpand_Modules(CCtrlTreeView::TEventInfo *ev)
- {
- if (populating && ev->nmtv->action == TVE_EXPAND) {
- ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ev->nmtv->itemNew.lParam;
- if (mtis && (mtis->type == (CONTACT | EMPTY))) {
- MCONTACT hContact = mtis->hContact;
- mtis->type = CONTACT;
+void CMainDlg::onItemExpand_Modules(CCtrlTreeView::TEventInfo *ev)
+{
+ if (populating && ev->nmtv->action == TVE_EXPAND) {
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ev->nmtv->itemNew.lParam;
+ if (mtis && (mtis->type == (CONTACT | EMPTY))) {
+ MCONTACT hContact = mtis->hContact;
+ mtis->type = CONTACT;
- ModuleSettingLL modlist;
- if (!EnumModules(&modlist))
- return;
+ ModuleSettingLL modlist;
+ if (!EnumModules(&modlist))
+ return;
- ModSetLinkLinkItem *module = modlist.first;
- while (module && hwnd2mainWindow) {
- if (module->name[0] && !IsModuleEmpty(hContact, module->name)) {
- insertItem(hContact, module->name, ev->nmtv->itemNew.hItem);
- }
- module = (ModSetLinkLinkItem *)module->next;
+ ModSetLinkLinkItem *module = modlist.first;
+ while (module && hwnd2mainWindow) {
+ if (module->name[0] && !IsModuleEmpty(hContact, module->name)) {
+ insertItem(hContact, module->name, ev->nmtv->itemNew.hItem);
}
-
- FreeModuleSettingLL(&modlist);
+ module = (ModSetLinkLinkItem *)module->next;
}
+
+ FreeModuleSettingLL(&modlist);
}
}
+}
- void onSelChanged_Modules(CCtrlTreeView::TEventInfo *ev)
- {
- wchar_t text[FLD_SIZE];
+void CMainDlg::onSelChanged_Modules(CCtrlTreeView::TEventInfo *ev)
+{
+ wchar_t text[FLD_SIZE];
- TVITEMEX tvi = {};
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
- tvi.hItem = ev->nmtv->itemNew.hItem;
- tvi.pszText = text;
- tvi.cchTextMax = _countof(text);
- m_modules.GetItem(&tvi);
+ TVITEMEX tvi = {};
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
+ tvi.hItem = ev->nmtv->itemNew.hItem;
+ tvi.pszText = text;
+ tvi.cchTextMax = _countof(text);
+ m_modules.GetItem(&tvi);
+
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
+ if (mtis) {
+ MCONTACT hContact = mtis->hContact;
+ if (mtis->type == STUB)
+ return;
- ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
- if (mtis) {
- MCONTACT hContact = mtis->hContact;
- if (mtis->type == STUB)
- return;
+ if (populating)
+ Select = 0;
- if (populating)
- Select = 0;
+ if (mtis->type == MODULE) {
+ _T2A module(text);
+ PopulateSettings(hContact, module);
+ }
+ else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) {
+ int multi = 0;
- if (mtis->type == MODULE) {
- _T2A module(text);
- PopulateSettings(hContact, module);
- }
- else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) {
- int multi = 0;
+ ClearListView();
- ClearListView();
+ if (mtis->type == CONTACT_ROOT_ITEM && !hContact) {
+ multi = 1;
+ hContact = db_find_first();
+ }
- if (mtis->type == CONTACT_ROOT_ITEM && !hContact) {
- multi = 1;
- hContact = db_find_first();
+ while (hContact && hwnd2mainWindow) {
+ if (multi && ApplyProtoFilter(hContact)) {
+ hContact = db_find_next(hContact);
+ continue;
}
- while (hContact && hwnd2mainWindow) {
- if (multi && ApplyProtoFilter(hContact)) {
- hContact = db_find_next(hContact);
- continue;
- }
-
- addListHandle(hContact);
+ addListHandle(hContact);
- if (!multi)
- break;
+ if (!multi)
+ break;
- hContact = db_find_next(hContact);
- }
+ hContact = db_find_next(hContact);
}
- else ClearListView();
}
else ClearListView();
}
+ else ClearListView();
+}
- void onBeginLabelEdit_Modules(CCtrlTreeView::TEventInfo *ev)
- {
- ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ev->nmtvdi->item.lParam;
- if (!mtis->type || mtis->type == CONTACT) {
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
- return;
- }
-
- mir_subclassWindow(m_modules.GetEditControl(), ModuleTreeLabelEditSubClassProc);
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, FALSE);
- }
-
- void onEndLabelEdit_Modules(CCtrlTreeView::TEventInfo *ev)
- {
- TVITEMEX tvi = {};
- wchar_t text[FLD_SIZE];
- ModuleTreeInfoStruct *mtis;
- tvi.mask = TVIF_HANDLE | TVIF_TEXT | TVIF_PARAM;
- tvi.hItem = ev->nmtvdi->item.hItem;
- tvi.pszText = text;
- tvi.cchTextMax = _countof(text);
- m_modules.GetItem(&tvi);
- mtis = (ModuleTreeInfoStruct *)ev->nmtvdi->item.lParam;
-
- _T2A newtext(ev->nmtvdi->item.pszText);
- _T2A oldtext(tvi.pszText);
-
- if (!newtext // edit control failed
- || !mtis->type // its a root item
- || mtis->type == CONTACT // its a contact
- || newtext[0] == 0) // empty string
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, FALSE);
- else {
- if (mir_strcmp(oldtext, newtext)) {
- renameModule(mtis->hContact, oldtext, newtext);
- findAndRemoveDuplicates(mtis->hContact, newtext);
- if (m_modules.GetItem(&tvi))
- PopulateSettings(mtis->hContact, newtext);
- }
- SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
- }
+void CMainDlg::onBeginLabelEdit_Modules(CCtrlTreeView::TEventInfo *ev)
+{
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ev->nmtvdi->item.lParam;
+ if (!mtis->type || mtis->type == CONTACT) {
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
+ return;
}
- void onContextMenu_Modules(CContextMenuPos *pos)
- {
- moduleListRightClick(m_hwnd, *pos);
- }
+ mir_subclassWindow(m_modules.GetEditControl(), ModuleTreeLabelEditSubClassProc);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, FALSE);
+}
- void onClick_Settings(CCtrlListView::TEventInfo *ev)
- {
- LVHITTESTINFO hti;
- hti.pt = ev->nmlv->ptAction;
- if (m_settings.SubItemHitTest(&hti) > -1) {
- if (g_Inline && hti.iSubItem <= 1 && hti.flags != LVHT_ONITEMICON && info.selectedItem == hti.iItem)
- EditLabel(hti.iItem, hti.iSubItem);
- else
- EditFinish(hti.iItem);
+void CMainDlg::onEndLabelEdit_Modules(CCtrlTreeView::TEventInfo *ev)
+{
+ TVITEMEX tvi = {};
+ wchar_t text[FLD_SIZE];
+ ModuleTreeInfoStruct *mtis;
+ tvi.mask = TVIF_HANDLE | TVIF_TEXT | TVIF_PARAM;
+ tvi.hItem = ev->nmtvdi->item.hItem;
+ tvi.pszText = text;
+ tvi.cchTextMax = _countof(text);
+ m_modules.GetItem(&tvi);
+ mtis = (ModuleTreeInfoStruct *)ev->nmtvdi->item.lParam;
+
+ _T2A newtext(ev->nmtvdi->item.pszText);
+ _T2A oldtext(tvi.pszText);
+
+ if (!newtext // edit control failed
+ || !mtis->type // its a root item
+ || mtis->type == CONTACT // its a contact
+ || newtext[0] == 0) // empty string
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, FALSE);
+ else {
+ if (mir_strcmp(oldtext, newtext)) {
+ renameModule(mtis->hContact, oldtext, newtext);
+ findAndRemoveDuplicates(mtis->hContact, newtext);
+ if (m_modules.GetItem(&tvi))
+ PopulateSettings(mtis->hContact, newtext);
}
- else EditFinish(0);
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, TRUE);
}
+}
- void onDblClick_Settings(CCtrlListView::TEventInfo *ev)
- {
- LVHITTESTINFO hti;
- hti.pt = ev->nmlv->ptAction;
- if (m_settings.SubItemHitTest(&hti) == -1)
- return;
-
- if (!info.module[0]) { // contact
- LVITEM lvi = {};
- lvi.mask = LVIF_PARAM;
- lvi.iItem = hti.iItem;
- if (m_settings.GetItem(&lvi)) {
- ItemInfo ii = {};
- ii.hContact = (MCONTACT)lvi.lParam;
- OnFindItem(0, (WPARAM)&ii, 0);
- }
- return;
- }
-
- if (!g_Inline || hti.iSubItem > 1 || hti.flags == LVHT_ONITEMICON) {
- char setting[FLD_SIZE];
+void CMainDlg::onClick_Settings(CCtrlListView::TEventInfo *ev)
+{
+ LVHITTESTINFO hti;
+ hti.pt = ev->nmlv->ptAction;
+ if (m_settings.SubItemHitTest(&hti) > -1) {
+ if (g_Inline && hti.iSubItem <= 1 && hti.flags != LVHT_ONITEMICON && info.selectedItem == hti.iItem)
+ EditLabel(hti.iItem, hti.iSubItem);
+ else
EditFinish(hti.iItem);
- if (ListView_GetItemTextA(hwnd2List, hti.iItem, 0, setting, _countof(setting)))
- editSetting(info.hContact, info.module, setting);
- }
- else EditLabel(hti.iItem, hti.iSubItem);
}
+ else EditFinish(0);
+}
- void onColumnClick_Settings(CCtrlListView::TEventInfo *ev)
- {
- ColumnsSortParams params = {};
- params.hList = hwnd2List;
- params.column = ev->nmlv->iSubItem;
- params.last = lastColumn;
- ListView_SortItemsEx(params.hList, ColumnsCompare, (LPARAM)&params);
- lastColumn = (params.column == lastColumn) ? -1 : params.column;
+void CMainDlg::onDblClick_Settings(CCtrlListView::TEventInfo *ev)
+{
+ LVHITTESTINFO hti;
+ hti.pt = ev->nmlv->ptAction;
+ if (m_settings.SubItemHitTest(&hti) == -1)
+ return;
+
+ if (!info.module[0]) { // contact
+ LVITEM lvi = {};
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = hti.iItem;
+ if (m_settings.GetItem(&lvi)) {
+ ItemInfo ii = {};
+ ii.hContact = (MCONTACT)lvi.lParam;
+ OnFindItem(0, (WPARAM)&ii, 0);
+ }
+ return;
}
- void onContextMenu_Settings(CContextMenuPos *pos)
- {
- SettingsListRightClick(m_hwnd, *pos);
+ if (!g_Inline || hti.iSubItem > 1 || hti.flags == LVHT_ONITEMICON) {
+ char setting[FLD_SIZE];
+ EditFinish(hti.iItem);
+ if (ListView_GetItemTextA(hwnd2List, hti.iItem, 0, setting, _countof(setting)))
+ editSetting(info.hContact, info.module, setting);
}
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Module entry point
+ else EditLabel(hti.iItem, hti.iSubItem);
+}
-void openMainWindow()
+void CMainDlg::onColumnClick_Settings(CCtrlListView::TEventInfo *ev)
{
- (new CMainDlg())->Create();
+ ColumnsSortParams params = {};
+ params.hList = hwnd2List;
+ params.column = ev->nmlv->iSubItem;
+ params.last = lastColumn;
+ ListView_SortItemsEx(params.hList, ColumnsCompare, (LPARAM)&params);
+ lastColumn = (params.column == lastColumn) ? -1 : params.column;
}
diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp
index 182057a06b..1cf5248935 100644
--- a/plugins/DbEditorPP/src/moduletree.cpp
+++ b/plugins/DbEditorPP/src/moduletree.cpp
@@ -451,15 +451,15 @@ void refreshTree(int restore)
}
// hwnd here is to the main window, NOT the treview
-void moduleListRightClick(HWND hwnd, CContextMenuPos &pos)
+void CMainDlg::onContextMenu_Modules(CContextMenuPos *pos)
{
wchar_t text[FLD_SIZE];
- TVITEM tvi = {};
+ TVITEMEX tvi = {};
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
- tvi.hItem = pos.hItem;
+ tvi.hItem = pos->hItem;
tvi.pszText = text;
tvi.cchTextMax = _countof(text);
- TreeView_GetItem(hwnd2Tree, &tvi);
+ m_modules.GetItem(&tvi);
if (!tvi.lParam)
return;
@@ -496,15 +496,15 @@ void moduleListRightClick(HWND hwnd, CContextMenuPos &pos)
if (watchIdx >= 0)
CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED | MF_BYCOMMAND);
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos.pt.x, pos.pt.y, 0, hwnd, nullptr)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr)) {
case MENU_RENAME_MOD:
skipEnter = true;
- TreeView_EditLabel(hwnd2Tree, tvi.hItem);
+ m_modules.EditLabel(tvi.hItem);
break;
case MENU_DELETE_MOD:
if (deleteModule(hContact, module, 1)) {
- TreeView_DeleteItem(hwnd2Tree, pos.hItem);
+ m_modules.DeleteItem(pos->hItem);
mir_free(mtis);
}
break;
@@ -538,7 +538,7 @@ void moduleListRightClick(HWND hwnd, CContextMenuPos &pos)
break;
case 2: // contact
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos.pt.x, pos.pt.y, 0, hwnd, nullptr)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr)) {
case MENU_CLONE_CONTACT:
if (CloneContact(hContact))
refreshTree(1);
@@ -553,21 +553,21 @@ void moduleListRightClick(HWND hwnd, CContextMenuPos &pos)
}
db_delete_contact(hContact);
freeTree(hContact);
- TreeView_DeleteItem(hwnd2Tree, tvi.hItem);
+ m_modules.DeleteItem(tvi.hItem);
break;
- ////////////////////////////////////////////////////////////////////// divider
case MENU_EXPORTCONTACT:
exportDB(hContact, nullptr);
break;
+
case MENU_IMPORTFROMTEXT:
ImportSettingsMenuItem(hContact);
break;
+
case MENU_IMPORTFROMFILE:
ImportSettingsFromFileMenuItem(hContact, nullptr);
break;
- ////////////////////////////////////////////////////////////////////// divider
case MENU_ADD_MODULE:
addModuleDlg(hContact);
break;
@@ -579,7 +579,7 @@ void moduleListRightClick(HWND hwnd, CContextMenuPos &pos)
break;
case 3: // NULL contact
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos.pt.x, pos.pt.y, 0, hwnd, nullptr)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr)) {
case MENU_ADD_MODULE:
addModuleDlg(hContact);
break;
@@ -599,7 +599,7 @@ void moduleListRightClick(HWND hwnd, CContextMenuPos &pos)
break;
case 4: // Contacts root
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos.pt.x, pos.pt.y, 0, hwnd, nullptr)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr)) {
case MENU_EXPORTCONTACT:
exportDB(INVALID_CONTACT_ID, "");
break;
diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp
index 1212b1c02f..7e83cb9373 100644
--- a/plugins/DbEditorPP/src/settinglist.cpp
+++ b/plugins/DbEditorPP/src/settinglist.cpp
@@ -683,9 +683,9 @@ void EditLabel(int item, int subitem)
}
// hwnd here is to the main window, NOT the listview
-void SettingsListRightClick(HWND hwnd, CContextMenuPos &pos)
+void CMainDlg::onContextMenu_Settings(CContextMenuPos *pos)
{
- if (pos.iCurr == -1) {
+ if (pos->iCurr == -1) {
// nowhere.. new item menu
HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXTMENU));
HMENU hSubMenu = GetSubMenu(hMenu, 6);
@@ -696,7 +696,7 @@ void SettingsListRightClick(HWND hwnd, CContextMenuPos &pos)
RemoveMenu(hSubMenu, 0, MF_BYPOSITION); // separator
}
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos.pt.x, pos.pt.y, 0, hwnd, nullptr)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr)) {
case MENU_ADD_BYTE:
newSetting(info.hContact, info.module, DBVT_BYTE);
break;
@@ -735,8 +735,8 @@ void SettingsListRightClick(HWND hwnd, CContextMenuPos &pos)
LVITEM lvi = {};
lvi.mask = LVIF_IMAGE;
- lvi.iItem = pos.iCurr;
- ListView_GetItem(hwnd2List, &lvi);
+ lvi.iItem = pos->iCurr;
+ m_settings.GetItem(&lvi);
switch (lvi.iImage) {
case IMAGE_STRING:
@@ -781,7 +781,7 @@ void SettingsListRightClick(HWND hwnd, CContextMenuPos &pos)
break;
}
- if (ListView_GetSelectedCount(hwnd2List) > 1) {
+ if (m_settings.GetSelectedCount() > 1) {
RemoveMenu(hSubMenu, 3, MF_BYPOSITION); // convert
RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND);
RemoveMenu(hSubMenu, MENU_COPY_SET, MF_BYCOMMAND);
@@ -789,14 +789,15 @@ void SettingsListRightClick(HWND hwnd, CContextMenuPos &pos)
}
char setting[FLD_SIZE];
- if (!ListView_GetItemTextA(hwnd2List, pos.iCurr, 0, setting, _countof(setting))) return;
+ if (!ListView_GetItemTextA(m_settings.GetHwnd(), pos->iCurr, 0, setting, _countof(setting)))
+ return;
// check if the setting is being watched and if it is then check the menu item
int watchIdx = WatchedArrayIndex(info.hContact, info.module, setting, 1);
if (watchIdx >= 0)
CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED | MF_BYCOMMAND);
- switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos.pt.x, pos.pt.y, 0, hwnd, nullptr)) {
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr)) {
case MENU_EDIT_SET:
editSetting(info.hContact, info.module, setting);
break;
diff --git a/plugins/DbEditorPP/src/stdafx.h b/plugins/DbEditorPP/src/stdafx.h
index c038dd1b80..6926963818 100644
--- a/plugins/DbEditorPP/src/stdafx.h
+++ b/plugins/DbEditorPP/src/stdafx.h
@@ -220,7 +220,44 @@ void saveListSettings(HWND hwnd, ColumnsSettings *cs);
INT_PTR CALLBACK ColumnsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam);
// main_window
-void openMainWindow();
+
+class CMainDlg : public CDlgBase
+{
+ int splitterPos;
+ int lastColumn = -1;
+
+ CSplitter m_splitter;
+ CCtrlTreeView m_modules;
+ CCtrlListView m_settings;
+
+ UI_MESSAGE_MAP(CMainDlg, CDlgBase);
+ UI_MESSAGE(WM_FINDITEM, OnFindItem);
+ UI_MESSAGE(WM_COMMAND, OnCommand);
+ UI_MESSAGE_MAP_END();
+
+public:
+ CMainDlg();
+
+ bool OnInitDialog() override;
+ void OnDestroy() override;
+ int Resizer(UTILRESIZECONTROL *urc) override;
+
+ LRESULT OnFindItem(UINT, WPARAM, LPARAM);
+ LRESULT OnCommand(UINT, WPARAM, LPARAM);
+
+ void onChange_Splitter(CSplitter*);
+
+ void onItemExpand_Modules(CCtrlTreeView::TEventInfo *ev);
+ void onSelChanged_Modules(CCtrlTreeView::TEventInfo *ev);
+ void onBeginLabelEdit_Modules(CCtrlTreeView::TEventInfo *ev);
+ void onEndLabelEdit_Modules(CCtrlTreeView::TEventInfo *ev);
+ void onContextMenu_Modules(CContextMenuPos *pos);
+
+ void onClick_Settings(CCtrlListView::TEventInfo *ev);
+ void onDblClick_Settings(CCtrlListView::TEventInfo *ev);
+ void onColumnClick_Settings(CCtrlListView::TEventInfo *ev);
+ void onContextMenu_Settings(CContextMenuPos *pos);
+};
// deletemodules
int deleteModule(MCONTACT hContact, const char *module, int confirm);