ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

finddlg.c
Go to the documentation of this file.
00001 /*
00002  *  Common Dialog Boxes interface (32 bit)
00003  *  Find/Replace
00004  *
00005  * Copyright 1998,1999 Bertho A. Stultiens
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00020  */
00021 
00022 #include <stdarg.h>
00023 #include <string.h>
00024 #include "windef.h"
00025 #include "winbase.h"
00026 #include "winnls.h"
00027 #include "wingdi.h"
00028 #include "winuser.h"
00029 #include "commdlg.h"
00030 #include "cderr.h"
00031 #include "dlgs.h"
00032 #include "wine/debug.h"
00033 
00034 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
00035 
00036 #include "cdlg.h"
00037 
00038 
00039 /*-----------------------------------------------------------------------*/
00040 
00041 static UINT     FindReplaceMessage;
00042 static UINT     HelpMessage;
00043 
00044 #define FR_MASK (FR_DOWN | FR_MATCHCASE | FR_WHOLEWORD | FR_REPLACEALL | FR_REPLACE | FR_FINDNEXT | FR_DIALOGTERM)
00045 /* CRITICAL_SECTION COMDLG32_CritSect; */
00046 
00047 /* Notes:
00048  * MS uses a critical section at a few locations. However, I fail to
00049  * see the reason for this. Their comdlg32.dll has a few race conditions
00050  * but _not_ at those places that are protected with the mutex (there are
00051  * globals that seem to hold info for the wndproc).
00052  *
00053  * FindText[AW]/ReplaceText[AW]
00054  * The find/replace calls are passed a structure that is _not_ used
00055  * internally. There is a local copy that holds the running info to
00056  * be able to combine xxxA and xxxW calls. The passed pointer is
00057  * returned upon sendmessage. Apps won't break this way when they rely
00058  * on the original pointer. This will work as long as the sizes of
00059  * FINDREPLACEA == FINDREPLACEW. The local copy will also prevent
00060  * the app to see the wine-specific extra flags to distinguish between
00061  * A/W and Find/Replace.
00062  */
00063 
00064 
00065 /***********************************************************************
00066  *  COMDLG32_FR_GetFlags            [internal]
00067  * Returns the button state that needs to be reported to the caller.
00068  *  RETURNS
00069  *      Current state of check and radio buttons
00070  */
00071 static DWORD COMDLG32_FR_GetFlags(HWND hDlgWnd)
00072 {
00073     DWORD flags = 0;
00074     if(IsDlgButtonChecked(hDlgWnd, rad2) == BST_CHECKED)
00075         flags |= FR_DOWN;
00076     if(IsDlgButtonChecked(hDlgWnd, chx1) == BST_CHECKED)
00077         flags |= FR_WHOLEWORD;
00078     if(IsDlgButtonChecked(hDlgWnd, chx2) == BST_CHECKED)
00079         flags |= FR_MATCHCASE;
00080         return flags;
00081 }
00082 
00083 /***********************************************************************
00084  *  COMDLG32_FR_HandleWMCommand     [internal]
00085  * Handle WM_COMMAND messages...
00086  */
00087 static void COMDLG32_FR_HandleWMCommand(HWND hDlgWnd, COMDLG32_FR_Data *pData, int Id, int NotifyCode)
00088 {
00089     DWORD flag;
00090 
00091     pData->user_fr.fra->Flags &= ~FR_MASK;  /* Clear return flags */
00092     if(pData->fr.Flags & FR_WINE_REPLACE)   /* Replace always goes down... */
00093         pData->user_fr.fra->Flags |= FR_DOWN;
00094 
00095     if(NotifyCode == BN_CLICKED)
00096         {
00097         switch(Id)
00098         {
00099         case IDOK: /* Find Next */
00100             if(GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
00101                         {
00102                 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_FINDNEXT;
00103                                 if(pData->fr.Flags & FR_WINE_UNICODE)
00104                                 {
00105                                     MultiByteToWideChar( CP_ACP, 0, pData->fr.lpstrFindWhat, -1,
00106                                                          pData->user_fr.frw->lpstrFindWhat,
00107                                                          0x7fffffff );
00108                                 }
00109                                 else
00110                                 {
00111                     strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
00112                                 }
00113                 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
00114                         }
00115             break;
00116 
00117         case IDCANCEL:
00118             pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | FR_DIALOGTERM;
00119             SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
00120                 DestroyWindow(hDlgWnd);
00121             break;
00122 
00123                 case psh2: /* Replace All */
00124             flag = FR_REPLACEALL;
00125                         goto Replace;
00126 
00127                 case psh1: /* Replace */
00128             flag = FR_REPLACE;
00129 Replace:
00130             if((pData->fr.Flags & FR_WINE_REPLACE)
00131                         && GetDlgItemTextA(hDlgWnd, edt1, pData->fr.lpstrFindWhat, pData->fr.wFindWhatLen) > 0)
00132                         {
00133                 pData->fr.lpstrReplaceWith[0] = 0; /* In case the next GetDlgItemText Fails */
00134                 GetDlgItemTextA(hDlgWnd, edt2, pData->fr.lpstrReplaceWith, pData->fr.wReplaceWithLen);
00135                 pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd) | flag;
00136                                 if(pData->fr.Flags & FR_WINE_UNICODE)
00137                                 {
00138                                     MultiByteToWideChar( CP_ACP, 0, pData->fr.lpstrFindWhat, -1,
00139                                                          pData->user_fr.frw->lpstrFindWhat,
00140                                                          0x7fffffff );
00141                                     MultiByteToWideChar( CP_ACP, 0, pData->fr.lpstrReplaceWith, -1,
00142                                                          pData->user_fr.frw->lpstrReplaceWith,
00143                                                          0x7fffffff );
00144                                 }
00145                                 else
00146                                 {
00147                     strcpy(pData->user_fr.fra->lpstrFindWhat, pData->fr.lpstrFindWhat);
00148                     strcpy(pData->user_fr.fra->lpstrReplaceWith, pData->fr.lpstrReplaceWith);
00149                                 }
00150                 SendMessageA(pData->fr.hwndOwner, FindReplaceMessage, 0, (LPARAM)pData->user_fr.fra);
00151                         }
00152             break;
00153 
00154         case pshHelp:
00155             pData->user_fr.fra->Flags |= COMDLG32_FR_GetFlags(hDlgWnd);
00156             SendMessageA(pData->fr.hwndOwner, HelpMessage, (WPARAM)hDlgWnd, (LPARAM)pData->user_fr.fra);
00157             break;
00158                 }
00159         }
00160         else if(NotifyCode == EN_CHANGE && Id == edt1)
00161     {
00162         BOOL enable = SendDlgItemMessageA(hDlgWnd, edt1, WM_GETTEXTLENGTH, 0, 0) > 0;
00163         EnableWindow(GetDlgItem(hDlgWnd, IDOK), enable);
00164                 if(pData->fr.Flags & FR_WINE_REPLACE)
00165                 {
00166             EnableWindow(GetDlgItem(hDlgWnd, psh1), enable);
00167             EnableWindow(GetDlgItem(hDlgWnd, psh2), enable);
00168                 }
00169     }
00170 }
00171 
00172 /***********************************************************************
00173  *  COMDLG32_FindReplaceDlgProc     [internal]
00174  * [Find/Replace]Text32[A/W] window procedure.
00175  */
00176 static INT_PTR CALLBACK COMDLG32_FindReplaceDlgProc(HWND hDlgWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
00177 {
00178     COMDLG32_FR_Data *pdata = GetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
00179     INT_PTR retval = TRUE;
00180 
00181     if(iMsg == WM_INITDIALOG)
00182         {
00183                 pdata = (COMDLG32_FR_Data *)lParam;
00184         if(!SetPropA(hDlgWnd, (LPSTR)COMDLG32_Atom, (HANDLE)pdata))
00185                 {
00186             ERR("Could not Set prop; invent a graceful exit?...\n");
00187             DestroyWindow(hDlgWnd);
00188                         return FALSE;
00189                 }
00190                SendDlgItemMessageA(hDlgWnd, edt1, EM_SETLIMITTEXT, pdata->fr.wFindWhatLen, 0);
00191             SendDlgItemMessageA(hDlgWnd, edt1, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrFindWhat);
00192                 if(pdata->fr.Flags & FR_WINE_REPLACE)
00193                 {
00194                        SendDlgItemMessageA(hDlgWnd, edt2, EM_SETLIMITTEXT, pdata->fr.wReplaceWithLen, 0);
00195                 SendDlgItemMessageA(hDlgWnd, edt2, WM_SETTEXT, 0, (LPARAM)pdata->fr.lpstrReplaceWith);
00196                 }
00197 
00198         if(!(pdata->fr.Flags & FR_SHOWHELP))
00199             ShowWindow(GetDlgItem(hDlgWnd, pshHelp), SW_HIDE);
00200             if(pdata->fr.Flags & FR_HIDEUPDOWN)
00201         {
00202             ShowWindow(GetDlgItem(hDlgWnd, rad1), SW_HIDE);
00203             ShowWindow(GetDlgItem(hDlgWnd, rad2), SW_HIDE);
00204             ShowWindow(GetDlgItem(hDlgWnd, grp1), SW_HIDE);
00205             }
00206         else if(pdata->fr.Flags & FR_NOUPDOWN)
00207             {
00208             EnableWindow(GetDlgItem(hDlgWnd, rad1), FALSE);
00209             EnableWindow(GetDlgItem(hDlgWnd, rad2), FALSE);
00210             EnableWindow(GetDlgItem(hDlgWnd, grp1), FALSE);
00211         }
00212                 else
00213                 {
00214             SendDlgItemMessageA(hDlgWnd, rad1, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? 0 : BST_CHECKED, 0);
00215             SendDlgItemMessageA(hDlgWnd, rad2, BM_SETCHECK, pdata->fr.Flags & FR_DOWN ? BST_CHECKED : 0, 0);
00216                 }
00217 
00218             if(pdata->fr.Flags & FR_HIDEMATCHCASE)
00219             ShowWindow(GetDlgItem(hDlgWnd, chx2), SW_HIDE);
00220         else if(pdata->fr.Flags & FR_NOMATCHCASE)
00221             EnableWindow(GetDlgItem(hDlgWnd, chx2), FALSE);
00222                 else
00223             SendDlgItemMessageA(hDlgWnd, chx2, BM_SETCHECK, pdata->fr.Flags & FR_MATCHCASE ? BST_CHECKED : 0, 0);
00224 
00225             if(pdata->fr.Flags & FR_HIDEWHOLEWORD)
00226             ShowWindow(GetDlgItem(hDlgWnd, chx1), SW_HIDE);
00227         else if(pdata->fr.Flags & FR_NOWHOLEWORD)
00228             EnableWindow(GetDlgItem(hDlgWnd, chx1), FALSE);
00229                 else
00230             SendDlgItemMessageA(hDlgWnd, chx1, BM_SETCHECK, pdata->fr.Flags & FR_WHOLEWORD ? BST_CHECKED : 0, 0);
00231 
00232         /* We did the init here, now call the hook if requested */
00233 
00234         /* We do not do ShowWindow if hook exists and is FALSE  */
00235         /*   per MSDN Article Q96135                            */
00236         if((pdata->fr.Flags & FR_ENABLEHOOK)
00237                  && ! pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, (LPARAM) &pdata->fr))
00238                 return TRUE;
00239         ShowWindow(hDlgWnd, SW_SHOWNORMAL);
00240         UpdateWindow(hDlgWnd);
00241                 return TRUE;
00242         }
00243 
00244     if(pdata && (pdata->fr.Flags & FR_ENABLEHOOK))
00245     {
00246         retval = pdata->fr.lpfnHook(hDlgWnd, iMsg, wParam, lParam);
00247     }
00248     else
00249         retval = FALSE;
00250 
00251     if(pdata && !retval)
00252         {
00253         retval = TRUE;
00254         switch(iMsg)
00255         {
00256             case WM_COMMAND:
00257             COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, LOWORD(wParam), HIWORD(wParam));
00258             break;
00259 
00260             case WM_CLOSE:
00261             COMDLG32_FR_HandleWMCommand(hDlgWnd, pdata, IDCANCEL, BN_CLICKED);
00262             break;
00263 
00264             case WM_HELP:
00265             /* Heeeeelp! */
00266             FIXME("Got WM_HELP. Who is gonna supply it?\n");
00267                     break;
00268 
00269         case WM_CONTEXTMENU:
00270             /* Heeeeelp! */
00271             FIXME("Got WM_CONTEXTMENU. Who is gonna supply it?\n");
00272                 break;
00273         /* FIXME: Handle F1 help */
00274 
00275             default:
00276                 retval = FALSE; /* We did not handle the message */
00277             }
00278         }
00279 
00280         /* WM_DESTROY is a special case.
00281          * We need to ensure that the allocated memory is freed just before
00282          * the dialog is killed. We also need to remove the added prop.
00283          */
00284         if(iMsg == WM_DESTROY)
00285         {
00286         RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
00287         HeapFree(GetProcessHeap(), 0, pdata);
00288         }
00289 
00290         return retval;
00291 }
00292 
00293 /***********************************************************************
00294  *  COMDLG32_FR_CheckPartial        [internal]
00295  * Check various fault conditions in the supplied parameters that
00296  * cause an extended error to be reported.
00297  *  RETURNS
00298  *      TRUE: Success
00299  *      FALSE: Failure
00300  */
00301 static BOOL COMDLG32_FR_CheckPartial(
00302     const FINDREPLACEA *pfr,    /* [in] Find structure */
00303     BOOL Replace            /* [in] True if called as replace */
00304 ) {
00305     if(!pfr)
00306         {
00307         COMDLG32_SetCommDlgExtendedError(CDERR_INITIALIZATION);
00308                 return FALSE;
00309     }
00310 
00311         if(pfr->lStructSize != sizeof(FINDREPLACEA))
00312         {
00313         COMDLG32_SetCommDlgExtendedError(CDERR_STRUCTSIZE);
00314         return FALSE;
00315         }
00316 
00317         if(!IsWindow(pfr->hwndOwner))
00318         {
00319         COMDLG32_SetCommDlgExtendedError(CDERR_DIALOGFAILURE);
00320         return FALSE;
00321         }
00322 
00323     if((pfr->wFindWhatLen < 1 || !pfr->lpstrFindWhat)
00324         ||(Replace && !pfr->lpstrReplaceWith))
00325         {
00326         COMDLG32_SetCommDlgExtendedError(FRERR_BUFFERLENGTHZERO);
00327                 return FALSE;
00328         }
00329 
00330     if((FindReplaceMessage = RegisterWindowMessageA(FINDMSGSTRINGA)) == 0)
00331         {
00332         COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
00333                 return FALSE;
00334         }
00335     if((HelpMessage = RegisterWindowMessageA(HELPMSGSTRINGA)) == 0)
00336         {
00337         COMDLG32_SetCommDlgExtendedError(CDERR_REGISTERMSGFAIL);
00338                 return FALSE;
00339         }
00340 
00341         if((pfr->Flags & FR_ENABLEHOOK) && !pfr->lpfnHook)
00342         {
00343         COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);
00344                 return FALSE;
00345         }
00346 
00347         if((pfr->Flags & FR_ENABLETEMPLATEHANDLE) && !pfr->hInstance)
00348         {
00349         COMDLG32_SetCommDlgExtendedError(CDERR_NOHINSTANCE);
00350                 return FALSE;
00351         }
00352 
00353     return TRUE;
00354 }
00355 
00356 /***********************************************************************
00357  *  COMDLG32_FR_DoFindReplace       [internal]
00358  * Actual load and creation of the Find/Replace dialog.
00359  *  RETURNS
00360  *      Window handle to created dialog:Success
00361  *      NULL:Failure
00362  */
00363 static HWND COMDLG32_FR_DoFindReplace(
00364     COMDLG32_FR_Data *pdata /* [in] Internal data structure */
00365 ) {
00366     HWND hdlgwnd = 0;
00367         HGLOBAL loadrc;
00368         DWORD error;
00369         LPDLGTEMPLATEW rcs;
00370 
00371     TRACE("hInst=%p, Flags=%08x\n", pdata->fr.hInstance, pdata->fr.Flags);
00372 
00373         if(!(pdata->fr.Flags & FR_ENABLETEMPLATEHANDLE))
00374         {
00375             HMODULE hmod = COMDLG32_hInstance;
00376         HRSRC htemplate;
00377         if(pdata->fr.Flags & FR_ENABLETEMPLATE)
00378             {
00379             hmod = pdata->fr.hInstance;
00380                         if(pdata->fr.Flags & FR_WINE_UNICODE)
00381                         {
00382                 htemplate = FindResourceW(hmod, (LPCWSTR)pdata->fr.lpTemplateName, (LPWSTR)RT_DIALOG);
00383                         }
00384                         else
00385                         {
00386                 htemplate = FindResourceA(hmod, pdata->fr.lpTemplateName, (LPCSTR)RT_DIALOG);
00387                         }
00388         }
00389         else
00390         {
00391             int rcid = pdata->fr.Flags & FR_WINE_REPLACE ? REPLACEDLGORD
00392                                      : FINDDLGORD;
00393             htemplate = FindResourceA(hmod, MAKEINTRESOURCEA(rcid), (LPCSTR)RT_DIALOG);
00394         }
00395         if(!htemplate)
00396             {
00397             error = CDERR_FINDRESFAILURE;
00398             goto cleanup;
00399         }
00400 
00401             loadrc = LoadResource(hmod, htemplate);
00402         }
00403         else
00404         {
00405                 loadrc = pdata->fr.hInstance;
00406         }
00407 
00408         if(!loadrc)
00409         {
00410         error = CDERR_LOADRESFAILURE;
00411         goto cleanup;
00412     }
00413 
00414         if((rcs = LockResource(loadrc)) == NULL)
00415         {
00416         error = CDERR_LOCKRESFAILURE;
00417         goto cleanup;
00418         }
00419 
00420         hdlgwnd = CreateDialogIndirectParamA(COMDLG32_hInstance,
00421                          rcs,
00422                                              pdata->fr.hwndOwner,
00423                                              COMDLG32_FindReplaceDlgProc,
00424                                              (LPARAM)pdata);
00425     if(!hdlgwnd)
00426         {
00427         error = CDERR_DIALOGFAILURE;
00428 cleanup:
00429         COMDLG32_SetCommDlgExtendedError(error);
00430                 HeapFree(GetProcessHeap(), 0, pdata);
00431         }
00432         return hdlgwnd;
00433 }
00434 
00435 /***********************************************************************
00436  *  FindTextA               [COMDLG32.@]
00437  *
00438  * See FindTextW.
00439  */
00440 HWND WINAPI FindTextA(
00441     LPFINDREPLACEA pfr  /* [in] Find/replace structure*/
00442 ) {
00443     COMDLG32_FR_Data *pdata;
00444 
00445         TRACE("LPFINDREPLACE=%p\n", pfr);
00446 
00447     if(!COMDLG32_FR_CheckPartial(pfr, FALSE))
00448         return 0;
00449 
00450         if((pdata = COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
00451         return 0; /* Error has been set */
00452 
00453         pdata->user_fr.fra = pfr;
00454         pdata->fr = *pfr;
00455     return COMDLG32_FR_DoFindReplace(pdata);
00456 }
00457 
00458 /***********************************************************************
00459  *  ReplaceTextA                [COMDLG32.@]
00460  *
00461  * See ReplaceTextW.
00462  */
00463 HWND WINAPI ReplaceTextA(
00464     LPFINDREPLACEA pfr  /* [in] Find/replace structure*/
00465 ) {
00466     COMDLG32_FR_Data *pdata;
00467 
00468         TRACE("LPFINDREPLACE=%p\n", pfr);
00469 
00470     if(!COMDLG32_FR_CheckPartial(pfr, TRUE))
00471         return 0;
00472 
00473         if((pdata = COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data))) == NULL)
00474         return 0; /* Error has been set */
00475 
00476         pdata->user_fr.fra = pfr;
00477         pdata->fr = *pfr;
00478     pdata->fr.Flags |= FR_WINE_REPLACE;
00479     return COMDLG32_FR_DoFindReplace(pdata);
00480 }
00481 
00482 /***********************************************************************
00483  *  FindTextW               [COMDLG32.@]
00484  *
00485  * Create a modeless find-text dialog box.
00486  *
00487  *  RETURNS
00488  *      Window handle to created dialog: Success
00489  *      NULL: Failure
00490  */
00491 HWND WINAPI FindTextW(
00492     LPFINDREPLACEW pfr  /* [in] Find/replace structure*/
00493 ) {
00494     COMDLG32_FR_Data *pdata;
00495         DWORD len;
00496 
00497         TRACE("LPFINDREPLACE=%p\n", pfr);
00498 
00499     if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, FALSE))
00500         return 0;
00501 
00502         len = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
00503                                    NULL, 0, NULL, NULL );
00504         if((pdata = COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data) + len)) == NULL)
00505                 return 0; /* Error has been set */
00506 
00507         pdata->user_fr.frw = pfr;
00508         pdata->fr = *(LPFINDREPLACEA)pfr;   /* FINDREPLACEx have same size */
00509     pdata->fr.Flags |= FR_WINE_UNICODE;
00510         pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1);  /* Set string pointer */
00511         WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
00512                              pdata->fr.lpstrFindWhat, len, NULL, NULL );
00513         return COMDLG32_FR_DoFindReplace(pdata);
00514 }
00515 
00516 /***********************************************************************
00517  *  ReplaceTextW                [COMDLG32.@]
00518  *
00519  * Create a modeless replace-text dialog box.
00520  *
00521  *  RETURNS
00522  *      Window handle to created dialog: Success
00523  *      NULL: Failure
00524  */
00525 HWND WINAPI ReplaceTextW(
00526     LPFINDREPLACEW pfr  /* [in] Find/replace structure*/
00527 ) {
00528     COMDLG32_FR_Data *pdata;
00529         DWORD len1, len2;
00530 
00531         TRACE("LPFINDREPLACE=%p\n", pfr);
00532 
00533     if(!COMDLG32_FR_CheckPartial((LPFINDREPLACEA)pfr, TRUE))
00534         return 0;
00535 
00536         len1 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
00537                                     NULL, 0, NULL, NULL );
00538         len2 = WideCharToMultiByte( CP_ACP, 0, pfr->lpstrReplaceWith, pfr->wReplaceWithLen,
00539                                     NULL, 0, NULL, NULL );
00540         if((pdata = COMDLG32_AllocMem(sizeof(COMDLG32_FR_Data) + len1 + len2)) == NULL)
00541                 return 0; /* Error has been set */
00542 
00543         pdata->user_fr.frw = pfr;
00544         pdata->fr = *(LPFINDREPLACEA)pfr;   /* FINDREPLACEx have same size */
00545     pdata->fr.Flags |= FR_WINE_REPLACE | FR_WINE_UNICODE;
00546         pdata->fr.lpstrFindWhat = (LPSTR)(pdata + 1);  /* Set string pointer */
00547         pdata->fr.lpstrReplaceWith = pdata->fr.lpstrFindWhat + len1;
00548 
00549         WideCharToMultiByte( CP_ACP, 0, pfr->lpstrFindWhat, pfr->wFindWhatLen,
00550                              pdata->fr.lpstrFindWhat, len1, NULL, NULL );
00551         WideCharToMultiByte( CP_ACP, 0, pfr->lpstrReplaceWith, pfr->wReplaceWithLen,
00552                              pdata->fr.lpstrReplaceWith, len2, NULL, NULL );
00553         return COMDLG32_FR_DoFindReplace(pdata);
00554 }

Generated on Sat May 26 2012 04:21:42 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.