Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is a C++, MFC, MDI app. I thought this would be easy, but I can't seem to get it to work.

This is an MDI app, but only one form view is normally open. The top bar of the view isn't needed when only one view is open. Through the PreCreateWindow override I've removed everything from the top bar, but it still shows up.

I'm probably missing something basic...

What I have tried:

This is the current PreCreateWindow for the child frame

C++
BOOL CChildStdTrace::PreCreateWindow(CREATESTRUCT& cs)
{
		cs.style |= WS_CHILD|WS_VISIBLE
			|WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
		cs.style &= ~(WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_DLGFRAME 
|FWS_ADDTOTITLE|WS_BORDER|WS_THICKFRAME);
		cs.dwExStyle &= ~(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME);
	}
	return(DRVCHILD::PreCreateWindow( cs ));
}


This leaves just a blank bar at the top of the window, my customer wants it removed because it's just taking up real estate.
Posted
Updated 3-Jun-22 4:47am
v2
Comments
Richard MacCutchan 3-Jun-22 4:26am    
I have a non-MFC version that does not show top bars on the child windows. I create them from a modified MDIChild class, using only extended style WS_EX_CLIENTEDGE, and styles WS_CHILD | WS_VISIBLE. It is many years since I used MFC so cannot recall whether I did the same when using that.
wdolson 5-Jun-22 21:00pm    
I tried your suggestion and I got the same behavior. The top bar of the view window is still there, there just isn't anything on it.
Richard MacCutchan 6-Jun-22 3:21am    
I think the problem is that the CMDIFrameWnd will always create a header bar, whatever styles you use on it.
wdolson 6-Jun-22 21:30pm    
So it sounds like I can't get there from here. I can say I tried...

1 solution

Wouldn't it be better to call PreCreateWindow at Begin?
C++
BOOL CChildStdTrace::PreCreateWindow(CREATESTRUCT& cs)
{
    if( !CFrameWnd::PreCreateWindow(cs) )
        return FALSE;

    // TODO: Modify the Window class or styles here by modifying
    // the CREATESTRUCT cs
 
    return TRUE;
}
 
Share this answer
 
Comments
0x01AA 3-Jun-22 10:51am    
"Wouldn't it be better to call PreCreateWindow at Begin?": No. PreCreateWindow needs to be executed after modifying the styles. Btw. No vote from here ;)
merano99 3-Jun-22 11:05am    
Too bad. Microsoft documents it like this:
https://docs.microsoft.com/en-us/cpp/mfc/changing-the-styles-of-a-window-created-by-mfc?view=msvc-170
wdolson 5-Jun-22 21:05pm    
PreCreateWindow is called by the framework before the window is created. You can modify the properties of the window before it's created by changing the CREATESTRUCT values, which I'm already doing. I just can't get the top bar on the view window to go away completely.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900