The label of cmfctabctrl is disabled.

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.