From 8142cedd8b857edd99a92f328e8b692b32bfeba6 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 16 Dec 2010 23:06:55 +0200 Subject: save windows position --- init.cpp | 15 +++++++++++++++ main.cpp | 30 ++++++++++++++++++++++++++++++ main.h | 1 + messages.cpp | 6 ++++++ new_gpg.vcxproj | 26 ++++++++++++++------------ options.cpp | 6 ++++++ 6 files changed, 72 insertions(+), 12 deletions(-) diff --git a/init.cpp b/init.cpp index 3afca12..3497f4b 100644 --- a/init.cpp +++ b/init.cpp @@ -30,6 +30,7 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam); extern char *date(); MM_INTERFACE mmi = {0}; UTF8_INTERFACE utfi = {0}; +RECT key_from_keyserver_rect = {0}, firstrun_rect = {0}, new_key_rect = {0}, key_gen_rect = {0}, load_key_rect = {0}, import_key_rect = {0}, key_password_rect = {0}, load_existing_key_rect = {0}; XML_API xi = {0}; logtofile debuglog; bool gpg_configured = false; @@ -93,6 +94,20 @@ void init_vars() debuglog.init(); bJabberAPI = DBGetContactSettingByte(NULL, szGPGModuleName, "bJabberAPI", bIsMiranda09?1:0); bFileTransfers = DBGetContactSettingByte(NULL, szGPGModuleName, "bFileTransfers", 1); + firstrun_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "FirstrunWindowX", 0); + firstrun_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "FirstrunWindowY", 0); + key_password_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "PasswordWindowX", 0); + key_password_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "PasswordWindowY", 0); + key_gen_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "KeyGenWindowX", 0); + key_gen_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "KeyGenWindowY", 0); + load_key_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "LoadKeyWindowX", 0); + load_key_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "LoadKeyWindowY", 0); + import_key_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "ImportKeyWindowX", 0); + import_key_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "ImportKeyWindowY", 0); + new_key_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "NewKeyWindowX", 0); + new_key_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "NewKeyWindowY", 0); + load_existing_key_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "LoadExistingKeyWindowX", 0); + load_existing_key_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "LoadExistingKeyWindowY", 0); } extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) diff --git a/main.cpp b/main.cpp index 8d12350..eca2698 100644 --- a/main.cpp +++ b/main.cpp @@ -39,6 +39,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM { case WM_INITDIALOG: { + SetWindowPos(hwndDlg, 0, firstrun_rect.left, firstrun_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); col.pszText = _T("Key ID"); col.mask = LVCF_TEXT | LVCF_WIDTH; @@ -490,6 +491,11 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM DestroyWindow(hwndDlg); break; case WM_DESTROY: + { + GetWindowRect(hwndDlg, &firstrun_rect); + DBWriteContactSettingDword(NULL, szGPGModuleName, "FirstrunWindowX", firstrun_rect.left); + DBWriteContactSettingDword(NULL, szGPGModuleName, "FirstrunWindowY", firstrun_rect.top); + } hwndFirstRun = NULL; break; @@ -958,6 +964,7 @@ static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, { case WM_INITDIALOG: { + SetWindowPos(hwndDlg, 0, new_key_rect.left, new_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); TCHAR *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); SetDlgItemText(hwndDlg, IDC_MESSAGE, (_tcslen(tmp) > 0)?_T("There is existing key for contact, would you like to replace with new key ?"):_T("New public key was received, do you want to import it?")); @@ -1013,6 +1020,11 @@ static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, DestroyWindow(hwndDlg); break; case WM_DESTROY: + { + GetWindowRect(hwndDlg, &new_key_rect); + DBWriteContactSettingDword(NULL, szGPGModuleName, "NewKeyWindowX", new_key_rect.left); + DBWriteContactSettingDword(NULL, szGPGModuleName, "NewKeyWindowY", new_key_rect.top); + } hwndNewKey = NULL; break; @@ -1025,6 +1037,7 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, { case WM_INITDIALOG: { + SetWindowPos(hwndDlg, 0, key_gen_rect.left, key_gen_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEY_TYPE), _T("RSA"), 0); ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEY_TYPE), _T("DSA"), 1); @@ -1308,6 +1321,11 @@ static BOOL CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, DestroyWindow(hwndDlg); break; case WM_DESTROY: + { + GetWindowRect(hwndDlg, &key_gen_rect); + DBWriteContactSettingDword(NULL, szGPGModuleName, "KeyGenWindowX", key_gen_rect.left); + DBWriteContactSettingDword(NULL, szGPGModuleName, "KeyGenWindowY", key_gen_rect.top); + } hwndKeyGen = NULL; break; @@ -1329,6 +1347,7 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam, { case WM_INITDIALOG: { + SetWindowPos(hwndDlg, 0, load_existing_key_rect.left, load_existing_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); col.pszText = _T("Key ID"); col.mask = LVCF_TEXT | LVCF_WIDTH; @@ -1515,6 +1534,11 @@ static BOOL CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wParam, DestroyWindow(hwndDlg); break; case WM_DESTROY: + { + GetWindowRect(hwndDlg, &load_existing_key_rect); + DBWriteContactSettingDword(NULL, szGPGModuleName, "LoadExistingKeyWindowX", load_existing_key_rect.left); + DBWriteContactSettingDword(NULL, szGPGModuleName, "LoadExistingKeyWindowY", load_existing_key_rect.top); + } hwndSelectExistingKey = NULL; break; @@ -1532,6 +1556,7 @@ static BOOL CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara { case WM_INITDIALOG: { + SetWindowPos(hwndDlg, 0 , import_key_rect.left, import_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), _T("subkeys.pgp.net"), 0); ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), _T("keys.gnupg.net"), 0); @@ -1593,6 +1618,11 @@ static BOOL CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wPara DestroyWindow(hwndDlg); break; case WM_DESTROY: + { + GetWindowRect(hwndDlg, &import_key_rect); + DBWriteContactSettingDword(NULL, szGPGModuleName, "ImportKeyWindowX", import_key_rect.left); + DBWriteContactSettingDword(NULL, szGPGModuleName, "ImportKeyWindowY", import_key_rect.top); + } break; } diff --git a/main.h b/main.h index 6478467..5b98750 100644 --- a/main.h +++ b/main.h @@ -24,6 +24,7 @@ struct contact_data extern std::map hcontact_data; extern bool bAutoExchange; +extern RECT key_from_keyserver_rect, firstrun_rect, new_key_rect, key_gen_rect, load_key_rect, import_key_rect, key_password_rect, load_existing_key_rect; #endif diff --git a/messages.cpp b/messages.cpp index 3601604..e8954e1 100644 --- a/messages.cpp +++ b/messages.cpp @@ -840,6 +840,7 @@ static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, L { case WM_INITDIALOG: { + SetWindowPos(hwndDlg, 0, key_password_rect.left, key_password_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); TranslateDialogDefault(hwndDlg); string questionstr = "Please enter password for key with ID: "; questionstr += inkeyid; @@ -909,6 +910,11 @@ static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, L DestroyWindow(hwndDlg); break; case WM_DESTROY: + { + GetWindowRect(hwndDlg, &key_password_rect); + DBWriteContactSettingDword(NULL, szGPGModuleName, "PasswordWindowX", key_password_rect.left); + DBWriteContactSettingDword(NULL, szGPGModuleName, "PasswordWindowY", key_password_rect.top); + } break; } diff --git a/new_gpg.vcxproj b/new_gpg.vcxproj index cc08297..39bdf92 100644 --- a/new_gpg.vcxproj +++ b/new_gpg.vcxproj @@ -1111,7 +1111,7 @@ Use - Use + NotUsing Use Use Use @@ -1129,7 +1129,7 @@ Use - Use + NotUsing Use Use Use @@ -1147,7 +1147,7 @@ Use - Use + NotUsing Use Use Use @@ -1165,7 +1165,7 @@ Create - Create + NotUsing Create Create commonheaders.h @@ -1187,7 +1187,7 @@ Use - Use + NotUsing Use Use Use @@ -1203,10 +1203,12 @@ c:\temp\new_gpg.pch c:\temp\new_gpg.pch - + + NotUsing + Use - Use + NotUsing Use Use Use @@ -1224,7 +1226,7 @@ Use - Use + NotUsing Use Use Use @@ -1242,7 +1244,7 @@ Use - Use + NotUsing Use Use Use @@ -1260,7 +1262,7 @@ Use - Use + NotUsing Use Use Use @@ -1278,7 +1280,7 @@ Use - Use + NotUsing Use Use Use @@ -1296,7 +1298,7 @@ Use - Use + NotUsing Use Use Use diff --git a/options.cpp b/options.cpp index c0debec..3ac57b9 100644 --- a/options.cpp +++ b/options.cpp @@ -639,6 +639,7 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP { case WM_INITDIALOG: { + SetWindowPos(hwndDlg, 0, load_key_rect.left, load_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW); HANDLE hcnt = hContact; if(metaIsProtoMetaContacts(hcnt)) hcnt = metaGetMostOnline(hcnt); @@ -1221,6 +1222,11 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP DestroyWindow(hwndDlg); break; case WM_DESTROY: + { + GetWindowRect(hwndDlg, &load_key_rect); + DBWriteContactSettingDword(NULL, szGPGModuleName, "LoadKeyWindowX", load_key_rect.left); + DBWriteContactSettingDword(NULL, szGPGModuleName, "LoadKeyWindowY", load_key_rect.top); + } break; } -- cgit v1.2.3