Solved

CScrollView as a child of a CFormView.

Posted on 1998-10-26
7
430 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 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
Technology Partners: 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!

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 550
centeredAverage challenge 8 188
wordappend challenge 8 249
how to split multiple lines delimiter : 8 133
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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

752 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