From 2ebb53adcd4663ac2f1da74972b7b21d53b0ce53 Mon Sep 17 00:00:00 2001 From: "george.hazan" Date: Thu, 26 May 2011 20:18:42 +0000 Subject: patch for dbeditorpp: C++ support, other improvements git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@122 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- dbeditorpp/addeditsettingsdlg.cpp | 50 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'dbeditorpp/addeditsettingsdlg.cpp') diff --git a/dbeditorpp/addeditsettingsdlg.cpp b/dbeditorpp/addeditsettingsdlg.cpp index c0bfb7c..6c21fe4 100644 --- a/dbeditorpp/addeditsettingsdlg.cpp +++ b/dbeditorpp/addeditsettingsdlg.cpp @@ -56,8 +56,8 @@ BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType) // case DBVT_ASCIIZ: if (toType == 4) // convert to UNICODE { - int len = strlen(dbv.pszVal)+1; - WCHAR *wc = _alloca(len*sizeof(WCHAR)); + int len = (int)strlen(dbv.pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); Result = !DBWriteContactSettingWString(hContact, module, setting, wc); } @@ -74,9 +74,9 @@ BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType) // case DBVT_UTF8: if (toType == 3 && UOS) // convert to ANSI { - int len = strlen(dbv.pszVal)+1; - char *sz = _alloca(len*3); - WCHAR *wc = _alloca(len*sizeof(WCHAR)); + int len = (int)strlen(dbv.pszVal) + 1; + char *sz = (char*)_alloca(len*3); + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); Result = !DBWriteContactSettingString(hContact, module, setting, sz); @@ -108,14 +108,14 @@ int saveAsType(HWND hwnd) } -BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { char tmp[32]; - SetWindowLong(hwnd,GWL_USERDATA,(LPARAM)lParam); + SetWindowLongPtr(hwnd,GWLP_USERDATA,(LPARAM)lParam); switch (((struct DBsetting*)lParam)->dbv.type) { case DBVT_BYTE: @@ -159,7 +159,7 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar char text[32]; SetWindowText(hwnd, Translate("Edit DWORD value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - mir_snprintf(text, 32, "%X", ((struct DBsetting*)lParam)->dbv.dVal); + mir_snprintf(text, SIZEOF(text), "%X", ((struct DBsetting*)lParam)->dbv.dVal); SetDlgItemText(hwnd, IDC_SETTINGVALUE, text); } CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_HEX); @@ -207,10 +207,10 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); if (UOS) { - int length = strlen(tmp)+1; - WCHAR *wc = _alloca(length*sizeof(WCHAR)); + int length = (int)strlen(tmp) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); - _SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); + SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); } else { // convert from UTF8 @@ -243,7 +243,7 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar for(j=0; jdbv.type == DBVT_UTF8 && UOS) - _SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); + SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); else GetWindowText(GetDlgItem(hwnd, valueID), value, valueLength+1); } @@ -425,10 +425,10 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } // fall through case IDCANCEL: { - struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLong(hwnd,GWL_USERDATA); - safe_free(dbsetting->module); - safe_free(dbsetting->setting); - safe_free(dbsetting); + struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + mir_free(dbsetting->module); + mir_free(dbsetting->setting); + mir_free(dbsetting); DestroyWindow(hwnd); } break; @@ -443,16 +443,16 @@ void editSetting(HANDLE hContact, char* module, char* setting) DBVARIANT dbv = {0}; // freed in the dialog if (!GetSetting(hContact,module, setting, &dbv)) { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets free()ed in the window proc dbsetting->dbv = dbv; // freed in the dialog dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(setting); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(setting); if (dbv.type == DBVT_UTF8 && UOS) - _CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd2mainWindow,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); else - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd2mainWindow,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); } } \ No newline at end of file -- cgit v1.2.3