diff options
Diffstat (limited to 'plugins/DbEditorPP/src/main_window.cpp')
-rw-r--r-- | plugins/DbEditorPP/src/main_window.cpp | 376 |
1 files changed, 165 insertions, 211 deletions
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 7c74985b66..ea5f75dc60 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -1,13 +1,20 @@ #include "headers.h"
HWND hwnd2mainWindow;
-int Order;
-HIMAGELIST himl2;
-int Hex;
-#define GC_SPLITTERMOVED (WM_USER+101)
+static HIMAGELIST hImg = 0;
+
+int g_Hex;
+int g_Mode;
+int g_Order;
+int g_Inline;
+
+extern SettingListInfo info;
+extern struct ColumnsSettings csSettingList[];
+extern HWND hwnd2List;
+extern HWND hwnd2Tree;
-extern BOOL bServiceMode;
+#define GC_SPLITTERMOVED (WM_USER+101)
void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void SettingsListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -99,36 +106,36 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case WM_CHAR:
if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6)
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc);
+ newFindWindow();
break;
case WM_KEYUP:
if (wParam == VK_DELETE || wParam == VK_F2 || wParam == VK_F5 || wParam == VK_F3) {
TVITEM tvi;
- char module[256];
+ TCHAR text[FLD_SIZE];
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
tvi.hItem = TreeView_GetSelection(hwnd);
- tvi.pszText = module;
- tvi.cchTextMax = SIZEOF(module);
+ tvi.pszText = text;
+ tvi.cchTextMax = SIZEOF(text);
if (TreeView_GetItem(hwnd, &tvi) && tvi.lParam) {
ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
MCONTACT hContact = mtis->hContact;
if (wParam == VK_DELETE) {
if ((mtis->type) & MODULE) {
- if (deleteModule(module, hContact, 0)) {
+ if (deleteModule(hContact,_T2A(text), 1)) {
mir_free(mtis);
TreeView_DeleteItem(hwnd, tvi.hItem);
}
}
else if ((mtis->type == CONTACT) && hContact) {
if (db_get_b(NULL, "CList", "ConfirmDelete", 1)) {
- char msg[1024];
- mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module);
- if (MessageBox(0, msg, Translate("Confirm contact delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
+ TCHAR str[MSG_SIZE];
+ mir_sntprintf(text, TranslateT("Are you sure you want to delete contact \"%s\"?"), text);
+ if (dlg(str, MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
break;
}
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
- freeTree(hwnd, mtis->hContact);
+ freeTree(mtis->hContact);
TreeView_DeleteItem(hwnd, tvi.hItem);
}
}
@@ -139,7 +146,7 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break;
}
else if (wParam == VK_F3) {
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc);
+ newFindWindow();
break;
}
}
@@ -154,34 +161,31 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd, UINT msg, WPARAM wPar switch (msg) {
case WM_CHAR:
if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6)
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc);
+ newFindWindow();
break;
case WM_KEYDOWN:
- if (wParam == VK_DELETE || wParam == VK_F5 || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) {
- char *module, setting[256];
- MCONTACT hContact;
- SettingListInfo* sli = (SettingListInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (!sli)
- break;
- hContact = sli->hContact;
- module = sli->module;
- ListView_GetItemText(hwnd, ListView_GetSelectionMark(hwnd), 0, setting, SIZEOF(setting));
+
+ if (wParam == VK_F5) {
+ PopulateSettings(info.hContact, info.module);
+ }
+ else if (wParam == VK_F3)
+ newFindWindow();
+ else
+ if (wParam == VK_DELETE || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) {
+
+ char setting[FLD_SIZE];
+ int idx = ListView_GetSelectionMark(hwnd);
+ if (idx == -1 ) return 0;
+ ListView_GetItemTextA(hwnd, idx, 0, setting, SIZEOF(setting));
if (wParam == VK_F2)
- editSetting(hContact, module, setting);
- else if (wParam == VK_F5) {
- char *szModule = mir_tstrdup(module); // need to do this, otheriwse the setlist stays empty
- PopulateSettings(hwnd, hContact, szModule);
- mir_free(szModule);
- }
+ editSetting(info.hContact, info.module, setting);
else if (wParam == VK_DELETE)
- DeleteSettingsFromList(hwnd, hContact, module, setting);
+ DeleteSettingsFromList(info.hContact, info.module, setting);
return 0;
}
- else if (wParam == VK_F3)
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc);
break;
}
return mir_callNextSubclass(hwnd, SettingListSubclassProc, msg, wParam, lParam);
@@ -194,102 +198,57 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) TranslateDialogDefault(hwnd);
{
hwnd2mainWindow = hwnd;
+ hwnd2Tree = GetDlgItem(hwnd, IDC_MODULES);
+ hwnd2List = GetDlgItem(hwnd, IDC_SETTINGS);
+
+ LoadResidentSettings();
+
+ // image list
+ hImg = LoadIcons();
+
// do the icon
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)));
SetWindowText(hwnd, TranslateT("Database Editor++"));
// setup the splitter
- SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, (LONG_PTR)db_get_w(NULL, modname, "Splitter", 300));
+ SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, (LONG_PTR)db_get_w(NULL, modname, "Splitter", 200));
SendMessage(hwnd, GC_SPLITTERMOVED, 0, 0);
mir_subclassWindow(GetDlgItem(hwnd, IDC_SPLITTER), SplitterSubclassProc);
+
// module tree
- TreeView_SetUnicodeFormat(GetDlgItem(hwnd, IDC_MODULES), TRUE);
- mir_subclassWindow(GetDlgItem(hwnd, IDC_MODULES), ModuleTreeSubclassProc);
+ mir_subclassWindow(hwnd2Tree, ModuleTreeSubclassProc);
+ TreeView_SetImageList(hwnd2Tree, hImg, TVSIL_NORMAL);
+
//setting list
- setupSettingsList(GetDlgItem(hwnd, IDC_SETTINGS));
- mir_subclassWindow(GetDlgItem(hwnd, IDC_SETTINGS), SettingListSubclassProc);
+ mir_subclassWindow(hwnd2List, SettingListSubclassProc);
+ ListView_SetExtendedListViewStyle(hwnd2List, 32 | LVS_EX_SUBITEMIMAGES | LVS_EX_LABELTIP ); //LVS_EX_GRIDLINES
+ loadListSettings(hwnd2List, csSettingList);
+ ListView_SetImageList(hwnd2List, hImg, LVSIL_SMALL);
HMENU hMenu = GetMenu(hwnd);
TranslateMenu(hMenu);
for (int i = 0; i < 6; i++)
TranslateMenu(GetSubMenu(hMenu, i));
- // move the dialog to the users position
- MoveWindow(hwnd, db_get_dw(NULL, modname, "x", 0), db_get_dw(NULL, modname, "y", 0), db_get_dw(NULL, modname, "width", 500), db_get_dw(NULL, modname, "height", 250), 0);
- if (db_get_b(NULL, modname, "Maximised", 0)) {
- WINDOWPLACEMENT wp;
- wp.length = sizeof(WINDOWPLACEMENT);
- wp.flags = WPF_RESTORETOMAXIMIZED;
- wp.showCmd = SW_SHOWMAXIMIZED;
+ Utils_RestoreWindowPosition(hwnd, NULL, modname, "Main_");
+ if (db_get_b(NULL, modname, "Maximized", 0))
+ ShowWindow(hwnd,SW_SHOWMAXIMIZED);
- SetWindowPlacement(hwnd, &wp);
- }
- SetCursor(LoadCursor(NULL, IDC_ARROW));
+ g_Inline = !db_get_b(NULL, modname, "DontAllowInLineEdit", 1);
+ CheckMenuItem(GetSubMenu(hMenu, 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED: MF_UNCHECKED));
- Mode = MODE_ALL;
+ g_Mode = MODE_ALL;
CheckMenuItem(GetSubMenu(hMenu, 5), MENU_FILTER_ALL, MF_BYCOMMAND | MF_CHECKED);
- Hex = db_get_b(NULL, modname, "HexMode", 0);
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((Hex & HEX_BYTE) ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_WORD_HEX, MF_BYCOMMAND | ((Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(GetSubMenu(hMenu, 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
+ g_Hex = db_get_b(NULL, modname, "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));
CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (db_get_b(NULL, modname, "RestoreOnOpen", 1) ? MF_CHECKED : MF_UNCHECKED));
- Order = db_get_b(NULL, modname, "SortMode", 1);
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (Order ? MF_CHECKED : MF_UNCHECKED));
-
- // image list
- int numberOfIcons = 0;
- himl = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 10, 0);
- if (himl != NULL) {
- if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_SETTINGS)))
- numberOfIcons++;
- if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_KNOWN)))
- numberOfIcons++;
- if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_KNOWNOPEN)))
- numberOfIcons++;
- if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_CONTACTS)))
- numberOfIcons++;
- if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_OFFLINE)))
- numberOfIcons++;
- if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_ONLINE)))
- numberOfIcons++;
-
- if (numberOfIcons < DEF_ICON + 1) {
- if (numberOfIcons)
- ImageList_Destroy(himl);
- himl = NULL;
- }
-
- AddProtoIconsToList(himl, numberOfIcons);
-
- himl2 = NULL;
- numberOfIcons = 0;
-
- if (himl2 = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 0)) {
- if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_BINARY)))
- numberOfIcons++;
- if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_BYTE)))
- numberOfIcons++;
- if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_WORD)))
- numberOfIcons++;
- if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_DWORD)))
- numberOfIcons++;
- if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_STRING)))
- numberOfIcons++;
- if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_UNICODE)))
- numberOfIcons++;
- if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_HANDLE)))
- numberOfIcons++;
-
- if (numberOfIcons < 7) {
- if (numberOfIcons)
- ImageList_Destroy(himl2);
- himl2 = NULL;
- }
- }
- }
+ g_Order = db_get_b(NULL, modname, "SortMode", 1);
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED));
int restore;
if (hRestore)
@@ -317,10 +276,10 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ScreenToClient(hwnd, &pt);
splitterPos = rc.left + pt.x + 1;
- if (splitterPos < 65)
- splitterPos = 65;
- if (splitterPos > rc2.right - rc2.left - 65)
- splitterPos = rc2.right - rc2.left - 65;
+ if (splitterPos < 150)
+ splitterPos = 150;
+ if (splitterPos > rc2.right - rc2.left - 150)
+ splitterPos = rc2.right - rc2.left - 150;
SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
db_set_w(NULL, modname, "Splitter", (WORD)splitterPos);
}
@@ -332,12 +291,8 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
MINMAXINFO *mmi = (MINMAXINFO *)lParam;
int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
-
- if (splitterPos + 40 > 200)
- mmi->ptMinTrackSize.x = splitterPos + 65;
- else
- mmi->ptMinTrackSize.x = 200;
- mmi->ptMinTrackSize.y = 150;
+ mmi->ptMinTrackSize.x = splitterPos + 150;
+ mmi->ptMinTrackSize.y = 300;
}
return 0;
@@ -351,29 +306,23 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) urd.hInstance = hInst;
urd.hwndDlg = hwnd;
urd.lParam = (LPARAM)GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
- urd.lpTemplate = MAKEINTRESOURCE(IDD_MAIN);
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_MAIN);
urd.pfnResizer = DialogResize;
CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
-
- if (msg == WM_SIZE && wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED)
- db_set_b(NULL, modname, "Maximised", 1);
- else if (msg == WM_SIZE && wParam == SIZE_RESTORED)
- db_set_b(NULL, modname, "Maximised", 0);
}
break;
case WM_DESTROY: // free our shit!
if (db_get_b(NULL, modname, "RestoreOnOpen", 1)) {
HTREEITEM item;
- HWND hwnd2Tree = GetDlgItem(hwnd, IDC_MODULES);
- char module[256] = { 0 };
+
if (item = TreeView_GetSelection(hwnd2Tree)) {
int type = MODULE;
-
+ TCHAR text[FLD_SIZE];
TVITEM tvi = { 0 };
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
- tvi.pszText = module;
- tvi.cchTextMax = SIZEOF(module);
+ tvi.pszText = text;
+ tvi.cchTextMax = SIZEOF(text);
tvi.hItem = item;
if (TreeView_GetItem(hwnd2Tree, &tvi)) {
MCONTACT hContact = 0;
@@ -388,50 +337,58 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (type == CONTACT)
db_set_s(NULL, modname, "LastModule", "");
else
- db_set_s(NULL, modname, "LastModule", module);
+ db_set_s(NULL, modname, "LastModule", _T2A(text));
}
else {
db_unset(NULL, modname, "LastContact");
db_unset(NULL, modname, "LastModule");
}
- HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS);
- int pos = ListView_GetSelectionMark(hwnd2Settings);
+ int pos = ListView_GetSelectionMark(hwnd2List);
if (pos != -1) {
- char text[256];
- ListView_GetItemText(hwnd2Settings, pos, 0, text, SIZEOF(text));
- db_set_s(NULL, modname, "LastSetting", text);
+ char data[FLD_SIZE];
+ ListView_GetItemTextA(hwnd2List, pos, 0, data, SIZEOF(data));
+ db_set_s(NULL, modname, "LastSetting", data);
}
else
db_unset(NULL, modname, "LastSetting");
}
}
- db_set_b(NULL, modname, "HexMode", (byte)Hex);
- db_set_b(NULL, modname, "SortMode", (byte)Order);
- saveListSettings(GetDlgItem(hwnd, IDC_SETTINGS));
- hwnd2mainWindow = 0;
- ClearListview(GetDlgItem(hwnd, IDC_SETTINGS));
- freeTree(GetDlgItem(hwnd, IDC_MODULES), 0);
- if (himl)
- ImageList_Destroy(himl);
- if (himl2)
- ImageList_Destroy(himl2);
-
- if (!db_get_b(NULL, modname, "Maximised", 0)) {
- RECT rc;
- GetWindowRect(hwnd, &rc);
- db_set_dw(NULL, modname, "x", rc.left);
- db_set_dw(NULL, modname, "y", rc.top);
- db_set_dw(NULL, modname, "width", rc.right - rc.left);
- db_set_dw(NULL, modname, "height", rc.bottom - rc.top);
- }
- if (hwnd2importWindow) {
- DestroyWindow(hwnd2importWindow);
- hwnd2importWindow = 0;
- }
+ db_set_b(NULL, modname, "HexMode", (byte)g_Hex);
+ db_set_b(NULL, modname, "SortMode", (byte)g_Order);
+ db_set_b(NULL, modname, "DontAllowInLineEdit", (byte)!g_Inline);
+ {
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hwnd, &wp);
+ if (wp.flags == WPF_RESTORETOMAXIMIZED) {
+ db_set_b(NULL, modname, "Maximized", 1);
+ ShowWindow(hwnd, SW_SHOWNOACTIVATE);
+ } else
+ db_set_b(NULL, modname, "Maximized", 0);
+ Utils_SaveWindowPosition(hwnd, NULL, modname, "Main_");
+ ShowWindow(hwnd, SW_HIDE);
+ }
+
+ saveListSettings(hwnd2List, csSettingList);
+ ClearListView();
+
+ freeTree(0);
+
+ hwnd2mainWindow = NULL;
+ hwnd2Tree = NULL;
+ hwnd2List = NULL;
+
+ if (hImg) {
+ ImageList_Destroy(hImg);
+ hImg = NULL;
+ }
+
+ FreeResidentSettings();
+
if (bServiceMode)
PostQuitMessage(0);
return 0;
@@ -447,30 +404,23 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case MENU_REFRESH_SETS:
{
TVITEM tvi;
- ModuleTreeInfoStruct *mtis;
- char module[256];
+
+ TCHAR text[FLD_SIZE];
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
- tvi.hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_MODULES));
- tvi.pszText = module;
- tvi.cchTextMax = SIZEOF(module);
- if (!TreeView_GetItem(GetDlgItem(hwnd, IDC_MODULES), &tvi)) break;
- if (tvi.lParam) {
- mtis = (ModuleTreeInfoStruct *)tvi.lParam;
- if (mtis->type == MODULE)
- PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, module);
- else
- ClearListview(GetDlgItem(hwnd, IDC_SETTINGS));
- }
+ tvi.hItem = TreeView_GetSelection(hwnd2Tree);
+ tvi.pszText = text; // modulename
+ tvi.cchTextMax = SIZEOF(text);
+ if (!TreeView_GetItem(hwnd2Tree, &tvi)) break;
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
+ if (mtis && (mtis->type == MODULE))
+ PopulateSettings(mtis->hContact, _T2A(text));
else
- ClearListview(GetDlgItem(hwnd, IDC_SETTINGS));
+ ClearListView();
}
break;
///////////////////////// // watches
case MENU_VIEW_WATCHES:
- if (!hwnd2watchedVarsWindow) // so only opens 1 at a time
- hwnd2watchedVarsWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WATCH_DIAG), 0, WatchDlgProc);
- else
- SetForegroundWindow(hwnd2watchedVarsWindow);
+ openWatchedVarWindow();
break;
case MENU_REMALL_WATCHES:
freeAllWatches();
@@ -485,7 +435,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) exportDB(NULL, 0);
break;
case MENU_IMPORTFROMFILE:
- ImportSettingsFromFileMenuItem(NULL, "");
+ ImportSettingsFromFileMenuItem(NULL, NULL);
break;
case MENU_IMPORTFROMTEXT:
ImportSettingsMenuItem(NULL);
@@ -495,52 +445,60 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) DestroyWindow(hwnd);
break;
case MENU_DELETE:
- deleteModuleGui();
+ deleteModuleDlg();
break;
case MENU_FINDANDREPLACE:
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc);
+ newFindWindow();
+ break;
+ case MENU_FIX_RESIDENT:
+ if (dlg(TranslateT("Fix resident setting deleting them from DB ?"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) {
+ int cnt = fixResidentSettings();
+ TCHAR text[MSG_SIZE];
+ mir_sntprintf(text, TranslateT("Deleted orphaned items: %d"), cnt);
+ msg(text);
+ }
break;
case MENU_FILTER_ALL:
- if (Mode != MODE_ALL) {
+ if (g_Mode != MODE_ALL) {
HMENU hMenu = GetMenu(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);
- Mode = MODE_ALL;
+ g_Mode = MODE_ALL;
refreshTree(1);
}
break;
case MENU_FILTER_LOADED:
- if (Mode != MODE_LOADED) {
+ if (g_Mode != MODE_LOADED) {
HMENU hMenu = GetMenu(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);
- Mode = MODE_LOADED;
+ g_Mode = MODE_LOADED;
refreshTree(1);
}
break;
case MENU_FILTER_UNLOADED:
- if (Mode != MODE_UNLOADED) {
+ if (g_Mode != MODE_UNLOADED) {
HMENU hMenu = GetMenu(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);
- Mode = MODE_UNLOADED;
+ g_Mode = MODE_UNLOADED;
refreshTree(1);
}
break;
case MENU_BYTE_HEX:
- Hex ^= HEX_BYTE;
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((Hex & HEX_BYTE) ? MF_CHECKED : MF_UNCHECKED));
+ g_Hex ^= HEX_BYTE;
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((g_Hex & HEX_BYTE) ? MF_CHECKED : MF_UNCHECKED));
break;
case MENU_WORD_HEX:
- Hex ^= HEX_WORD;
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_WORD_HEX, MF_BYCOMMAND | ((Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED));
+ g_Hex ^= HEX_WORD;
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_WORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED));
break;
case MENU_DWORD_HEX:
- Hex ^= HEX_DWORD;
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
+ g_Hex ^= HEX_DWORD;
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
break;
case MENU_SAVE_POSITION:
{
@@ -549,9 +507,12 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) db_set_b(NULL, modname, "RestoreOnOpen", (byte)save);
}
break;
+ case MENU_INLINE_EDIT:
+ g_Inline = !g_Inline;
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED: MF_UNCHECKED));
case MENU_SORT_ORDER:
- Order = !Order;
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (Order ? MF_CHECKED : MF_UNCHECKED));
+ g_Order = !g_Order;
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED));
refreshTree(1);
break;
case MENU_OPEN_OPTIONS:
@@ -578,26 +539,19 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_FINDITEM:
ItemInfo *ii = (ItemInfo *)wParam;
- HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS);
- int hItem = findItemInTree(GetDlgItem(hwnd, IDC_MODULES), ii->hContact, ii->module);
- if (hItem != -1) {
- TreeView_SelectItem(GetDlgItem(hwnd, IDC_MODULES), (HTREEITEM)hItem);
- if (ii->type != FW_MODULE) {
- LVITEM lvItem;
- LVFINDINFO lvfi;
-
- lvfi.flags = LVFI_STRING;
- lvfi.psz = ii->setting;
- lvfi.vkDirection = VK_DOWN;
-
- lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
- lvItem.iItem = ListView_FindItem(hwnd2Settings, -1, &lvfi);
- lvItem.iSubItem = 0;
- if (lvItem.iItem >= 0)
- ListView_SetItemState(hwnd2Settings, lvItem.iItem, LVIS_SELECTED, LVIS_SELECTED);
- }
+ HTREEITEM hItem = findItemInTree(ii->hContact, ii->module);
+ if (hItem) {
+ TreeView_SelectItem(hwnd2Tree, hItem);
+ TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND);
+ if (ii->type != FW_MODULE)
+ SelectSetting(ii->setting);
}
break;
}
return 0;
}
+
+
+void openMainWindow() {
+ CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, MainDlgProc);
+}
|