Comments about Find/Replace dialogs

Topics: Developer Forum
Sep 15, 2006 at 8:57 AM
I integrated the Find/Replace dialogs in my project and tested them in real cases. Here are my feelings about it. These are personal feelings and you may not agree.

1) SearchHelper::FindNextAndHighlight(int,int)
when "Find Next" button is clicked, the focus is transferred to the editor component; this is really annoying if you mainly use the keyboard: hitting <Enter> triggers the find function and the focus is transferred; for the next find operation, you have to manually re-transfer the focus to the dialog (with the mouse or Alt+Tab). I wouldn't transfer the focus, or at least make this configurable

2) FindControl::comboboxFindWhat_KeyUp()
when <Enter> key is clicked, focus is transferred to the find button (assuming you solved point 1 above). I would prefer keeping the focus in the combobox and do a SelectAll(), such that you can directly enter a new search string

3) SearchHelper::FindNextAndHighlight(int,int)
EnsureVisibleEnforcePolicy() only works (scroll the caret) if the editor component has set the visible policy with SetVisiblePolicy, otherwise it doesn't do anything. Should then the find control set automatically reasonable caret policies? Moreover, EnsureVisibleEnforcePolicy() only handle vertical scrolling; if the selected text is not visible in the horizontal axis, something else is also needed, for instance ScrollCaret(). A combination that I tried and gives good results is:

Caret policies:
SetVisiblePolicy(CaretPolicy.Strict, 0);
SetXCaretPolicy(CartePolicy.Jumps|CaretPolicy.Even, 0);

EnsureVisibleEnforcePolicy(); // handle vertical scroll
ScrollCaret(); // handle horizontal scroll (if needed)

4) FindForm::Initialize()
Is it possible to move the Cancel event binding to the ctor? Then you can imagine to reuse the same dialog with different editor components (and avoid binding the same event several times)

5) when in "Wrap around" mode: it would be useful to have a notification dialog that tells you when you have achieve a complete cycle (back to the starting point); of course, the startint point should be reset every time the search string is modified. You could make this configurable.

6) it would be also probably a good thing to make the dialog relocation (when the selected text is behind the dialog) configurable.

Hope this helps.
Sep 15, 2006 at 9:00 AM
I should have added that I tested the dialog with the code revision 5315.

Sep 17, 2006 at 4:09 AM
Ok, I will take a look at it and work some if not all of those changes in. Thanks again for helping out!
Sep 19, 2006 at 3:09 PM
I implemented most of those issues above. I haven't done the wrap-around notification yet, but plan to soon. I need to make the messagebox text and button text configurable with resource files or something like that for globalization support as well.