?
Solved

A Child window of CMDIChildWnd.

Posted on 2003-03-29
14
Medium Priority
?
426 Views
Last Modified: 2013-11-20
I created a child window of a CMDIChildWnd derived class.
It is a just simple CWnd derived window.

The problem begings when I create a child of the CWnd derived window, which is a child of CMDIChildWNd.

The painting and background erase processes are messed up big time!!

When I try to move the window, the background of its parent window, the child of CMDIChildWnd, is not  erasing its back ground leaving the tracks of the path that the window moved along.

Does aybody ahve any idea??
0
Comment
Question by:string6
[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
14 Comments
 

Expert Comment

by:MrNoName
ID: 8232462
You are probably not providing a window class for it

Override the PreCreateWindow virtual function

BOOL CYourClass::PreCreateWindow(CREATESTRUCT& cs)
{
        if( !CMDIChildWnd::PreCreateWindow(cs) )
          return FALSE;

     cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
     cs.lpszClass = AfxRegisterWndClass (CS_DBLCLKS, AfxGetApp ()->LoadStandardCursor (IDC_ARROW),
          (HBRUSH) (COLOR_3DFACE+1), AfxGetApp()->LoadStandardIcon (IDI_WINLOGO));

     return TRUE;
}

Notice the call to AfxRegisterWndClass. The problem you are encountering could be caused by a NULL call...like this: AfxRegisterWndClass (0)
0
 

Author Comment

by:string6
ID: 8232754
The thing that I don't understand is why it does not happen if I create a child window in a regular CWnd derived window , not CMDIChildWnd derived window.

Could you educate me little bit please?
0
 

Author Comment

by:string6
ID: 8232755
By the way, I have not had a chance to try your recommendation yet.  I will post the result after I try.
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!

 

Author Comment

by:string6
ID: 8232763
One more thig,

The window which is not painting and erasing its back ground is a CWnd derived window contained in CMDIChildWnd derived window.
0
 

Expert Comment

by:mjwilliamson
ID: 8238083
Why don't you use a CMDIFrameWnd class and the doc/view
architecture. This will handle the Child window for you.

0
 

Author Comment

by:string6
ID: 8238717
I am using CMDIFrameWnd class for the container of CMDIChild.  I cannot use doc/view due to the nauture of project
0
 

Expert Comment

by:mjwilliamson
ID: 8238800
what are you trying to achieve with this CWnd window?
0
 

Author Comment

by:string6
ID: 8238838
It is going to have buttons in it, and the user should be able to move it arouund.
0
 

Expert Comment

by:mjwilliamson
ID: 8238940
If the new window is to be a child of the child window,
then I pressume that it is a toolbar or floating bar
you are after. You could add a toolbar to the childFrame
class and load a toolbar the conventional in Create().

This can be docked perminently at the top of the child
window which would keep things tidy or you could float
it at a particular location on the screen. This should
also take care of the erase background or whatever the
problem was.

Hope this helps
0
 

Author Comment

by:string6
ID: 8239014
Unfortunatly that is not the case.

It is a cbutton drived button I have to have in a window, which is contained in a CMDIChildWnd derived class.
0
 

Expert Comment

by:mjwilliamson
ID: 8239044
Does it have to be a CButton object you use?
0
 

Author Comment

by:string6
ID: 8239090
Yes......  I have no choice......

I was given a mfc extesion dll that creates button as requested.  I have to make a button page editor in MDI evironment......

I think in CMDIChildWnd case, CMDIChildWnd is resoposible to paint and erase background of its child windows....

It sort of works if I force to invalidate the CMDIChildWnd class.

 
0
 

Author Comment

by:string6
ID: 8271759
I will get this question deleted and get the point refunded.

I any body have opposition to it, please post iwthing 4 days.

Thanks
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8295004
PAQ'd and all 200 points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
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

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…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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