From eadd77936fd5405d23ab71722183e6f3f2de8208 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Tue, 31 Jul 2012 18:12:58 +0000 Subject: AddContactPlus: Open only one window at a time git-svn-id: http://svn.miranda-ng.org/main/trunk@1287 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AddContactPlus/src/addcontact.cpp | 1 + plugins/AddContactPlus/src/addcontactplus.h | 1 + plugins/AddContactPlus/src/main.cpp | 24 ++++++++++++++++-------- 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'plugins/AddContactPlus') diff --git a/plugins/AddContactPlus/src/addcontact.cpp b/plugins/AddContactPlus/src/addcontact.cpp index a2feb5c449..d77ba3a07d 100644 --- a/plugins/AddContactPlus/src/addcontact.cpp +++ b/plugins/AddContactPlus/src/addcontact.cpp @@ -409,6 +409,7 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp } case WM_DESTROY: + hAddDlg = NULL; CallService(MS_SKIN2_RELEASEICONBIG, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_BIG, (LPARAM)NULL), 0); CallService(MS_SKIN2_RELEASEICON, (WPARAM)SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)NULL), 0); ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hdlg, IDC_PROTO, CBEM_GETIMAGELIST, 0, 0)); diff --git a/plugins/AddContactPlus/src/addcontactplus.h b/plugins/AddContactPlus/src/addcontactplus.h index 280a349fce..29da1dfa17 100644 --- a/plugins/AddContactPlus/src/addcontactplus.h +++ b/plugins/AddContactPlus/src/addcontactplus.h @@ -53,3 +53,4 @@ with this program; if not, write to the Free Software Foundation, Inc., INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam); extern HINSTANCE hInst; +extern HWND hAddDlg; diff --git a/plugins/AddContactPlus/src/main.cpp b/plugins/AddContactPlus/src/main.cpp index c81962fb5e..d4bc5304ad 100644 --- a/plugins/AddContactPlus/src/main.cpp +++ b/plugins/AddContactPlus/src/main.cpp @@ -25,6 +25,7 @@ int hLangpack; static HANDLE hModulesLoaded = 0, hChangedIcons = 0, hAccListChanged = 0, hMainMenuItem = 0, hToolBarItem = 0, hService = 0; HANDLE hIconLibItem; +HWND hAddDlg; PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), @@ -55,7 +56,15 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_ADDCONT INT_PTR AddContactPlusDialog(WPARAM, LPARAM) { - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)NULL, AddContactDlgProc, 0); + if(hAddDlg) + { + SetForegroundWindow(hAddDlg); + SetFocus(hAddDlg); + } + else + { + hAddDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), NULL, AddContactDlgProc, 0); + } return 0; } @@ -78,13 +87,12 @@ static int OnAccListChanged(WPARAM, LPARAM) { PROTOACCOUNT** pAccounts; int iRealAccCount, iAccCount = 0; - DWORD dwCaps; ProtoEnumAccounts(&iRealAccCount, &pAccounts); for (int i = 0; i < iRealAccCount; i++) { if (!IsAccountEnabled(pAccounts[i])) continue; - dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); + DWORD dwCaps = (DWORD)CallProtoService(pAccounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (dwCaps & PF1_BASICSEARCH || dwCaps & PF1_EXTSEARCH || dwCaps & PF1_SEARCHBYEMAIL || dwCaps & PF1_SEARCHBYNAME) iAccCount++; } @@ -133,12 +141,12 @@ static int CreateButton(WPARAM, LPARAM) static int OnModulesLoaded(WPARAM, LPARAM) { SKINICONDESC sid = {0}; - char szFile[MAX_PATH]; - GetModuleFileNameA(hInst, szFile, MAX_PATH); + TCHAR szFile[MAX_PATH]; + GetModuleFileName(hInst, szFile, MAX_PATH); sid.cbSize = sizeof(SKINICONDESC); - sid.flags = SIDF_TCHAR; - sid.pszDefaultFile = szFile; - sid.ptszSection = _T("AddContact+"); + sid.flags = SIDF_ALL_TCHAR; + sid.ptszDefaultFile = szFile; + sid.ptszSection = LPGENT("AddContact+"); sid.iDefaultIndex = -IDI_ADDCONTACT; sid.ptszDescription = LPGENT("Add Contact"); sid.pszName = ICON_ADD; -- cgit v1.2.3