Link to home
Start Free TrialLog in
Avatar of string6
string6

asked on

A Child window of CMDIChildWnd.

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??
Avatar of MrNoName
MrNoName

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)
Avatar of string6

ASKER

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?
Avatar of string6

ASKER

By the way, I have not had a chance to try your recommendation yet.  I will post the result after I try.
Avatar of string6

ASKER

One more thig,

The window which is not painting and erasing its back ground is a CWnd derived window contained in CMDIChildWnd derived window.
Why don't you use a CMDIFrameWnd class and the doc/view
architecture. This will handle the Child window for you.

Avatar of string6

ASKER

I am using CMDIFrameWnd class for the container of CMDIChild.  I cannot use doc/view due to the nauture of project
what are you trying to achieve with this CWnd window?
Avatar of string6

ASKER

It is going to have buttons in it, and the user should be able to move it arouund.
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
Avatar of string6

ASKER

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.
Does it have to be a CButton object you use?
Avatar of string6

ASKER

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.

 
Avatar of string6

ASKER

I will get this question deleted and get the point refunded.

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

Thanks
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial