diff options
Diffstat (limited to 'dbeditorpp/addeditsettingsdlg.cpp')
-rw-r--r-- | dbeditorpp/addeditsettingsdlg.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
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; j<len; j++)
{
- _snprintf(tmp, sizeof(tmp), "%02X ", (BYTE)p[j]);
+ mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)p[j]);
strcat(data, tmp);
}
@@ -299,12 +299,12 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL))
{
sscanf(setting, "%X", &tmp);
- mir_snprintf(temp, 32, "%ld", tmp);
+ mir_snprintf(temp, SIZEOF(temp), "%ld", tmp);
}
else
{
sscanf(setting, "%d", &tmp);
- mir_snprintf(temp, 32, "%X", tmp);
+ mir_snprintf(temp, SIZEOF(temp), "%X", tmp);
}
SetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), temp);
}
@@ -313,7 +313,7 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar break;
case IDOK:
{
- struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLong(hwnd,GWL_USERDATA);
+ struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA);
char *setting, *value;
int settingLength, valueLength, valueID = IDC_SETTINGVALUE;
settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGNAME));
@@ -356,7 +356,7 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (valueLength)
{
if (dbsetting->dbv.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 |