Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CScrollView as a child of a CFormView.

Posted on 1998-10-26
7
Medium Priority
?
476 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 200 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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…
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.
Screencast - Getting to Know the Pipeline

886 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