From 6dc7a289ccf1567a87dfca66a86ace0f509621ff Mon Sep 17 00:00:00 2001
From: Elias Benali elptr@users.sourceforge.net Date: Sat, 25 Oct 2008 21:09:27 -0400 Subject: wordpad: Make the Replace function work and the Find/Replace dialogs behave like expected.
The "Find What" field is filled from the current selection in the document, if any. --- programs/wordpad/wordpad.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index d06b2d9..434b6fd 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -49,6 +49,10 @@ # define U3(x) (x) #endif
+#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + /* use LoadString */ static const WCHAR wszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
@@ -1281,12 +1285,29 @@ static LRESULT handle_findmsg(LPFINDREPLACEW pFr) static void dialog_find(LPFINDREPLACEW fr, BOOL replace) { static WCHAR findBuffer[MAX_STRING_LEN]; + static WCHAR replaceBuffer[MAX_STRING_LEN]; + CHARRANGE cr; + TEXTRANGE tr; + + SendMessage(hEditorWnd, EM_EXGETSEL, 0, (LPARAM)&cr); + if (cr.cpMax > cr.cpMin) { + cr.cpMax = cr.cpMin + MIN(sizeof(findBuffer)/sizeof(WCHAR)-1, cr.cpMax-cr.cpMin); + tr.chrg = cr; + tr.lpstrText = (LPSTR)findBuffer; + SendMessage(hEditorWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + } else + findBuffer[0] = '\0'; + + replaceBuffer[0] = '\0';
ZeroMemory(fr, sizeof(FINDREPLACEW)); fr->lStructSize = sizeof(FINDREPLACEW); fr->hwndOwner = hMainWnd; fr->Flags = FR_HIDEUPDOWN; fr->lpstrFindWhat = findBuffer; + fr->wFindWhatLen = sizeof(findBuffer); + fr->wReplaceWithLen = sizeof(replaceBuffer); /* ignored by FindTextW() */ + fr->lpstrReplaceWith = replaceBuffer; /* ignored by FindTextW() */ fr->lCustData = -1; fr->wFindWhatLen = MAX_STRING_LEN*sizeof(WCHAR);
Hi Elias,
Please don't send mail to wine-devel and wine-patches at the same time, if you want feedback, send it to wine-devel, if you want it committed, send it to wine-patches
Elias Benali schreef:
diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index d06b2d9..434b6fd 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -49,6 +49,10 @@ # define U3(x) (x) #endif
+#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif
/* use LoadString */ static const WCHAR wszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
Considering you only use this macro once, wouldn't it be better to just expand MIN?
Cheers, Maarten.
"Maarten Lankhorst" m.b.lankhorst@gmail.com wrote:
+#ifndef MIN +# define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif
/* use LoadString */ static const WCHAR wszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
Considering you only use this macro once, wouldn't it be better to just expand MIN?
There is no need to introduce MIN/MAX at all, windef.h provides min/max (notice lower case) already.