Solved

CFormView, CDialog, and events...

Posted on 1997-08-13
5
854 Views
Last Modified: 2013-11-19
Environment:  VC++ 5.0 and Windows NT 4.0

Hello everyone,

I'm creating a CFormView based MDI application and have created a CDialog based class to handle the processing for the dialog itself.  My question involves the handling of events.

If I add an event handler (for a button on the dialog for example) to the CDialog based class, I don't seem to be able to receive notifications from the button.  However, if I place the event handler in the CFormView based class, I can
receive the event from the button.

Is there any way to have the CDialog based class handle the events without manually passing the events to the class thru the CFormview based class?

Any suggestions would be helpful.

Thanks in advance,
Mike Irvin
M.Irvin@Dialogic.com
0
Comment
Question by:irvinm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:davmarc
ID: 1303674
Controls included in your CDialog window send notification messages to their parent - the CDialog.

Controls included in your CFormView window send notification messages to their parent - the CFormView.

If you want someone else CDialog to handle CFromView controls notification messages (or vice versa) you must forward the messages manually.

Davide Marcato.
0
 

Expert Comment

by:Amaresh080997
ID: 1303675
Hi MikeIrvin,
I dont clearly understand your requirement.As far as I understand  ur requirement, I think u may have to pass the messages manually.

0
 

Author Comment

by:irvinm
ID: 1303676
I am a little confused over the concept of having a CDialog
class handling the controls in the dialog.

In my application I am trying to separate the CView (CFormView)
from the processing and event handling in the CDialog.  When
I add an event processor in the CDialog to handle the events
from the controls in the dialog, I can not receive events.

However, if I move the event handling to the View class,
everything is fine.  So, from your explaination, events from
the Dialog controls should be routed to the parent (which
makes sense), but since that is the CView, what is the point
of creating a separate class (CDialog) based to handle the
processing when events have to be manually route to this
class.

Doesn't it make sense to place the processing of dialog controls
into a CDialog class for encapsulation purposes.

Thanks for the initial information,
Mike Irvin
0
 
LVL 4

Accepted Solution

by:
davmarc earned 100 total points
ID: 1303677
The rule is that every control sends notification messages to its parent, being it a CView window or a dialog box.

I think you are making some confusion about the role of CFormView: it seems like a dialog box and internally behaves mostly like that, but it is managed by a CView derived class to make it fit into the document/view paradigm as MFC implements it.

When you work with a CFormView, most of the concepts valid for regular (modeless) dialog boxes apply as well: you place the controls with the resource editor, you handle the messages coming from them, and so forth.
But you implement everything in your customized CFormView-derived class, without dealing with CDialog at all. You use CDialog only for working with traditional non-document/view non-CFramed dialog boxes.

I hope this explanation helps somehow.
After associating a CDialog-derived class with a dialog template,  the messages generated by its controls will be delivered to class' handlers. Otherwise, there is something incorrect in your code.

Davide Marcato.
0
 

Author Comment

by:irvinm
ID: 1303678
Thank you for the explaination.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Detect CR LF to each line 12 174
Creating an alias to a directory so I can change the directory 'contents' by changing the alias 5 95
lucky13 challenge 11 158
pre4 challenge 19 110
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question