Tabcontrol User Guide

Source: Internet
Author: User

From: http://hi.baidu.com/moxingfen/blog/item/7576ec1263992258f819b8eb.html

Http://hi.baidu.com/moxingfen/blog/item/0d12a6f03481c8a6a40f52eb.html/cmtid/85efe86d6e59e1f7431694d5

 


Create an MFC project and draw a tabcontrol in your own window. Then, associate the control with the variable of the previous control, called m_page.

// Add an item to the tab_control

M_page.insertitem (0, _ T ("page1 "));
M_page.insertitem (1, _ T ("page2 "));
M_page.insertitem (2, _ T ("page3 "));

This is to add tags to it.

Then, insert a resource in the dialog box and set the following attributes to the Resource:
Border: None
Style: Child
Create a class for this dialog box. Cpage1 ..
Then add the following in the header file of the main window:
# Include "page1.h"

In the code file header of the Main Window, add:
Cpage1 m_page1;

Then write in the oninitdialog process of loading the main window:
M_page1.create (idd_page1, & m_page );
M_page1.setwindowpos (null, 10, 30,400,100, swp_showwindow );
In this way, this subwindow appears on the main window.

 

Right-click tabcontrol and choose add event handler. In the class list, select the class in the main window. The message type will not change. Start with your own name.


Void cmaindlg: ontcnselchange_page (nmhdr * pnmhdr, lresult * presult)
{
// Get current POS
Crect R;
M_page.getclientrect (& R );

// Which one is selected now?
Switch (m_page.getcursel ())
{
Case 0:
M_page1.setwindowpos (null, 10, 30, R. Right-20, R. Bottom-40, swp_showwindow );
Break;

Case 1:
M_page1.setwindowpos (null, 10, 30, R. Right-20, R. Bottom-40, swp_hidewindow );
Break;

Case 2:
M_page1.setwindowpos (null, 10, 30, R. Right-20, R. Bottom-40, swp_hidewindow );
Break;
}
* Presult = 0;
}

Of course, you can open an array, store the pointer of the dialog box object, and then you don't need to write the switch.

 

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.