http//blog.163.com/gz_ricky/blog/static/1820491182011061180897/ReprintThe Tab Ctrltab Property page control can add a different page to a window, and then be notified when the page selection has changed. MFC uses the CTabCtrl class to encapsulate the various operations of a property page control. by calling BOOL Create (DWORD dwstyle,Constrect& Rect, cwnd*pParentWnd, UINT NID); To create a window, dwstyle can use the following property page control's private style: Tcs_buttons use the button to represent the page selection location tcs_multiline Branch Display page Select Location Tcs_ Singleline only use one row to display the page selection location after the control has been created, you must add a page to it, and the function to add the page is: BOOL InsertItem (intNitem, LPCTSTR lpszitem); Nitem is the position, starting from zero, Lpszitem for the page to select the text displayed on the location. If you want to display an icon at the page selection location, you can call the BOOL InsertItem (intNitem, LPCTSTR Lpszitem,intNImage); NImage indicates the position of the image being used. (CImageList * SetImageList (CImageList *) must be called beforepimagelist), set the correct ImageList) In addition CTabCtrl also provides some functions for getting/modifies the state of the control. intGetCurSel ()/intSetCurSel (intNitem); used to get/sets the page position that is currently selected. BOOL DeleteItem (intNitem)/bool deleteallitems (); Used to delete the specified/all pages. voidRemoveimage (intnImage); Used to delete the icon on the selected location of a page. The message map of the property page control also uses the On_notify macro, in the form of on_notify (wNotifyCode, ID, MEMBERFXN), wnotifycode as the notification code, ID for the window ID that generated the message, MEMBERFXN is a handler function, the prototype of the function is like void Onxxxtab (NMHDR* PNMHDR, lresult*pResult), where PNMHDR is a data structure that needs to be converted to other types of structures when used specifically. The possible values for the list control and the corresponding data structure are: Tcn_selchange is sent after the current page has changed, the structure used: NMHDR tcn_selchanging when the current page is changed send can prevent the page from changing by returning true, Structure used: NMHDR in general, when the current page changes, you need to hide some of the current subwindow and display the other sub-windows. The following pseudo-code demonstrates how to use the property page control: Cparentwnd::oncreate (...) {M_tab. Create (...); M_tab. InsertItem (0,"Option 1"); M_tab. InsertItem (1,"Option 2"); Create a edit box asThe M_tab's ChildCreate AStaticBox asThe M_tab's ChildEdit_box. ShowWindow (Sw_show);//edit box on the first page of the property pageStatic_box. ShowWindow (Sw_hide);//static box on the second page of the property page} voidCparentwnd::onselectchangetab (nmhdr* Pnmhdr, lresult*PResult) {//Process page Select changed messageif(M_tab. GetCurSel () = =0) {//Show/Hide different child windows according to the current pageEdit_box. ShowWindow (Sw_show); Static_box. ShowWindow (Sw_hide); } Else {// Edit_box. ShowWindow (Sw_hide); Static_box. ShowWindow (Sw_show); } }
Folder Tab Ctrl