
Since the find and replace common dialog boxes are modeless, they
P ocessing find-r
communicate with their parent window object by using a registered
and-replace
message FINDMSGSTRING. Y u must write an event response functiono
messages
that responds to FINDMSGSTRING. That event response function takes
two parameters—a WPARAM and an LPARAM—and returns an LRESULT.
The LPARAM parameter contains a pointer that you must pass to the
dialog box object’ UpdateData member function.s
After calling UpdateData, you must check for the FR_DIALOGTERM flag.
The common dialog box code sets that flag when the user closes the
modeless dialog box. Y ur event response function should then zero theo
dialog box object pointer because it’ no longer valid. Y u must constructs o
and create the dialog box object again.
As long as the FR_DIALOGTERM flag wasn’t set, you can process the
FINDMSGSTRING message by performing the actual search. This can be as
simple as an edit control object’ Search member function or as complicateds
as triggering a search of a Paradox or dBASE table.
In this example, EvFindMsg is an event response function for a registered
message. EvFindMsg calls UpdateData and then checks the
FR_DIALOGTERM flag. If it wasn’t set, EvFindMsg calls another member
function to perform the search.
DEFINE_RESPONSE_TABLE1(TDatabaseWindow, TFrameWindow)
.
.
.
EV_REGISTERED(FINDMSGSTRING, EvFindMsg),
END_RESPONSE_TABLE;
.
.
.
LRESULT TDatabaseWindow::EvFindMsg(WPARAM, LPARAM lParam)
{
if (SearchDialog) {
SearchDialog->UpdateData(lParam);
// is the dialog box closing?
if (SearchData.Flags & FR_DIALOGTERM) {
SearchDialog = 0;
SearchCmd = 0;
} else
DoSearch();
}
return 0;
}
Chapter 8, Dialog box objects
193