Graduation design has not finished, but my old habits again committed, for a small problem tangled up for me for a long time, but by the wind of Baidu and Google, I still can not find the answer, finally in an unexpected thinking to solve the problem.
A few days ago began to write multiple documents MFC program, of course, the beginning of the tangle of things under the interface is also very normal, well, I would like to remove the mainframe completely off the border, first remove the menu, toolbar, very simple, Baidu, the answer is almost correct, but to pay attention to multiple documents to the menu, unlike a single document, Mainly because each view can make mainframe have different menus, not to mention by default there is a main menu, so you need to remove the menu in the app and mainframe, direct Setmemu (NULL); Notice that it's not the same in the app.
BOOL cwepingapp::initinstance ()
{
....
:: AfxGetMainWnd ()->setmenu (NULL);
....
}
OK, but you quickly find that this is not easy to see, and then try to remove the Childframe menu, View menu. Or in a simpler way:
The AddDocTemplate (pdoctemplate) in the InitInstance () of the Cxxxapp;
Plus pdoctemplate->m_hmenushared=null;.
OnCreate in CMainFrame, add a SetMenu (NULL); it's OK.
Finally became a very white things, but still have effect on the beautiful border effect, after checking the document and Baidu, know to remove a CWnd border, you can set style, there can be two ways: first, in PreCreateWindow overload in the createstruct& CS toss, Mainly tossing dwExStyle and style, one is an extended style, an original style,
Second, is the same ModifyStyleEx and ModifyStyle, similar to the above, check the document to know that also called the Setwindowslong function, of course, we do not have so much trouble, directly to the style of the two functions on the line, pay attention to the use of the oncreate inside
So what style to set, after my research, set the following style can be, although some cumbersome,
ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge, extended style
ws_thickframe| ws_caption| ws_border| Ws_sysmenu Original Style
OK, I use the second, but also deliberately wrote a macro, easy to see.
#define DELETE_BORDER_HWND (Pcwndclass) \
{\
Pcwndclass->modifystyleex (ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge,0,swp_drawframe); \
Pcwndclass->modifystyle (ws_thickframe| ws_caption| ws_border| Ws_sysmenu, 0, Swp_drawframe);
}
#define DELETE_BORDER_CS (CS) \
{\
Cs.dwexstyle &= ~ (ws_ex_clientedge| ws_ex_windowedge| Ws_ex_staticedge); \
Cs.style &= ~ (ws_thickframe| ws_caption| ws_border| Ws_sysmenu); \
}
If you also have many places in Baidu, you can know that, to make mainframe,childframe, and view border completely without words, need to be in this three class OnCreate or PreCreateWindow to remove these styles, So you can get a perfect border effect right away, here said that the perfect, mainly because the careful person will find, in fact, the main border still has a frame can not eliminate, well, patient students tried a style and style, radical students to search how to redraw the non-client area, and then go to another channel, But there is also a classmate is, want to know why there will be a border appears, of course, good easy solution is often here.
Okay, originally want to make that border become more obvious, and then prove that I am not dizzy, so I intend to overload painting function, remove background redraw, but the result I failed, the background completely go, this is not possible, after a round of Baidu and confused, I found mainframe have m_ Hwndmdiclient such a member, from the name, we know we found the suspect, that is, he covered our client area, causing us to redraw the background. So tangled in can not redraw the background has no meaning, back to the original purpose, remove the border, if this CWnd blocking the background, then his border must also pollute our customer area, with macros to change its habits. Bingo. We get the perfect go border.
Of course, there's no explanation for SDI here, but you can solve them yourself from here. Hope this article can reduce your Baidu time, but I spent two days to Baidu.