Solved

CScrollView as a child of a CFormView.

Posted on 1998-10-26
7
403 Views
Last Modified: 2013-11-20
We have a CScrollView derived class that we want to have as a child (like a control) in a CFormView derived class. The problem is that some messages don't arrives to the child view, like WM_KEYDOWN/WM_KEYUP. At least the message handlers doesn't execute. We creates the child view in the parents OnInitialUpdate, in principle like this:

m_pChildView = new CTheChildView;

GetClassName(m_hWnd, strClassName.GetBuffer(BUFFER_SIZE), BUFFER_SIZE);
strClassName.ReleaseBuffer();

->Create(strClassName, strName, WS_CHILD | WS_VISIBLE, rect, this, 0);
m_pChildView->SetScrollSizes(MM_TEXT, CSize(100,100));
m_pChildView->OnInitialUpdate();

How do we get those messages?
0
Comment
Question by:stefanr
  • 3
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1323866
CFormView is doing a tremendous amount of work to make sure the controls inside of it manage focus properly. You've broken that work by using a non-control as a child of the window.

It's do able, but you need to handle TranslateAccelerator() in the splitter view and offer the view inside the splitterwindow a chance at handling the message--specifically, passing it to the children in the dialog box it's created. You'll need to make sure you keep track of which view had the focus.

B ekiM
0
 
LVL 3

Author Comment

by:stefanr
ID: 1323867
Mike,
it seems that the present code should be altered to be more consistent with MFC. Would you suggest that the view now used as a control should be converted to a control? Do you think that it would be managable without too much alterations regarding that my experience right now is very limited creating controls? The view is actually a grid view.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1323868
If the view is a grid view, it's surprising to me that it isn't already a control.

I don't see any "inconsistency with MFC", and to be frank I'm not even sure what that means. If that's what you feel, then I guess there's even more to this problem you haven't shared with us.

I answered only the question you posed; if you want to share more information about the problem, then maybe I can provide a more suitable answer.

Converting the view to a control is one good way to solve the issues you've expressed so far, and the only way to gain experience is to get some work done. So, maybe that's what you should do.

B ekiM


0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Author Comment

by:stefanr
ID: 1323869
Mike,
I interpreted your statement "You've broken that work by using a non-control as a child of the window." as "inconsistent with MFC", but that's may have been wrong. The problem with this grid view is that it was done by a bunch of other programmers, and some of them don't work here anymore. The grid view itself is constructed to be fast, since it is used in a real time system. Therefore all the obscure code. Now the need to add some controls to it have been solved by using a CFormView as a primary view and the grid view as a child to it. The time frame to solve the question at hand is very limited, and therefore I wondered if it perhaps would be a faster way of solving it trying to convert it to a control, regarding the limited experience in writing controls we have here.
0
 
LVL 2

Expert Comment

by:lucidity
ID: 1323870
You could have your CFormView route messages to its paren AND the CScrollView. I would like to take a look at your code if I could. If you make any head way into making a view into a control I would also be interested in learning about that.
0
 
LVL 3

Author Comment

by:stefanr
ID: 1323871
The people in charge have been convinced that it would be better and faster to use the MS FlexGrid control for this, and I couldn't agree more.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1323872
> I interpreted your statement "You've broken that
 > work by using a non-control as a child of the window."
 > as "inconsistent with MFC", but that's may have been wrong.

Yep.  Any control that lives as a child in any window needs to process messages a little bit differently. Instead of sizing itself, it will need to be resized, for example.  If you want to window to act like a control, it will need to find a way to get input messages from its parent.

That's just Windows, that's not specific to MFC.

 > The time frame to solve the question at hand is
 > very limited, and therefore I wondered if it perhaps
 > would be a faster way of solving it trying to convert
 > it to a control, regarding the limited experience in
 > writing controls we have here.

Only you can answer that for yourself. Obviously, it's hard for me to make a correct time estimate for someone I don't even know.

B ekiM

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now