DialogBar communication
IceMan -- rmenschi@umr.edu
Monday, August 05, 1996
Environment: Visual C++4.0 / Win95 / (perhaps NT4.0 later)
...I have more of a design question using MFC than anything else. I have
4 dialog bars in a SDI application:
- DialogBar1 and 2 are basically just listboxes.
- DialogBar3 is a list control in report view (two columns) with a
couple buttons to add/delete items to the list.
- DialogBar4 is a multi-line edit box with button.
- The SDI view itself is is just a collection of small "icons".
...Okay, now what I'd like to do is be able to have the user double click
items in DialogBar1 and 2 listboxes and have the list box text show up at
the cursor position in DialogBar4. DialogBar4's button should update the
text second column of the list control (in DialogBar3) with the text in
its (DialogBar4) edit box. The view's icons are number by the user to
match up with the numbers in DialogBar3 list control's first column.
Yes, it's convoluted.
...I've thought about this for a while and I'm considering having all of
the dialog bars communicate with the document and then (somehow) have the
document update all of the dialog bars that are affected. Is this the
best MFC way to do it, or would it be better to somehow post user-defined
messages into the loop and have the other dialog bars try and catch those
messages (I've never tried doing that before)? Or is there a better way
to pull this off?
IMPLEMENTATION NOTE: Each of the dialog bars' code is contained in
separate distinct classes.
Thanks,
Rob Mensching
rmenschi@umr.edu
Graham -- Cunningham@tgd.swissptt.ch
Friday, August 09, 1996
[Mini-digest: 2 responses]
Hi if you take a look at the Design Patterns book it shows you how to
implement this kind of communication between windows they call it the
Observer pattern. I have implemented the 2 classes required CSubject and
CObserver and I inherit from these in the each class
eg class CSearchDialogBar : public CDialogBar, public CObserver, public
CSubject
class COtherDialogBar : public CDialogBar, public CObserver, public
CSubject
I then in mainfrm when i am creating the dialog bar I create links
between the bars using
m_SearchDialogBar.Attach(&m_OtherDialogBar);
this tells the search that whenever it changes to call Update() in the
OtherDialogBar.
If you want the classes let me know. but the best thing is to get the
book.
regards
Graham Cunningham
00 41 31 338 0633
-----From: ppbillc@srv2.sj.ablecom.net
I'd use CFormView and not bother with all the dialogbars..put all
the controls in one place. SDI lends itself nicely to this. Just my
2c
B
/ \
* *
\ _,-._/
| Вернуться в корень Архива
|