A SERVICE OF

logo

BOOL
FnName
(long);
The long item used in the NotifyViews or QueryViews function call is used
for the long parameter for the response function.
Y u can use NotifyViews to notify your child documents, their associatedo
views, and the associated views of your root document of a change in data,
an update, or any other event that might need to be reflected onscreen. The
meaning of the event and the accompanying item passed as a parameter to
the event are implementation defined.
NotifyViews first calls all the document’ child documents’ NotifyViewss
functions, which are called with the same parameters. Once all the children
have been called, NotifyViews passes the event and item to all of the
document’ associated views. NotifyViews returns a BOOL. If any childs
document or associated view returns FALSE, NotifyViews returns FALSE.
Otherwise NotifyViews returns TRUE.
QueryViews sends an event and accompanying parameter just like
NotifyViews. The difference is that, whereas NotifyViews returns TRUE
when any child or view returns TRUE, QueryViews returns a pointer to the
first view that returns TRUE. This lets you find a view that meets some
condition and then perform some action on that view. If no views return
TRUE, QueryViews returns 0.
Another difference between NotifyViews and QueryViews is that NotifyViews
always sends the event and its parameter to all children and associated
views, whereas QueryViews stops at the first view that returns TRUE.
For example, suppose you have a document class that contains graphics
data in a bitmap. Y u want to know which of your associated views iso
displaying a certain area of the current bitmap. Y u can define an evento
such as WM_CHECKRECT. Then you can set up a TRect structure
containing the coordinates of the rectangle you want to check for The.
excerpted code for this would look something like this:
DEFINE_RESPONSE_TABLE1(TMyView, TView)
.
.
.
EV_OWLNOTIFY(WM_CHECKREST, EvCheckRest),
.
.
.
END_RESPONSE_TABLE;
void MyDocClass::Function() {
// Set up a TRect * with the coordinates you want to send.
TRect *rect = new TRect(100, 100, 300, 300);
// QueryViews
TView *view = QueryViews(WM_CHECKRECT, (long) rect);
Chapter 9, Doc/View objects
213