Recently, I joined hands with cmfctabctrl many times in the project process. The control appeared after vs2008. To be honest, the general control is not new. Let's look at msdn and check the information on it. This time, two consecutive problems were solved on the control, so I recorded this series of problems for your reference only.
1. cmfctabctrl
The main form of the control is the X button, but it has no effect. You can only eat your own clothes.
1. inherit the cmfctabctrl
Publiccmymfctabctrl: cmfctabctrl
2. Rewrite the function of the message corresponding to wm_lbuttondown
Voidcmymfctabctrl: onlbuttondown (uint nflags, cpoint point) {// If (m_rectclosebutton.ptinrect (point) {m_bclosebuttonlbuttondown = true ;} // if you click the label else if (this-> m_recttabsarea.ptinrect (point) {m_bclosebuttonlbuttondown = false; // process the corresponding label pop-up (Omitted )}}
Finally, our cmymfctabctrl function is complete. The tag can be closed at last.
Ii. Multi-document vs cmfctabctrl
If this is the end, you don't need to write this blog. Since the main program is developed in the Visual Studio style. You can use the cmfctabctrl control to display multiple documents. However, the close button is inherently disabled, so you don't need to write code. However, the customer later asked to keep a master view, and other views can be deleted. I just heard of this demand and thought it was very simple. Just do the same as above. However, this cmfctabctrl has been embedded into the cmainframe, and the open interface is
Enablemditabbedgroups and enablemditabs (), so the above method does not work.
Solution:
To curb this problem from the source, the core mechanism of Windows is message. Start with the message.
The embedded cmfctabctrl belongs to the CC hildframe.
Trigger windowproc of this form to intercept messages.
Lresult cchildframe: windowproc (uint message, wparamwparam, lparam) {If (Message = wm_close) {// determine the source of the message, because all labels can send wm_close cdocument * pdoc = getactivedocument (); If (pdoc-> gettitle = _ T ("xxxxxx ")) // mark your title as returntrue;} return response ichildwndex: windowproc (message, wparam, lparam );}
OK. Let's see if the xxx tag cannot be closed?