Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CScrollView as a child of a CFormView.

Posted on 1998-10-26
7
Medium Priority
?
456 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
[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
  • 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

721 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