From 3b247d07d6bae82efdc5d0f61213b8605345cb6c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 12 Feb 2014 15:27:33 +0000 Subject: fixes for the MCONTACTs, stored in the database git-svn-id: http://svn.miranda-ng.org/main/trunk@8111 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/DbEditorPP/src/main_window.cpp | 377 ++++++++++++++++----------------- plugins/DbEditorPP/src/moduletree.cpp | 359 +++++++++++++++---------------- 2 files changed, 355 insertions(+), 381 deletions(-) (limited to 'plugins/DbEditorPP/src') diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index efdf5599ec..0406d5fe11 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -9,54 +9,54 @@ int Hex; extern BOOL bServiceMode; -void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); -void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); +void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +void SettingsListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -int DialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) +int DialogResize(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc) { - switch(urc->wId) { + switch (urc->wId) { case IDC_MODULES: - urc->rcItem.right = lParam-3; + urc->rcItem.right = lParam - 3; urc->rcItem.top = 0; urc->rcItem.left = 0; urc->rcItem.bottom = urc->dlgNewSize.cy; - return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; + return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; case IDC_SPLITTER: urc->rcItem.top = 0; urc->rcItem.bottom = urc->dlgNewSize.cy; urc->rcItem.right = lParam; - urc->rcItem.left = lParam-3; - return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; + urc->rcItem.left = lParam - 3; + return RD_ANCHORX_CUSTOM | RD_ANCHORY_CUSTOM; case IDC_SETTINGS: urc->rcItem.top = 0; urc->rcItem.bottom = urc->dlgNewSize.cy; urc->rcItem.left = lParam; urc->rcItem.right = urc->dlgNewSize.cx; - return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; + 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_ANCHORY_CUSTOM | RD_ANCHORX_CUSTOM; } - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; + return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; } -static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_NCHITTEST: return HTCLIENT; case WM_SETCURSOR: { RECT rc; - GetClientRect(hwnd,&rc); - SetCursor(rc.right>rc.bottom?LoadCursor(NULL, IDC_SIZENS):LoadCursor(NULL, IDC_SIZEWE)); + GetClientRect(hwnd, &rc); + SetCursor(rc.right > rc.bottom ? LoadCursor(NULL, IDC_SIZENS) : LoadCursor(NULL, IDC_SIZEWE)); } return TRUE; @@ -65,10 +65,10 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LP return 0; case WM_MOUSEMOVE: - if(GetCapture()==hwnd) { + if (GetCapture() == hwnd) { RECT rc; - GetClientRect(hwnd,&rc); - SendMessage(GetParent(hwnd),GC_SPLITTERMOVED,rc.right>rc.bottom?(short)HIWORD(GetMessagePos())+rc.bottom/2:(short)LOWORD(GetMessagePos())+rc.right/2,(LPARAM)hwnd); + GetClientRect(hwnd, &rc); + SendMessage(GetParent(hwnd), GC_SPLITTERMOVED, rc.right > rc.bottom ? (short)HIWORD(GetMessagePos()) + rc.bottom / 2 : (short)LOWORD(GetMessagePos()) + rc.right / 2, (LPARAM)hwnd); } return 0; @@ -80,26 +80,25 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LP return mir_callNextSubclass(hwnd, SplitterSubclassProc, msg, wParam, lParam); } -LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_RBUTTONDOWN: { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(hwnd,&hti.pt); + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(hwnd, &hti.pt); - if(TreeView_HitTest(hwnd,&hti)) - { - if(hti.flags&TVHT_ONITEM) + if (TreeView_HitTest(hwnd, &hti)) { + if (hti.flags&TVHT_ONITEM) TreeView_SelectItem(hwnd, hti.hItem); } } break; case WM_CHAR: - if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) + if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6) CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; @@ -107,34 +106,34 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM if (wParam == VK_DELETE || wParam == VK_F2 || wParam == VK_F5 || wParam == VK_F3) { TVITEM tvi; char module[256]; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.hItem=TreeView_GetSelection(hwnd); + tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; + tvi.hItem = TreeView_GetSelection(hwnd); tvi.pszText = module; tvi.cchTextMax = 255; - if (TreeView_GetItem(hwnd,&tvi) && tvi.lParam) { + 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(module, hContact, 0)) { mir_free(mtis); - TreeView_DeleteItem(hwnd,tvi.hItem); + TreeView_DeleteItem(hwnd, tvi.hItem); } } else if ((mtis->type == CONTACT) && hContact) { - if (db_get_b(NULL,"CList", "ConfirmDelete",1)) { + 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) + if (MessageBox(0, msg, Translate("Confirm Contact Delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDNO) break; } - CallService(MS_DB_CONTACT_DELETE, hContact,0); - freeTree(hwnd,mtis->hContact); - TreeView_DeleteItem(hwnd,tvi.hItem); + CallService(MS_DB_CONTACT_DELETE, hContact, 0); + freeTree(hwnd, mtis->hContact); + TreeView_DeleteItem(hwnd, tvi.hItem); } } else if (wParam == VK_F2 && mtis->type == MODULE) - TreeView_EditLabel(hwnd,tvi.hItem); + TreeView_EditLabel(hwnd, tvi.hItem); else if (wParam == VK_F5) { refreshTree(1); break; @@ -150,11 +149,11 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM return mir_callNextSubclass(hwnd, ModuleTreeSubclassProc, msg, wParam, lParam); } -static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_CHAR: - if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) + if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6) CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; @@ -162,17 +161,17 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam 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); + SettingListInfo* sli = (SettingListInfo*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!sli) break; hContact = sli->hContact; module = sli->module; ListView_GetItemText(hwnd, ListView_GetSelectionMark(hwnd), 0, setting, 256); if (wParam == VK_F2) - editSetting(hContact,module, setting); + 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); + PopulateSettings(hwnd, hContact, szModule); mir_free(szModule); } else if (wParam == VK_DELETE) @@ -189,55 +188,55 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); { hwnd2mainWindow = hwnd; // do the icon - SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); + 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,(LPARAM)db_get_w(NULL, modname, "Splitter", 300)); - SendMessage(hwnd, GC_SPLITTERMOVED, 0,0); - mir_subclassWindow(GetDlgItem(hwnd,IDC_SPLITTER), SplitterSubclassProc); + SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, (LPARAM)db_get_w(NULL, modname, "Splitter", 300)); + 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); + TreeView_SetUnicodeFormat(GetDlgItem(hwnd, IDC_MODULES), TRUE); + mir_subclassWindow(GetDlgItem(hwnd, IDC_MODULES), ModuleTreeSubclassProc); //setting list - setupSettingsList(GetDlgItem(hwnd,IDC_SETTINGS)); - mir_subclassWindow(GetDlgItem(hwnd,IDC_SETTINGS), SettingListSubclassProc); + setupSettingsList(GetDlgItem(hwnd, IDC_SETTINGS)); + mir_subclassWindow(GetDlgItem(hwnd, IDC_SETTINGS), SettingListSubclassProc); HMENU hMenu = GetMenu(hwnd); TranslateMenu(hMenu); - for (int i=0; i < 6; i++) - TranslateMenu(GetSubMenu(hMenu,i)); + 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)) { + 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; - SetWindowPlacement(hwnd,&wp); + SetWindowPlacement(hwnd, &wp); } - SetCursor(LoadCursor(NULL,IDC_ARROW)); + SetCursor(LoadCursor(NULL, IDC_ARROW)); Mode = MODE_ALL; - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_CHECKED); + 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)); + 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)); - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(db_get_b(NULL,modname,"RestoreOnOpen",1)?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)); + 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; @@ -294,7 +293,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int restore; if (hRestore) restore = 3; - else if (db_get_b(NULL,modname,"RestoreOnOpen",1)) + else if (db_get_b(NULL, modname, "RestoreOnOpen", 1)) restore = 2; else restore = 0; @@ -305,92 +304,92 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case GC_SPLITTERMOVED: { - POINT pt; - RECT rc; - RECT rc2; - - int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); - - GetWindowRect(hwnd,&rc2); + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA); - if ((HWND)lParam==GetDlgItem(hwnd,IDC_SPLITTER)) - { - GetClientRect(hwnd,&rc); - pt.x=wParam; pt.y=0; - 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; - SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA, splitterPos); - db_set_w(NULL, modname, "Splitter",(WORD)splitterPos); + RECT rc2; + GetWindowRect(hwnd, &rc2); + + if ((HWND)lParam == GetDlgItem(hwnd, IDC_SPLITTER)) { + RECT rc; + GetClientRect(hwnd, &rc); + POINT pt = { wParam, 0 }; + 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; + SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos); + db_set_w(NULL, modname, "Splitter", (WORD)splitterPos); } - PostMessage(hwnd,WM_SIZE,0,0); + PostMessage(hwnd, WM_SIZE, 0, 0); } break; + case WM_GETMINMAXINFO: { - MINMAXINFO *mmi=(MINMAXINFO*)lParam; - int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); + MINMAXINFO *mmi = (MINMAXINFO*)lParam; + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA); - if(splitterPos+40 > 200) - mmi->ptMinTrackSize.x=splitterPos+65; + if (splitterPos + 40 > 200) + mmi->ptMinTrackSize.x = splitterPos + 65; else - mmi->ptMinTrackSize.x=200; - mmi->ptMinTrackSize.y=150; - return 0; + mmi->ptMinTrackSize.x = 200; + mmi->ptMinTrackSize.y = 150; } + return 0; + case WM_MOVE: case WM_SIZE: { UTILRESIZEDIALOG urd; - ZeroMemory(&urd,sizeof(urd)); - urd.cbSize=sizeof(urd); - urd.hInstance=hInst; - urd.hwndDlg=hwnd; - urd.lParam=(LPARAM)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); - urd.lpTemplate=MAKEINTRESOURCE(IDD_MAIN); - urd.pfnResizer=DialogResize; - CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); + ZeroMemory(&urd, sizeof(urd)); + urd.cbSize = sizeof(urd); + urd.hInstance = hInst; + urd.hwndDlg = hwnd; + urd.lParam = (LPARAM)GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA); + urd.lpTemplate = MAKEINTRESOURCE(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); + db_set_b(NULL, modname, "Maximised", 1); else if (msg == WM_SIZE && wParam == SIZE_RESTORED) - db_set_b(NULL,modname,"Maximised",0); + db_set_b(NULL, modname, "Maximised", 0); } break; case WM_DESTROY: // free our shit! - if (db_get_b(NULL,modname,"RestoreOnOpen",1)) { + if (db_get_b(NULL, modname, "RestoreOnOpen", 1)) { HTREEITEM item; - HWND hwnd2Tree = GetDlgItem(hwnd,IDC_MODULES); - char module[256] = {0}; + HWND hwnd2Tree = GetDlgItem(hwnd, IDC_MODULES); + char module[256] = { 0 }; if (item = TreeView_GetSelection(hwnd2Tree)) { int type = MODULE; - TVITEM tvi = {0}; - MCONTACT hContact = NULL; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + + TVITEM tvi = { 0 }; + tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; tvi.pszText = module; tvi.cchTextMax = 255; - tvi.hItem=item; + 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; } - db_set_dw(NULL,modname,"LastContact",(DWORD)hContact); + db_set_dw(NULL, modname, "LastContact", hContact); if (type == CONTACT) - db_set_s(NULL,modname,"LastModule",""); + db_set_s(NULL, modname, "LastModule", ""); else - db_set_s(NULL,modname,"LastModule",module); + db_set_s(NULL, modname, "LastModule", module); } else { - db_unset(NULL,modname,"LastContact"); - db_unset(NULL,modname,"LastModule"); + db_unset(NULL, modname, "LastContact"); + db_unset(NULL, modname, "LastModule"); } HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); @@ -399,29 +398,29 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (pos != -1) { char text[256]; ListView_GetItemText(hwnd2Settings, pos, 0, text, SIZEOF(text)); - db_set_s(NULL,modname,"LastSetting",text); + db_set_s(NULL, modname, "LastSetting", text); } - else db_unset(NULL,modname,"LastSetting"); + 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)); + 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); + 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)) { + 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); + 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) { @@ -429,36 +428,35 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) hwnd2importWindow = 0; } - if ( bServiceMode ) + if (bServiceMode) PostQuitMessage(0); return 0; case WM_COMMAND: if (GetKeyState(VK_ESCAPE) & 0x8000) return TRUE; // this needs to be changed to c if htere is a label edit happening.. - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case MENU_REFRESH_MODS: refreshTree(1); break; case MENU_REFRESH_SETS: - { - TVITEM tvi; - ModuleTreeInfoStruct *mtis; - char module[256]; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.hItem=TreeView_GetSelection(GetDlgItem(hwnd, IDC_MODULES)); - tvi.pszText = module; - tvi.cchTextMax = 255; - 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)); - } + { + TVITEM tvi; + ModuleTreeInfoStruct *mtis; + char module[256]; + tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; + tvi.hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_MODULES)); + tvi.pszText = module; + tvi.cchTextMax = 255; + 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)); } + else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS)); + } break; ///////////////////////// // watches case MENU_VIEW_WATCHES: @@ -495,12 +493,11 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; case MENU_FILTER_ALL: - if (Mode != MODE_ALL) - { + if (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); + 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; refreshTree(1); } @@ -508,9 +505,9 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case MENU_FILTER_LOADED: if (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); + 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; refreshTree(1); } @@ -518,39 +515,39 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case MENU_FILTER_UNLOADED: if (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); + 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; 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)); + CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_BYTE_HEX, MF_BYCOMMAND | ((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)); + CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_WORD_HEX, MF_BYCOMMAND | ((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)); + CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED)); break; case MENU_SAVE_POSITION: - { - BOOL save = !db_get_b(NULL,modname,"RestoreOnOpen",1); - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(save?MF_CHECKED:MF_UNCHECKED)); - db_set_b(NULL,modname,"RestoreOnOpen", (byte)save); - } + { + BOOL save = !db_get_b(NULL, modname, "RestoreOnOpen", 1); + CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED)); + db_set_b(NULL, modname, "RestoreOnOpen", (byte)save); + } break; case MENU_SORT_ORDER: Order = !Order; - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SORT_ORDER,MF_BYCOMMAND|(Order?MF_CHECKED:MF_UNCHECKED)); + CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (Order ? MF_CHECKED : MF_UNCHECKED)); refreshTree(1); break; case MENU_OPEN_OPTIONS: - OPENOPTIONSDIALOG odp = {0}; + OPENOPTIONSDIALOG odp = { 0 }; odp.cbSize = sizeof(odp); odp.pszGroup = "Database"; odp.pszPage = modFullname; @@ -561,37 +558,35 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return TRUE; // case WM_COMMAND case WM_NOTIFY: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDC_MODULES: - moduleListWM_NOTIFY(hwnd,msg,wParam,lParam); + moduleListWM_NOTIFY(hwnd, msg, wParam, lParam); break; case IDC_SETTINGS: - SettingsListWM_NOTIFY(hwnd,msg,wParam,lParam); + SettingsListWM_NOTIFY(hwnd, msg, wParam, lParam); break; } return TRUE; // case WM_NOTIFY 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); - } + 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); } } break; diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index 7427e635a9..1cf43de7b7 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -5,7 +5,6 @@ int Select = 0; static ModuleTreeInfoStruct contacts_mtis = {CONTACT_ROOT_ITEM, 0}; static ModuleTreeInfoStruct settings_mtis = {CONTACT, 0}; - int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelectedContact, char *SelectedModule, char *SelectedSetting) { TVINSERTSTRUCT tvi; @@ -44,7 +43,7 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); lParam->hContact = hContact; lParam->type = CONTACT; - tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvi.item.lParam = (LPARAM)lParam; tvi.hParent = contactsRoot; @@ -52,7 +51,7 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, lParam->type |= EMPTY; // contacts name - DBVARIANT dbv ={0}; + DBVARIANT dbv = { 0 }; WCHAR nick[256]; WCHAR protoW[256]; // unicode proto @@ -87,11 +86,11 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, if (hSelectedContact == hContact) { module = modlist->first; - while(module && hwnd2mainWindow) { + while (module && hwnd2mainWindow) { if (module->name[0] && !IsModuleEmpty(hContact, module->name)) { tvi.hParent = contact; tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvi.item.pszText = module->name; lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); @@ -113,86 +112,81 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, if (hItem != -1) { TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); - TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); + TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND); if (SelectedSetting[0]) SelectSetting(SelectedSetting); } return itemscount; } -void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) +void doItems(HWND hwnd2Tree, ModuleSettingLL *modlist, int count) { - TVINSERTSTRUCT tvi; - TVITEM item ={0}; - MCONTACT hContact; - ModuleTreeInfoStruct *lParam; - ModSetLinkLinkItem *module; - char percent[96], title[64]; HWND hwnd = GetParent(hwnd2Tree); - int i = 0; + char percent[96], title[64]; mir_snprintf(title, SIZEOF(title), Translate("Loading modules...")); - item.mask = TVIF_STATE|TVIF_PARAM; + TVITEM item = { 0 }; + item.mask = TVIF_STATE | TVIF_PARAM; - HTREEITEM contact = TreeView_GetChild( hwnd2Tree, TVI_ROOT ); + HTREEITEM contact = TreeView_GetChild(hwnd2Tree, TVI_ROOT); contact = TreeView_GetNextSibling(hwnd2Tree, contact); contact = TreeView_GetChild(hwnd2Tree, contact); - while (contact && hwnd2mainWindow) { - i++; + MCONTACT hContact = 0; + for (int i = 1; contact && hwnd2mainWindow; i++) { item.hItem = contact; contact = TreeView_GetNextSibling(hwnd2Tree, contact); - if (TreeView_GetItem( hwnd2Tree, &item ) && item.lParam) { + if (TreeView_GetItem(hwnd2Tree, &item) && item.lParam) { ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; hContact = mtis->hContact; - if (hContact == NULL || mtis->type != (CONTACT|EMPTY)) + if (hContact == NULL || mtis->type != (CONTACT | EMPTY)) continue; - else - mtis->type = CONTACT; + mtis->type = CONTACT; } else continue; // Caption - mir_snprintf(percent, SIZEOF(percent), "%s %d%%", title, (int)(100*i/count)); + mir_snprintf(percent, SIZEOF(percent), "%s %d%%", title, (int)(100 * i / count)); SetWindowText(hwnd, percent); - module = modlist->first; - while(module && hwnd2mainWindow) { - if (module->name[0] && !IsModuleEmpty(hContact,module->name)) { - tvi.hParent = item.hItem; - tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.item.pszText = module->name; + for (ModSetLinkLinkItem *module = modlist->first; module && hwnd2mainWindow; module = module->next) { + if (!module->name[0] || IsModuleEmpty(hContact, module->name)) + continue; - lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); - lParam->hContact = hContact; + TVINSERTSTRUCT tvi; + tvi.hParent = item.hItem; + tvi.hInsertAfter = TVI_SORT; + tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; + tvi.item.pszText = module->name; - tvi.item.iImage = 1; - tvi.item.iSelectedImage = 2; - lParam->type = KNOWN_MODULE; + ModuleTreeInfoStruct *lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); + lParam->hContact = hContact; - tvi.item.lParam = (LPARAM)lParam; - TreeView_InsertItem(hwnd2Tree, &tvi); - } - module = (ModSetLinkLinkItem *)module->next; + tvi.item.iImage = 1; + tvi.item.iSelectedImage = 2; + lParam->type = KNOWN_MODULE; + + tvi.item.lParam = (LPARAM)lParam; + TreeView_InsertItem(hwnd2Tree, &tvi); } } SetWindowText(hwnd, TranslateT("Database Editor++")); } +// the following code to go through the whole tree is nicked from codeguru.. +// http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 + int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char* module) - /* the following code to go through the whole tree is nicked from codeguru.. - http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ { TVITEM item; char text[265]; HTREEITEM lastItem; if (!TreeView_GetCount(hwnd2Tree)) return 0; - item.mask = TVIF_STATE|TVIF_PARAM|TVIF_TEXT; + item.mask = TVIF_STATE | TVIF_PARAM | TVIF_TEXT; item.hItem = TVI_ROOT; item.pszText = text; item.cchTextMax = 264; @@ -201,8 +195,8 @@ int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char* module) lastItem = item.hItem; if (lastItem != TVI_ROOT) { /* these next 2 lines are not from code guru..... */ - if (TreeView_GetItem( hwnd2Tree, &item) && item.lParam) { - if ((hContact == ((ModuleTreeInfoStruct *)item.lParam)->hContact) && (!module[0] || !mir_strcmp(module,text))) { + if (TreeView_GetItem(hwnd2Tree, &item) && item.lParam) { + if ((hContact == ((ModuleTreeInfoStruct *)item.lParam)->hContact) && (!module[0] || !mir_strcmp(module, text))) { //TreeView_SelectItem(hwnd2Tree,item.hItem); return (int)item.hItem; } @@ -210,17 +204,19 @@ int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char* module) /* back to coduguru's code*/ } } - while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem ))); + while ((item.hItem = TreeView_GetChild(hwnd2Tree, lastItem))); - while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {} + while ((!(item.hItem = TreeView_GetNextSibling(hwnd2Tree, lastItem))) && (lastItem = item.hItem = TreeView_GetParent(hwnd2Tree, lastItem))) + ; } - while ( item.hItem ); + while (item.hItem); return -1; } +// the following code to go through the whole tree is nicked from codeguru.. +// http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 + void freeTree(HWND hwnd2Tree, MCONTACT hContact) - /* the following code to go through the whole tree is nicked from codeguru.. - http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ { TVITEM item; HTREEITEM lastItem; @@ -380,32 +376,29 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) switch((int)di) { case 1: // restore after rebuild - { - HTREEITEM item; - if (item = TreeView_GetSelection(hwnd2Tree)) { - TVITEM tvi = {0}; - - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.pszText = SelectedModule; - tvi.cchTextMax = 255; - tvi.hItem=item; - - TreeView_GetItem(hwnd2Tree, &tvi); - if (tvi.lParam) { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; - hSelectedContact = mtis->hContact; - if (mtis->type == CONTACT) SelectedModule[0] = 0; - Select = 1; - } + if (HTREEITEM item = TreeView_GetSelection(hwnd2Tree)) { + TVITEM tvi = { 0 }; + tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; + tvi.pszText = SelectedModule; + tvi.cchTextMax = 255; + tvi.hItem = item; + + TreeView_GetItem(hwnd2Tree, &tvi); + if (tvi.lParam) { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; + hSelectedContact = mtis->hContact; + if (mtis->type == CONTACT) SelectedModule[0] = 0; + Select = 1; } - break; } + break; + case 2: // restore saved - if (GetValue(NULL,modname,"LastModule",SelectedModule,SIZEOF(SelectedModule))) { - hSelectedContact = (MCONTACT)db_get_dw(NULL, modname, "LastContact", (DWORD)INVALID_HANDLE_VALUE); + if (GetValue(NULL, modname, "LastModule", SelectedModule, SIZEOF(SelectedModule))) { + hSelectedContact = db_get_dw(NULL, modname, "LastContact", (DWORD)INVALID_HANDLE_VALUE); if (hSelectedContact != INVALID_CONTACT_ID) Select = 1; - GetValue(NULL,modname,"LastSetting",SelectedSetting,SIZEOF(SelectedSetting)); + GetValue(NULL, modname, "LastSetting", SelectedSetting, SIZEOF(SelectedSetting)); } break; @@ -418,14 +411,14 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) if ((int)di != 4) { // do not rebuild on just going to another setting if (!EnumModules(&modlist)) { - msg(Translate("Error Loading Module List"),modFullname); + msg(Translate("Error Loading Module List"), modFullname); return; } // remove all items (incase there are items there... - freeTree(hwnd2Tree,0); + freeTree(hwnd2Tree, 0); TreeView_DeleteAllItems(hwnd2Tree); - TreeView_SelectItem(hwnd2Tree,0); + TreeView_SelectItem(hwnd2Tree, 0); //image list TreeView_SetImageList(hwnd2Tree, himl, TVSIL_NORMAL); @@ -434,7 +427,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) contacts_mtis.type = CONTACT_ROOT_ITEM; tvi.item.lParam = (LPARAM)&contacts_mtis; tvi.hParent = NULL; - tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_STATE|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_STATE | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvi.item.state = TVIS_BOLD; tvi.item.stateMask = TVIS_BOLD; tvi.item.cChildren = 1; @@ -448,7 +441,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) // add the settings item settings_mtis.type = STUB; tvi.item.lParam = (LPARAM)&settings_mtis; - tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvi.item.cChildren = 1; tvi.hParent = NULL; tvi.hInsertAfter = TVI_FIRST; @@ -462,13 +455,11 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) hContact = 0; module = modlist.first; - while (module) - { - if (!IsModuleEmpty(hContact,module->name)) - { + while (module) { + if (!IsModuleEmpty(hContact, module->name)) { tvi.hParent = contact; tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvi.item.pszText = module->name; lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); @@ -484,35 +475,31 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) module = (ModSetLinkLinkItem *)module->next; } - if (db_get_b(NULL,modname,"ExpandSettingsOnOpen",0)) - TreeView_Expand(hwnd2Tree,contact,TVE_EXPAND); + if (db_get_b(NULL, modname, "ExpandSettingsOnOpen", 0)) + TreeView_Expand(hwnd2Tree, contact, TVE_EXPAND); - if (Select && hSelectedContact == NULL) - { + if (Select && hSelectedContact == NULL) { int hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); - if (hItem != -1) - { + if (hItem != -1) { TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); - TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); + TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND); if (SelectedSetting[0]) SelectSetting(SelectedSetting); } Select = 0; } - count = doContacts(hwnd2Tree,contactsRoot,&modlist, Select?hSelectedContact:NULL, SelectedModule, SelectedSetting); + count = doContacts(hwnd2Tree, contactsRoot, &modlist, Select ? hSelectedContact : NULL, SelectedModule, SelectedSetting); Select = 0; - doItems(hwnd2Tree,&modlist,count); + doItems(hwnd2Tree, &modlist, count); FreeModuleSettingLL(&modlist); } - if (Select) - { + if (Select) { int hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); - if (hItem != -1) - { + if (hItem != -1) { TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); - TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); + TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND); if (SelectedSetting[0]) SelectSetting(SelectedSetting); } } @@ -523,14 +510,14 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_KEYUP: switch (wParam) { case VK_RETURN: - TreeView_EndEditLabelNow(GetParent(hwnd),0); + TreeView_EndEditLabelNow(GetParent(hwnd), 0); return 0; case VK_ESCAPE: - TreeView_EndEditLabelNow(GetParent(hwnd),1); + TreeView_EndEditLabelNow(GetParent(hwnd), 1); return 0; } break; @@ -540,37 +527,32 @@ static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd,UINT msg,WPARA void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam); -void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd here is to the main window, NOT the treview +void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hwnd here is to the main window, NOT the treview { - switch(((NMHDR*)lParam)->code) - { + switch (((NMHDR*)lParam)->code) { case TVN_ITEMEXPANDINGA: case TVN_ITEMEXPANDINGW: - if (populating && ((LPNMTREEVIEW)lParam)->action == TVE_EXPAND) - { + if (populating && ((LPNMTREEVIEW)lParam)->action == TVE_EXPAND) { ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)((LPNMTREEVIEW)lParam)->itemNew.lParam; - if (mtis && (mtis->type == (CONTACT | EMPTY))) - { + if (mtis && (mtis->type == (CONTACT | EMPTY))) { TVINSERTSTRUCT tvi; - HTREEITEM item = {0}; + HTREEITEM item = { 0 }; ModuleTreeInfoStruct *_lParam; - HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow,IDC_MODULES); + HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow, IDC_MODULES); ModSetLinkLinkItem *module; ModuleSettingLL modlist; MCONTACT hContact = mtis->hContact; mtis->type = CONTACT; - if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); break;} + if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"), modFullname); break; } module = modlist.first; - while(module && hwnd2mainWindow) - { - if (module->name[0] && !IsModuleEmpty(hContact,module->name)) - { + while (module && hwnd2mainWindow) { + if (module->name[0] && !IsModuleEmpty(hContact, module->name)) { tvi.hParent = ((LPNMTREEVIEW)lParam)->itemNew.hItem; tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvi.item.pszText = module->name; _lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); @@ -596,15 +578,15 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd { ModuleTreeInfoStruct *mtis; LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; - TVITEM tvi = {0}; + TVITEM tvi = { 0 }; char text[264]; MCONTACT hContact; HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); - tvi.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; tvi.hItem = pnmtv->itemNew.hItem; tvi.pszText = text; tvi.cchTextMax = 264; - TreeView_GetItem(pnmtv->hdr.hwndFrom,&tvi); + TreeView_GetItem(pnmtv->hdr.hwndFrom, &tvi); if (tvi.lParam) { mtis = (ModuleTreeInfoStruct *)tvi.lParam; @@ -615,7 +597,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd if (populating) Select = 0; if (mtis->type == MODULE) { - SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); + SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA); BOOL refresh = 1; if (info) { @@ -630,12 +612,12 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) { char data[32], szProto[256]; int index, loaded, multi = 0; - LVITEM lvi = {0}; - lvi.mask = LVIF_IMAGE|LVIF_TEXT|LVIF_PARAM; + LVITEM lvi = { 0 }; + lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM; lvi.iImage = 6; ClearListview(hwnd2Settings); - SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)NULL); + SetWindowLongPtr(hwnd2Settings, GWLP_USERDATA, (LONG)NULL); if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); if (mtis->type == CONTACT_ROOT_ITEM && !hContact) { @@ -643,10 +625,10 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd hContact = db_find_first(); } - while(hContact && hwnd2mainWindow) { + while (hContact && hwnd2mainWindow) { if (multi) { // filter - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + if (GetValue(hContact, "Protocol", "p", szProto, SIZEOF(szProto))) loaded = IsProtocolLoaded(szProto); else loaded = 0; @@ -664,9 +646,9 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd mir_snprintf(data, SIZEOF(data), "0x%08X (%ld)", hContact, hContact); - ListView_SetItemText(hwnd2Settings,index,1,data); - ListView_SetItemText(hwnd2Settings,index,2,Translate("HANDLE")); - ListView_SetItemText(hwnd2Settings,index,3,"0x0004 (4)"); + ListView_SetItemText(hwnd2Settings, index, 1, data); + ListView_SetItemText(hwnd2Settings, index, 2, Translate("HANDLE")); + ListView_SetItemText(hwnd2Settings, index, 3, "0x0004 (4)"); if (!multi) break; @@ -675,21 +657,20 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd } else ClearListview(hwnd2Settings); } - else - // clear any settings that may be there... + else // clear any settings that may be there... ClearListview(hwnd2Settings); } break; //TVN_SELCHANGED: case NM_RCLICK: if (((NMHDR*)lParam)->code == NM_RCLICK) - moduleListRightClick(hwnd,wParam,lParam); + moduleListRightClick(hwnd, wParam, lParam); break; case TVN_BEGINLABELEDITA: // subclass it.. case TVN_BEGINLABELEDITW: { - LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam; ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES)); if (!mtis->type || (mtis->type == CONTACT)) { @@ -703,68 +684,66 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd case TVN_ENDLABELEDITA: case TVN_ENDLABELEDITW: - { - LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; - TVITEM tvi = {0}; - char text[264]; - char *newtext; - ModuleTreeInfoStruct *mtis; - tvi.mask=TVIF_HANDLE|TVIF_TEXT|TVIF_PARAM; - tvi.hItem=ptvdi->item.hItem; - tvi.pszText = text; - tvi.cchTextMax = 264; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); - mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; - - newtext = u2a((WCHAR*)ptvdi->item.pszText); - - if (!newtext || // edit control failed - !mtis->type || // its a root item - mtis->type == CONTACT || // its a contact - *newtext == 0) // empty string - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); - else { - if (mir_strcmp(tvi.pszText, newtext)) { - renameModule(tvi.pszText, newtext, mtis->hContact); + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam; + TVITEM tvi = { 0 }; + char text[264]; + char *newtext; + ModuleTreeInfoStruct *mtis; + tvi.mask = TVIF_HANDLE | TVIF_TEXT | TVIF_PARAM; + tvi.hItem = ptvdi->item.hItem; + tvi.pszText = text; + tvi.cchTextMax = 264; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); + mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; + + newtext = u2a((WCHAR*)ptvdi->item.pszText); + + if (!newtext || // edit control failed + !mtis->type || // its a root item + mtis->type == CONTACT || // its a contact + *newtext == 0) // empty string + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); + else { + if (mir_strcmp(tvi.pszText, newtext)) { + renameModule(tvi.pszText, newtext, mtis->hContact); - findAndRemoveDuplicates(((LPNMHDR)lParam)->hwndFrom,mtis->hContact,newtext); + findAndRemoveDuplicates(((LPNMHDR)lParam)->hwndFrom, mtis->hContact, newtext); - if (TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi)) { - tvi.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; - tvi.iImage = 1; - tvi.iSelectedImage = 2; - TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); + if (TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi)) { + tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvi.iImage = 1; + tvi.iSelectedImage = 2; + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); - PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, newtext); - } + PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, newtext); } - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); } - - mir_free(newtext); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); } + + mir_free(newtext); break; } } -void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here is to the main window, NOT the treview +void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here is to the main window, NOT the treview { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); - if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) { + if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) { if (hti.flags & TVHT_ONITEM) { - TVITEM tvi = {0}; - HMENU hMenu,hSubMenu; + TVITEM tvi = { 0 }; + HMENU hMenu, hSubMenu; int menuNumber; char module[256]; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.hItem=hti.hItem; + tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; + tvi.hItem = hti.hItem; tvi.pszText = module; tvi.cchTextMax = 255; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); if (tvi.lParam) { ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; MCONTACT hContact = mtis->hContact; @@ -788,24 +767,24 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i int i, watching = 0; // check if the setting is being watched and if it is then check the menu item if (WatchListArray.item) - for (i=0; i < WatchListArray.count; i++) + for (i = 0; i < WatchListArray.count; i++) if (WatchListArray.item[i].module && (hContact == WatchListArray.item[i].hContact)) { if (!mir_strcmp(module, WatchListArray.item[i].module) && !WatchListArray.item[i].setting) { // yes so uncheck it - CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED|MF_BYCOMMAND); + CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED | MF_BYCOMMAND); watching = 1; break; } } - + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_RENAME_MOD: - TreeView_EditLabel(GetDlgItem(hwnd, IDC_MODULES),tvi.hItem); + TreeView_EditLabel(GetDlgItem(hwnd, IDC_MODULES), tvi.hItem); break; case MENU_DELETE_MOD: if (deleteModule(module, hContact, 0)) { - TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,hti.hItem); + TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, hti.hItem); mir_free(mtis); } break; @@ -814,10 +793,10 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i copyModuleMenuItem(module, hContact); break; - ////////////////////////////////////////////////////////////////////// divider + ////////////////////////////////////////////////////////////////////// divider case MENU_WATCH_ITEM: if (!watching) - addSettingToWatchList(hContact,module,0); + addSettingToWatchList(hContact, module, 0); else freeWatchListItem(i); if (hwnd2watchedVarsWindow) @@ -843,19 +822,19 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i break; case MENU_DELETE_CONTACT: - if (db_get_b(NULL,"CList", "ConfirmDelete",1)) { + 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) == IDYES) { - CallService(MS_DB_CONTACT_DELETE, hContact,0); - freeTree(((LPNMHDR)lParam)->hwndFrom,hContact); - TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,tvi.hItem); + if (MessageBox(0, msg, Translate("Confirm Contact Delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) { + CallService(MS_DB_CONTACT_DELETE, hContact, 0); + freeTree(((LPNMHDR)lParam)->hwndFrom, hContact); + TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, tvi.hItem); } } else { - CallService(MS_DB_CONTACT_DELETE, hContact,0); - freeTree(((LPNMHDR)lParam)->hwndFrom,hContact); - TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,tvi.hItem); + CallService(MS_DB_CONTACT_DELETE, hContact, 0); + freeTree(((LPNMHDR)lParam)->hwndFrom, hContact); + TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, tvi.hItem); } break; @@ -869,7 +848,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i case MENU_IMPORTFROMFILE: ImportSettingsFromFileMenuItem(hContact, ""); break; - + ////////////////////////////////////////////////////////////////////// divider case MENU_ADD_MODULE: { @@ -883,7 +862,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i break; case 3: // NULL contact - switch ( TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_ADD_MODULE: { HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact); @@ -905,7 +884,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i break; case 4: // Contacts root - switch ( TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_EXPORTCONTACT: exportDB(INVALID_CONTACT_ID, ""); break; -- cgit v1.2.3