From: Franz Bachler on
I've compiled the editor example from the book Ch. Petzold "The definitive
Guide to the Win32 API" and it works. But:

The find (also replace) dialog is unable to find or replace in up direction
even if you choose the up direction button. It goes only from the cursor in
down direction and at the end of the text it stops. What can I do that the
find works also in up direction?

Here the C-code:

#define MAX_STRING_LEN 256
static TCHAR szFindText [MAX_STRING_LEN] ;
static TCHAR szReplText [MAX_STRING_LEN] ;
HWND PopFindFindDlg (HWND hwnd)
{
static FINDREPLACE fr ; // must be static for modeless dialog!!!

fr.lStructSize = sizeof (FINDREPLACE) ;
fr.hwndOwner = hwnd ;
fr.hInstance = NULL ;
// fr.Flags = FR_HIDEUPDOWN | FR_HIDEMATCHCASE | FR_HIDEWHOLEWORD;
fr.Flags = FR_DOWN | FR_HIDEWHOLEWORD;
fr.lpstrFindWhat = szFindText ;
fr.lpstrReplaceWith = NULL ;
fr.wFindWhatLen = MAX_STRING_LEN ;
fr.wReplaceWithLen = 0 ;
fr.lCustData = 0 ;
fr.lpfnHook = NULL ;
fr.lpTemplateName = NULL ;
return FindText (&fr) ;
}

so this dialog is called from the WndProc

case IDM_SEARCH_FIND:
SendMessage (hwndEdit, EM_GETSEL, 0, (LPARAM) &iOffset) ;
hDlgModeless = PopFindFindDlg (hwnd) ;
return 0 ;

default:
// Process "Find-Replace" messages
if (message == messageFindReplace)
{
pfr = (LPFINDREPLACE) lParam ;
if (pfr->Flags & FR_DIALOGTERM)
hDlgModeless = NULL ;
if (pfr->Flags & FR_FINDNEXT)
if (!PopFindFindText (hwndEdit, &iOffset, pfr))
OkMessage (hwnd, TEXT ("Text not found!"),
TEXT ("\0"),1) ;

if (pfr->Flags & FR_REPLACE || pfr->Flags & FR_REPLACEALL)
if (!PopFindReplaceText (hwndEdit, &iOffset, pfr))
OkMessage (hwnd, TEXT ("Text not found!"),
TEXT ("\0"),1) ;
if (pfr->Flags & FR_REPLACEALL)
while (PopFindReplaceText (hwndEdit, &iOffset, pfr)) ;
return 0 ;

Greetings,
Franz
--
Franz Bachler, A-3250 Wieselburg
E-Mail: fraba (at) gmx.at
Homepage: http://members.aon.at/fraba
oder http://home.pages.at/fraba


From: Jongware on
On 29-Apr-10 11:04 AM, Franz Bachler wrote:
> I've compiled the editor example from the book Ch. Petzold "The definitive
> Guide to the Win32 API" and it works. But:
>
> The find (also replace) dialog is unable to find or replace in up direction
> even if you choose the up direction button. It goes only from the cursor in
> down direction and at the end of the text it stops. What can I do that the
> find works also in up direction?
>
> Here the C-code:
>
<snap>

Flag does not equal Function. It's an indicator of what the user wants
to make the computer do.

Check how the FR_DOWN flag is handled in your PopFindFindText and
PopFindReplaceText functions.

[Jw]