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/findwindow.cpp | 96 +++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'dbeditorpp/findwindow.cpp') diff --git a/dbeditorpp/findwindow.cpp b/dbeditorpp/findwindow.cpp index fc478ee..b9957cd 100644 --- a/dbeditorpp/findwindow.cpp +++ b/dbeditorpp/findwindow.cpp @@ -53,12 +53,12 @@ void freeItems(HWND hwnd) ii = (ItemInfo*)SendMessage(hwnd,LB_GETITEMDATA,i,0); if ((LRESULT)ii != LB_ERR) - safe_free(ii); + mir_free(ii); } } -BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { @@ -71,22 +71,22 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara CheckDlgButton(hwnd,IDC_SETTINGVALUE,1); CheckDlgButton(hwnd,IDC_FOUND,1); SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); - SetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA, 0); - SetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA, 0); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA, 0); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA, 0); } return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: - SetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA, 1); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA, 1); case IDC_SEARCH: { - if (GetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA)) // stop the search + if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA)) // stop the search { - SetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA,0); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA,0); } else { @@ -95,10 +95,10 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara char text[256]; char replace[256]=""; - if (!GetDlgItemText(hwnd,IDC_TEXT,text,sizeof(text))) break; + if (!GetDlgItemText(hwnd,IDC_TEXT,text,SIZEOF(text))) break; - if (GetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA) && - !GetDlgItemText(hwnd,IDC_REPLACE,replace,sizeof(replace)) && + if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA) && + !GetDlgItemText(hwnd,IDC_REPLACE,replace,SIZEOF(replace)) && !IsDlgButtonChecked(hwnd,IDC_ENTIRELY)) break; @@ -107,7 +107,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara !IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE) ) break; - fi = (FindInfo*)calloc(sizeof(FindInfo),1); + fi = (FindInfo*)mir_calloc(sizeof(FindInfo)); if (!fi) break; fi->hwnd = GetDlgItem(hwnd,IDC_LIST); @@ -117,7 +117,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME)?FW_SETNAME:0)| (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE)?FW_SETVAL:0); - if (GetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA)) + if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA)) { if (IsDlgButtonChecked(hwnd,IDC_FOUND)) fi->mode = RW_FOUND; @@ -134,7 +134,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (IsDlgButtonChecked(hwnd,IDC_ENTIRELY)) fi->mode |= RW_FULL; - fi->replace = strdup(replace); + fi->replace = mir_tstrdup(replace); SetWindowText(GetDlgItem(hwnd,IDOK),Translate("Stop")); EnableWindow(GetDlgItem(hwnd,IDC_SEARCH),0); @@ -148,10 +148,10 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara EnableWindow(GetDlgItem(hwnd,IDOK),0); } - fi->text = strdup(text); + fi->text = mir_tstrdup(text); SendDlgItemMessage(hwnd,IDC_LIST,LB_RESETCONTENT,0,0); - SetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA,1); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA,1); EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); forkthread(FindSettings,0,fi); @@ -201,7 +201,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting,const char* value,int type) { - ItemInfo *ii = (ItemInfo*)calloc(sizeof(ItemInfo),1); + ItemInfo *ii = (ItemInfo*)mir_calloc(sizeof(ItemInfo)); int index; char text[256] = ""; int result = 0; @@ -224,20 +224,20 @@ void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting { case FW_MODULE: ii->type = FW_MODULE; - mir_snprintf(text,256,Translate("%s Module \"%s\" in contact \"%s\""),mode,module,name); + mir_snprintf(text, SIZEOF(text), Translate("%s Module \"%s\" in contact \"%s\""), mode, module, name); break; case FW_SETTINGNAME: mir_strncpy(ii->setting,setting,256); ii->type = FW_SETTINGNAME; - if (GetValue(hContact,module,setting, szValue, sizeof(szValue))) - mir_snprintf(text,256,Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""),mode,setting,module,name,szValue); + if (GetValue(hContact,module,setting, szValue, SIZEOF(szValue))) + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""), mode, setting, module, name, szValue); else - mir_snprintf(text,256,Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""),mode,setting,module,name); + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, setting, module, name); break; case FW_SETTINGVALUE: mir_strncpy(ii->setting,setting,256); ii->type = FW_SETTINGVALUE; - mir_snprintf(text,256,Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""),mode,value,setting,module,name); + mir_snprintf(text, SIZEOF(text), Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, value, setting, module, name); break; } @@ -245,7 +245,7 @@ void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting if (type & FW_DELETED) { SendMessage(hwnd,LB_SETITEMDATA,index,0); - safe_free(ii); + mir_free(ii); } else { @@ -260,19 +260,19 @@ char *multiReplace(const char* value, const char *find, const char *replace, int { char *head, *temp, *string; - int len = strlen(find); - int replen = strlen(replace); + int len = (int)strlen(find); + int replen = (int)strlen(replace); - if (head = (cs?strstr(value, find):StrStrI(value, find))) // only should be 1 '=' sign there... + if (head = (char*)(cs?strstr(value, find):StrStrI(value, find))) // only should be 1 '=' sign there... { string = (char*)value; - temp = (char*)malloc(1); + temp = (char*)mir_alloc(1*sizeof(char)); temp[0] = '\0'; while (head) { - temp = (char*)realloc(temp, strlen(temp) + strlen(string) + replen + 1); - if (!temp) _strdup(value); + temp = (char*)mir_realloc(temp, strlen(temp) + strlen(string) + replen + 1); + if (!temp) mir_tstrdup(value); strncat(temp, string, (head - string)); string = head + len; @@ -285,7 +285,7 @@ char *multiReplace(const char* value, const char *find, const char *replace, int return temp; } - return _strdup(value); + return mir_tstrdup(value); } @@ -354,7 +354,7 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set { ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); DBDeleteContactSetting(hContact,module,setting); - safe_free(myreplace); + mir_free(myreplace); return 1; } @@ -364,7 +364,7 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set ItemFound(hwnd,hContact,module,setting,myreplace?myreplace:(char*)replace,FW_SETTINGVALUE|FW_REPLACED); } - safe_free(myreplace); + mir_free(myreplace); return count; } @@ -391,7 +391,7 @@ int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *s { ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); DBDeleteContactSetting(hContact,module,setting); - safe_free(myreplace); + mir_free(myreplace); return 1; } @@ -417,7 +417,7 @@ int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *s else DBFreeVariant(&dbv2); - safe_free(myreplace); + mir_free(myreplace); return count; } @@ -445,7 +445,7 @@ int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *fi ItemFound(hwnd,hContact,module,NULL,NULL,FW_MODULE|FW_DELETED); deleteModule((char*)module, hContact, 1); replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, NULL); - safe_free(myreplace); + mir_free(myreplace); return 1; } @@ -498,7 +498,7 @@ int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *fi count++; } - safe_free(myreplace); + mir_free(myreplace); return count; } @@ -547,7 +547,7 @@ void __cdecl FindSettings(LPVOID di) freeItems(hwnd); if (!text) return; - if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"),modFullname); safe_free(di); return;} + if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"),modFullname); mir_free(di); return;} SendMessage(GetDlgItem(GetParent(hwnd),IDC_SBAR),SB_SETTEXT,0,(LPARAM)Translate("Searching...")); @@ -555,7 +555,7 @@ void __cdecl FindSettings(LPVOID di) isNumber = sscanf(text,"%d",&settingValue); - while (GetWindowLong(GetDlgItem(prnthwnd,IDC_SEARCH),GWL_USERDATA)) + while (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA)) { if (!hContact) { @@ -580,8 +580,8 @@ void __cdecl FindSettings(LPVOID di) if (!EnumSettings(hContact,module->name,&SettingList)) { msg(Translate("Error Loading Setting List"),modFullname); - safe_free(text); - safe_free(di); + mir_free(text); + mir_free(di); FreeModuleSettingLL(&ModuleList); return; } @@ -692,20 +692,20 @@ void __cdecl FindSettings(LPVOID di) if (mode) { if (!replace[0]) - _snprintf(szTmp,sizeof(szTmp),Translate("Finished. %d items were found, %d items were deleted."),foundCount, replaceCount); + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were deleted."), foundCount, replaceCount); else - _snprintf(szTmp,sizeof(szTmp),Translate("Finished. %d items were found, %d items were replaced."),foundCount, replaceCount); + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were replaced."), foundCount, replaceCount); } else - _snprintf(szTmp,sizeof(szTmp),Translate("Finished. %d items were found."),foundCount); + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found."), foundCount); SendMessage(GetDlgItem(prnthwnd,IDC_SBAR),SB_SETTEXT,0,(LPARAM)szTmp); - SetWindowLong(GetDlgItem(prnthwnd,IDC_SEARCH),GWL_USERDATA,0); + SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA,0); - if (GetWindowLong(GetDlgItem(prnthwnd,IDC_REPLACE),GWL_USERDATA)) + if (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA)) { - SetWindowLong(GetDlgItem(prnthwnd,IDC_REPLACE),GWL_USERDATA, 0); + SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA, 0); EnableWindow(GetDlgItem(prnthwnd,IDC_SEARCH),1); SetWindowText(GetDlgItem(prnthwnd,IDOK),Translate("&Replace")); } @@ -715,9 +715,9 @@ void __cdecl FindSettings(LPVOID di) EnableWindow(GetDlgItem(prnthwnd,IDOK),1); } - safe_free(replace); - safe_free(text); - safe_free(di); + mir_free(replace); + mir_free(text); + mir_free(di); FreeModuleSettingLL(&ModuleList); EnableWindow(GetDlgItem(prnthwnd,IDCANCEL),1); -- cgit v1.2.3