summaryrefslogtreecommitdiff
path: root/plugins/DbEditorPP
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-17 22:06:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-17 22:06:06 +0300
commit95fcc842ba6df1606e75d2aef29502181d2f5ab7 (patch)
treed56effaf25cc805b1081a3410c3692bee4d8daba /plugins/DbEditorPP
parentcabb63de79c7bf2b46ac97193eb69340fee2bd63 (diff)
last global structure removed from dbeditor
Diffstat (limited to 'plugins/DbEditorPP')
-rw-r--r--plugins/DbEditorPP/src/main_window.cpp64
-rw-r--r--plugins/DbEditorPP/src/settinglist.cpp183
-rw-r--r--plugins/DbEditorPP/src/stdafx.h27
3 files changed, 149 insertions, 125 deletions
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp
index 46c66b6afe..04bb232ad7 100644
--- a/plugins/DbEditorPP/src/main_window.cpp
+++ b/plugins/DbEditorPP/src/main_window.cpp
@@ -12,8 +12,6 @@ CMainDlg *g_pMainWindow = nullptr;
extern volatile BOOL populating, skipEnter;
extern volatile int Select;
-extern SettingListInfo info;
-
void EditFinish(int selected);
void EditLabel(int item, int subitem);
@@ -88,6 +86,15 @@ static LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wPara
static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ if (g_pMainWindow)
+ if (g_pMainWindow->ListWndProc(msg, wParam))
+ return 0;
+
+ return mir_callNextSubclass(hwnd, SettingListSubclassProc, msg, wParam, lParam);
+}
+
+bool CMainDlg::ListWndProc(UINT msg, WPARAM wParam)
+{
switch (msg) {
case WM_CHAR:
if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6)
@@ -96,25 +103,26 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd, UINT msg, WPARAM wPar
case WM_KEYDOWN:
if (wParam == VK_F5)
- g_pMainWindow->PopulateSettings(info.hContact, info.module);
+ g_pMainWindow->PopulateSettings(m_hContact, m_module);
else if (wParam == VK_F3)
newFindWindow();
- else if (wParam == VK_DELETE || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) {
+ else if (wParam == VK_DELETE || (wParam == VK_F2 && m_settings.GetSelectedCount() == 1)) {
char setting[FLD_SIZE];
- int idx = ListView_GetSelectionMark(hwnd);
- if (idx == -1) return 0;
- ListView_GetItemTextA(hwnd, idx, 0, setting, _countof(setting));
+ int idx = m_settings.GetSelectionMark();
+ if (idx == -1)
+ return true;
+ ListView_GetItemTextA(m_settings.GetHwnd(), idx, 0, setting, _countof(setting));
if (wParam == VK_F2)
- g_pMainWindow->editSetting(info.hContact, info.module, setting);
+ g_pMainWindow->editSetting(m_hContact, m_module, setting);
else if (wParam == VK_DELETE)
- g_pMainWindow->DeleteSettingsFromList(info.hContact, info.module, setting);
+ g_pMainWindow->DeleteSettingsFromList(m_hContact, m_module, setting);
- return 0;
+ return true;
}
break;
}
- return mir_callNextSubclass(hwnd, SettingListSubclassProc, msg, wParam, lParam);
+ return false;
}
static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -145,7 +153,7 @@ CMainDlg::CMainDlg() :
m_modules(this, IDC_MODULES),
m_settings(this, IDC_SETTINGS),
m_splitter(this, IDC_SPLITTER),
- splitterPos(g_plugin.getWord("Splitter", 200))
+ m_splitterPos(g_plugin.getWord("Splitter", 200))
{
SetMinSize(450, 300);
@@ -316,7 +324,7 @@ int CMainDlg::Resizer(UTILRESIZECONTROL *urc)
{
switch (urc->wId) {
case IDC_MODULES:
- urc->rcItem.right = splitterPos - 3;
+ urc->rcItem.right = m_splitterPos - 3;
urc->rcItem.top = 0;
urc->rcItem.left = 0;
urc->rcItem.bottom = urc->dlgNewSize.cy;
@@ -325,14 +333,14 @@ int CMainDlg::Resizer(UTILRESIZECONTROL *urc)
case IDC_SPLITTER:
urc->rcItem.top = 0;
urc->rcItem.bottom = urc->dlgNewSize.cy;
- urc->rcItem.right = splitterPos;
- urc->rcItem.left = splitterPos - 3;
+ urc->rcItem.right = m_splitterPos;
+ urc->rcItem.left = m_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.left = m_splitterPos;
urc->rcItem.right = urc->dlgNewSize.cx;
return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM;
@@ -356,13 +364,13 @@ void CMainDlg::onChange_Splitter(CSplitter *)
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);
+ m_splitterPos = rc.left + pt.x + 1;
+ if (m_splitterPos < 150)
+ m_splitterPos = 150;
+ if (m_splitterPos > rc2.right - rc2.left - 150)
+ m_splitterPos = rc2.right - rc2.left - 150;
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SPLITTER), GWLP_USERDATA, m_splitterPos);
+ g_plugin.setWord("Splitter", (WORD)m_splitterPos);
PostMessage(m_hwnd, WM_SIZE, 0, 0);
}
@@ -633,7 +641,7 @@ 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)
+ if (g_Inline && hti.iSubItem <= 1 && hti.flags != LVHT_ONITEMICON && m_selectedItem == hti.iItem)
EditLabel(hti.iItem, hti.iSubItem);
else
EditFinish(hti.iItem);
@@ -648,7 +656,7 @@ void CMainDlg::onDblClick_Settings(CCtrlListView::TEventInfo *ev)
if (m_settings.SubItemHitTest(&hti) == -1)
return;
- if (!info.module[0]) { // contact
+ if (!m_module[0]) { // contact
LVITEM lvi = {};
lvi.mask = LVIF_PARAM;
lvi.iItem = hti.iItem;
@@ -661,7 +669,7 @@ void CMainDlg::onDblClick_Settings(CCtrlListView::TEventInfo *ev)
char setting[FLD_SIZE];
EditFinish(hti.iItem);
if (ListView_GetItemTextA(m_settings.GetHwnd(), hti.iItem, 0, setting, _countof(setting)))
- editSetting(info.hContact, info.module, setting);
+ editSetting(m_hContact, m_module, setting);
}
else EditLabel(hti.iItem, hti.iSubItem);
}
@@ -671,7 +679,7 @@ void CMainDlg::onColumnClick_Settings(CCtrlListView::TEventInfo *ev)
ColumnsSortParams params = {};
params.hList = m_settings.GetHwnd();
params.column = ev->nmlv->iSubItem;
- params.last = lastColumn;
+ params.last = m_lastColumn;
m_settings.SortItemsEx(ColumnsCompare, (LPARAM)&params);
- lastColumn = (params.column == lastColumn) ? -1 : params.column;
+ m_lastColumn = (params.column == m_lastColumn) ? -1 : params.column;
}
diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp
index 0df1490230..fde94ed280 100644
--- a/plugins/DbEditorPP/src/settinglist.cpp
+++ b/plugins/DbEditorPP/src/settinglist.cpp
@@ -1,12 +1,11 @@
#include "stdafx.h"
-SettingListInfo info = {};
-
int convertSetting(MCONTACT hContact, const char *module, const char *setting, int toType)
{
DBVARIANT dbv = {};
- if (db_get_s(hContact, module, setting, &dbv, 0)) return 0;
+ if (db_get_s(hContact, module, setting, &dbv, 0))
+ return 0;
if (dbv.type == toType) {
db_free(&dbv);
@@ -69,21 +68,21 @@ int convertSetting(MCONTACT hContact, const char *module, const char *setting, i
return res;
}
-void EditFinish(int selected)
+void CMainDlg::EditFinish(int selected)
{
- if (info.hwnd2Edit) {
- SendMessage(info.hwnd2Edit, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
- info.hwnd2Edit = nullptr;
+ if (m_hwnd2Edit) {
+ SendMessage(m_hwnd2Edit, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
+ m_hwnd2Edit = nullptr;
}
- info.selectedItem = selected;
+ m_selectedItem = selected;
}
void CMainDlg::ClearListView()
{
EditFinish(0);
- info.module[0] = 0;
- info.setting[0] = 0;
- info.hContact = 0;
+ m_module[0] = 0;
+ m_setting[0] = 0;
+ m_hContact = 0;
m_settings.DeleteAllItems();
}
@@ -182,7 +181,7 @@ void CMainDlg::updateListItem(int index, const char *setting, DBVARIANT *dbv, in
m_settings.SetItemText(index, 4, resident ? L"[R]" : L"");
- if (g_db && g_db->IsSettingEncrypted(info.module, setting)) {
+ if (g_db && g_db->IsSettingEncrypted(m_module, setting)) {
lvi.iImage = IMAGE_UNICODE;
m_settings.SetItem(&lvi);
m_settings.SetItemText(index, 0, _A2T(setting));
@@ -306,7 +305,7 @@ void CMainDlg::addListHandle(MCONTACT hContact)
void CMainDlg::addListItem(const char *setting, int resident)
{
DBVARIANT dbv;
- if (!db_get_s(info.hContact, info.module, setting, &dbv, 0)) {
+ if (!db_get_s(m_hContact, m_module, setting, &dbv, 0)) {
LVITEMA lvi = {};
lvi.mask = LVIF_TEXT;
lvi.pszText = (char *)setting;
@@ -332,11 +331,11 @@ void CMainDlg::PopulateSettings(MCONTACT hContact, const char *module)
// clear any settings that may be there...
ClearListView();
- info.hContact = hContact;
- mir_strncpy(info.module, tmp, _countof(info.module));
+ m_hContact = hContact;
+ mir_strncpy(m_module, tmp, _countof(m_module));
ModuleSettingLL setlist;
- if (IsModuleEmpty(info.hContact, info.module) || !EnumSettings(info.hContact, info.module, &setlist))
+ if (IsModuleEmpty(m_hContact, m_module) || !EnumSettings(m_hContact, m_module, &setlist))
return;
for (ModSetLinkLinkItem *setting = setlist.first; setting; setting = setting->next)
@@ -389,7 +388,7 @@ void CMainDlg::onSettingChanged(MCONTACT hContact, DBCONTACTWRITESETTING *cws)
}
// settings list
- if (hContact != info.hContact || mir_strcmp(info.module, cws->szModule))
+ if (hContact != m_hContact || mir_strcmp(m_module, cws->szModule))
return;
if (cws->value.type != DBVT_DELETED) {
@@ -402,26 +401,41 @@ void CMainDlg::onSettingChanged(MCONTACT hContact, DBCONTACTWRITESETTING *cws)
else deleteListItem(cws->szSetting);
}
-static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (g_pMainWindow)
+ if (g_pMainWindow->EditLabelWndProc(hwnd, uMsg, wParam))
+ return 0;
+
+ if (uMsg == WM_GETDLGCODE)
+ return DLGC_WANTALLKEYS;
+
+ return mir_callNextSubclass(hwnd, SettingLabelEditSubClassProc, uMsg, wParam, lParam);
+}
+
+bool CMainDlg::EditLabelWndProc(HWND hwnd, UINT uMsg, WPARAM wParam)
{
- switch (msg) {
+ switch (uMsg) {
case WM_KEYDOWN:
switch (wParam) {
case VK_RETURN:
if (GetKeyState(VK_CONTROL) & 0x8000) // ctrl is pressed
break;
SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
- return 0;
+ return true;
+
case VK_ESCAPE:
SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
- return 0;
+ return true;
}
break;
case WM_USER:
SetFocus(hwnd);
SendMessage(hwnd, WM_SETFONT, SendMessage(GetParent(hwnd), WM_GETFONT, 0, 0), 1);
- if (info.subitem)
+ if (m_subitem)
SendMessage(hwnd, EM_LIMITTEXT, (WPARAM)65535, 0);
else
SendMessage(hwnd, EM_LIMITTEXT, (WPARAM)255, 0);
@@ -438,9 +452,9 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
DBVARIANT dbv = {};
int len = GetWindowTextLength(hwnd) + 1;
- if ((!info.subitem && len <= 1) || db_get_s(info.hContact, info.module, info.setting, &dbv, 0)) {
+ if ((!m_subitem && len <= 1) || db_get_s(m_hContact, m_module, m_setting, &dbv, 0)) {
SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
- return 0;
+ return true;
}
wchar_t *value = (wchar_t *)mir_alloc(len * sizeof(wchar_t));
@@ -451,19 +465,19 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
int res = 0;
- switch (info.subitem) {
+ switch (m_subitem) {
case 0: // setting name
- if (!mir_strcmp(info.setting, szValue) || mir_strlen(szValue) > 0xFE) {
+ if (!mir_strcmp(m_setting, szValue) || mir_strlen(szValue) > 0xFE) {
db_free(&dbv);
mir_free(value);
SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
- return 0;
+ return true;
}
- if (db_set(info.hContact, info.module, szValue, &dbv))
+ if (db_set(m_hContact, m_module, szValue, &dbv))
break;
res = 1;
- db_unset(info.hContact, info.module, info.setting);
- g_pMainWindow->deleteListItem(info.setting);
+ db_unset(m_hContact, m_module, m_setting);
+ g_pMainWindow->deleteListItem(m_setting);
break;
case 1: // value
@@ -471,7 +485,7 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
int i = 0;
if (dbv.type == DBVT_BLOB) {
- res = WriteBlobFromString(info.hContact, info.module, info.setting, szValue, (int)mir_strlen(szValue));
+ res = WriteBlobFromString(m_hContact, m_module, m_setting, szValue, (int)mir_strlen(szValue));
break;
}
@@ -480,26 +494,26 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
case 'B':
val = wcstoul(&value[1], nullptr, 0);
if (!val || value[1] == '0') {
- res = !db_set_b(info.hContact, info.module, info.setting, (BYTE)val);
+ res = !db_set_b(m_hContact, m_module, m_setting, (BYTE)val);
}
else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ res = setTextValue(m_hContact, m_module, m_setting, value, dbv.type);
break;
case 'w':
case 'W':
val = wcstoul(&value[1], nullptr, 0);
if (!val || value[1] == '0')
- res = !db_set_w(info.hContact, info.module, info.setting, (WORD)val);
+ res = !db_set_w(m_hContact, m_module, m_setting, (WORD)val);
else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ res = setTextValue(m_hContact, m_module, m_setting, value, dbv.type);
break;
case 'd':
case 'D':
val = wcstoul(&value[1], nullptr, 0);
if (!val || value[1] == '0')
- res = !db_set_dw(info.hContact, info.module, info.setting, val);
+ res = !db_set_dw(m_hContact, m_module, m_setting, val);
else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ res = setTextValue(m_hContact, m_module, m_setting, value, dbv.type);
break;
case '0':
@@ -527,12 +541,12 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
case DBVT_BYTE:
case DBVT_WORD:
case DBVT_DWORD:
- res = setNumericValue(info.hContact, info.module, info.setting, val, dbv.type);
+ res = setNumericValue(m_hContact, m_module, m_setting, val, dbv.type);
break;
case DBVT_ASCIIZ:
case DBVT_WCHAR:
case DBVT_UTF8:
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ res = setTextValue(m_hContact, m_module, m_setting, value, dbv.type);
break;
}
break;
@@ -547,12 +561,12 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
sh = 1;
}
}
- res = setTextValue(info.hContact, info.module, info.setting, &value[sh], dbv.type);
+ res = setTextValue(m_hContact, m_module, m_setting, &value[sh], dbv.type);
}
break;
default:
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ res = setTextValue(m_hContact, m_module, m_setting, value, dbv.type);
break;
}
break;
@@ -562,7 +576,7 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
db_free(&dbv);
if (!res) {
- g_pMainWindow->msg(TranslateT("Unable to store value in this data type!"));
+ msg(TranslateT("Unable to store value in this data type!"));
break;
}
}
@@ -570,24 +584,25 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM
case IDCANCEL:
DestroyWindow(hwnd);
- return 0;
+ return true;
}
-
- case WM_GETDLGCODE:
- return DLGC_WANTALLKEYS;
+ break;
case WM_DESTROY:
- info.hwnd2Edit = nullptr;
+ m_hwnd2Edit = nullptr;
break;
}
- return mir_callNextSubclass(hwnd, SettingLabelEditSubClassProc, msg, wParam, lParam);
+
+ return false;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CMainDlg::EditLabel(int item, int subitem)
{
- if (info.hwnd2Edit) {
- SendMessage(info.hwnd2Edit, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0); // ignore the new value of the last edit
- info.hwnd2Edit = nullptr;
+ if (m_hwnd2Edit) {
+ SendMessage(m_hwnd2Edit, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0); // ignore the new value of the last edit
+ m_hwnd2Edit = nullptr;
}
char setting[FLD_SIZE];
@@ -599,14 +614,14 @@ void CMainDlg::EditLabel(int item, int subitem)
return;
DBVARIANT dbv;
- if (db_get_s(info.hContact, info.module, setting, &dbv, 0))
+ if (db_get_s(m_hContact, m_module, setting, &dbv, 0))
return;
- mir_strcpy(info.setting, setting);
- info.subitem = subitem;
+ mir_strcpy(m_setting, setting);
+ m_subitem = subitem;
if (!subitem)
- info.hwnd2Edit = CreateWindowW(L"EDIT", _A2T(setting), WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), m_settings.GetHwnd(), nullptr, g_plugin.getInst(), nullptr);
+ m_hwnd2Edit = CreateWindowW(L"EDIT", _A2T(setting), WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), m_settings.GetHwnd(), nullptr, g_plugin.getInst(), nullptr);
else {
wchar_t *str = nullptr, value[16] = {};
@@ -640,17 +655,17 @@ void CMainDlg::EditLabel(int item, int subitem)
GetClientRect(m_settings.GetHwnd(), &rclist);
if (rc.top + height > rclist.bottom &&rclist.bottom - rclist.top > height)
rc.top = rc.bottom - height;
- info.hwnd2Edit = CreateWindow(L"EDIT", str, WS_BORDER | WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL, rc.left, rc.top, rc.right - rc.left, height, m_settings.GetHwnd(), nullptr, g_plugin.getInst(), nullptr);
+ m_hwnd2Edit = CreateWindow(L"EDIT", str, WS_BORDER | WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL, rc.left, rc.top, rc.right - rc.left, height, m_settings.GetHwnd(), nullptr, g_plugin.getInst(), nullptr);
mir_free(str);
}
else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD)
- info.hwnd2Edit = CreateWindow(L"EDIT", value, WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), m_settings.GetHwnd(), nullptr, g_plugin.getInst(), nullptr);
+ m_hwnd2Edit = CreateWindow(L"EDIT", value, WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), m_settings.GetHwnd(), nullptr, g_plugin.getInst(), nullptr);
}
db_free(&dbv);
- mir_subclassWindow(info.hwnd2Edit, SettingLabelEditSubClassProc);
- SendMessage(info.hwnd2Edit, WM_USER, 0, 0);
+ mir_subclassWindow(m_hwnd2Edit, SettingLabelEditSubClassProc);
+ SendMessage(m_hwnd2Edit, WM_USER, 0, 0);
}
// hwnd here is to the main window, NOT the listview
@@ -662,38 +677,38 @@ void CMainDlg::onContextMenu_Settings(CContextMenuPos *pos)
HMENU hSubMenu = GetSubMenu(hMenu, 6);
TranslateMenu(hSubMenu);
- if (!info.module[0]) {
+ if (!m_module[0]) {
RemoveMenu(hSubMenu, 0, MF_BYPOSITION); // new
RemoveMenu(hSubMenu, 0, MF_BYPOSITION); // separator
}
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);
+ newSetting(m_hContact, m_module, DBVT_BYTE);
break;
case MENU_ADD_WORD:
- newSetting(info.hContact, info.module, DBVT_WORD);
+ newSetting(m_hContact, m_module, DBVT_WORD);
break;
case MENU_ADD_DWORD:
- newSetting(info.hContact, info.module, DBVT_DWORD);
+ newSetting(m_hContact, m_module, DBVT_DWORD);
break;
case MENU_ADD_STRING:
- newSetting(info.hContact, info.module, DBVT_ASCIIZ);
+ newSetting(m_hContact, m_module, DBVT_ASCIIZ);
break;
case MENU_ADD_UNICODE:
- newSetting(info.hContact, info.module, DBVT_WCHAR);
+ newSetting(m_hContact, m_module, DBVT_WCHAR);
break;
case MENU_ADD_BLOB:
- newSetting(info.hContact, info.module, DBVT_BLOB);
+ newSetting(m_hContact, m_module, DBVT_BLOB);
break;
case MENU_REFRESH:
- PopulateSettings(info.hContact, info.module);
+ PopulateSettings(m_hContact, m_module);
break;
}
return;
@@ -763,77 +778,77 @@ void CMainDlg::onContextMenu_Settings(CContextMenuPos *pos)
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);
+ int watchIdx = WatchedArrayIndex(m_hContact, m_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, m_hwnd, nullptr)) {
case MENU_EDIT_SET:
- editSetting(info.hContact, info.module, setting);
+ editSetting(m_hContact, m_module, setting);
break;
case MENU_COPY_SET:
- copySetting(info.hContact, info.module, setting);
+ copySetting(m_hContact, m_module, setting);
break;
case MENU_ADD_BYTE:
- newSetting(info.hContact, info.module, DBVT_BYTE);
+ newSetting(m_hContact, m_module, DBVT_BYTE);
return;
case MENU_ADD_WORD:
- newSetting(info.hContact, info.module, DBVT_WORD);
+ newSetting(m_hContact, m_module, DBVT_WORD);
return;
case MENU_ADD_DWORD:
- newSetting(info.hContact, info.module, DBVT_DWORD);
+ newSetting(m_hContact, m_module, DBVT_DWORD);
return;
case MENU_ADD_STRING:
- newSetting(info.hContact, info.module, DBVT_ASCIIZ);
+ newSetting(m_hContact, m_module, DBVT_ASCIIZ);
return;
case MENU_ADD_UNICODE:
- newSetting(info.hContact, info.module, DBVT_WCHAR);
+ newSetting(m_hContact, m_module, DBVT_WCHAR);
return;
case MENU_ADD_BLOB:
- newSetting(info.hContact, info.module, DBVT_BLOB);
+ newSetting(m_hContact, m_module, DBVT_BLOB);
return;
case MENU_CHANGE2BYTE:
- convertSetting(info.hContact, info.module, setting, DBVT_BYTE);
+ convertSetting(m_hContact, m_module, setting, DBVT_BYTE);
break;
case MENU_CHANGE2WORD:
- convertSetting(info.hContact, info.module, setting, DBVT_WORD);
+ convertSetting(m_hContact, m_module, setting, DBVT_WORD);
break;
case MENU_CHANGE2DWORD:
- convertSetting(info.hContact, info.module, setting, DBVT_DWORD);
+ convertSetting(m_hContact, m_module, setting, DBVT_DWORD);
break;
case MENU_CHANGE2STRING:
- convertSetting(info.hContact, info.module, setting, DBVT_ASCIIZ);
+ convertSetting(m_hContact, m_module, setting, DBVT_ASCIIZ);
break;
case MENU_CHANGE2UNICODE:
- convertSetting(info.hContact, info.module, setting, DBVT_UTF8);
+ convertSetting(m_hContact, m_module, setting, DBVT_UTF8);
break;
case MENU_WATCH_ITEM:
if (watchIdx < 0)
- addSettingToWatchList(info.hContact, info.module, setting);
+ addSettingToWatchList(m_hContact, m_module, setting);
else
freeWatchListItem(watchIdx);
PopulateWatchedWindow();
break;
case MENU_DELETE_SET:
- DeleteSettingsFromList(info.hContact, info.module, setting);
+ DeleteSettingsFromList(m_hContact, m_module, setting);
break;
case MENU_REFRESH:
- PopulateSettings(info.hContact, info.module);
+ PopulateSettings(m_hContact, m_module);
break;
}
}
diff --git a/plugins/DbEditorPP/src/stdafx.h b/plugins/DbEditorPP/src/stdafx.h
index a592524a26..6a41564f88 100644
--- a/plugins/DbEditorPP/src/stdafx.h
+++ b/plugins/DbEditorPP/src/stdafx.h
@@ -80,17 +80,6 @@ struct ModuleTreeInfoStruct
MCONTACT hContact;
};
-struct SettingListInfo
-{
- MCONTACT hContact;
- int selectedItem; // item that is currently selected
- char module[FLD_SIZE];
- // for edit
- HWND hwnd2Edit;
- char setting[FLD_SIZE];
- int subitem;
-};
-
struct DBsetting
{
MCONTACT hContact;
@@ -205,8 +194,17 @@ int CALLBACK ColumnsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam);
class CMainDlg : public CDlgBase
{
- int splitterPos;
- int lastColumn = -1;
+ int m_splitterPos;
+ int m_lastColumn = -1;
+
+ MCONTACT m_hContact = 0;
+ int m_selectedItem = -1; // item that is currently selected
+ char m_module[FLD_SIZE];
+
+ // for edit
+ HWND m_hwnd2Edit = nullptr;
+ char m_setting[FLD_SIZE];
+ int m_subitem = 0;
CSplitter m_splitter;
CCtrlTreeView m_modules;
@@ -271,7 +269,10 @@ public:
void ClearListView();
void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *setting);
+ void EditFinish(int selected);
void EditLabel(int item, int subitem);
+ bool EditLabelWndProc(HWND hwnd, UINT, WPARAM);
+ bool ListWndProc(UINT, WPARAM wParam);
void PopulateSettings(MCONTACT hContact, const char *module);
void SelectSetting(const char *setting);