Solved

CScrollView as a child of a CFormView.

Posted on 1998-10-26
7
422 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
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.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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