📄 read.cgi-read=10269.htm
字号:
<HTML><HEAD><TITLE>How to hide the tabs in PropertyPage</TITLE>
</HEAD><BODY background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF">
<table WIDTH="100%"> <tr WIDTH="100%"> <td><table>
<tr><td><img src="../mfc_sourcebook.jpg" tppabs="http://www.codeguru.com/mfc_sourcebook.jpg"
ALT="MFC Programmer's SourceBook" WIDTH="256"
HEIGHT="88"><td></tr>
<tr><td valign="bottom"><font SIZE="+1"
color="#a0a0ff"><b>Discussion Board</b></font></td></tr>
</table></td> <td width="40"></td>
<td align="right" valign="top"><td> </tr> </table> <hr><P ALIGN=CENTER>[ <A HREF="#Responses">Read Responses</A> | <A HREF="#PostResponse">Post a New Response</A> | <A HREF="index.cgi.htm" tppabs="http://www.codeguru.com/mfc_bbs/index.cgi">Return to the Index</A> ]
<A HREF="read.cgi-read=10270.htm" tppabs="http://www.codeguru.com/mfc_bbs/read.cgi?read=10270">Next in Thread</A><P ALIGN=CENTER><BIG><BIG><BIG><STRONG>How to hide the tabs in PropertyPage</STRONG></BIG></BIG></BIG>
<P ALIGN=CENTER><EM>Posted by <STRONG><A HREF="mailto:raul@hiso.honeywell.com">Raul R.</A></STRONG> on <STRONG>4/23/98 10:17p.m.</STRONG></EM></P>
<!-- REMOTE_HOST: 204.220.167.194; REMOTE_ADDR: 204.220.167.194-->
<P>Hi!
<BR>I have developed a Propertysheet having 18 pages. Almost all pages are dependent on each other. However i want to hide or show the required tabs as per menu selection on the same propertysheet. I don't want to use RemovePage or AddPage again and again to do that as each page needs data of other pages and updation of database depends on the user's selection on the propertysheet.
<P>I have tried by using DeleteItem and InsertItem of CTabCtrl of the ProertySheet. But it works fine i.e hides and shows the pages which are not traversed. If those methods are applied to the pages which have already been traversed if focused after Inserting into tab control gets crashed.
<P>Please try to help me out from the mesh.
<P>With
<BR>Love and Regards.
<P>Raul.
<P>The Sample Code is as follows:
<P>// MyPropertySheet.cpp : implementation file
<BR>//
<P>#include "stdafx.h"
<BR>#include "SimulatedSbcGui.h"
<BR>#include "MyPropertySheet.h"
<P>#include "Dialog11.h"
<BR>#include "Dialog12.h"
<BR>#include "Dialog21.h"
<BR>#include "Dialog22.h"
<P>#ifdef _DEBUG
<BR>#define new DEBUG_NEW
<BR>#undef THIS_FILE
<BR>static char THIS_FILE[] = __FILE__;
<BR>#endif
<P>#define G1 WM_USER+5
<BR>#define G2 WM_USER+6
<P>CDialog11 *dlg11;
<BR>CDialog12 *dlg12;
<BR>CDialog21 *dlg21;
<BR>CDialog22 *dlg22;
<P>CDialog11 dlg1;
<BR>CDialog11 dlg2;
<BR>CDialog11 dlg3;
<BR>CDialog11 dlg4;
<BR>CDialog11 dlg5;
<BR>CDialog11 dlg6;
<BR>CDialog11 dlg7;
<BR>CDialog11 dlg8;
<P>CToolBar *tool;
<BR>TC_ITEM TabCtrlItem[4];
<BR>CTabCtrl* tempTab;
<P>//CToolBarCtrl &toolBar = Null;
<BR>static UINT uIDToolBar[] = {G1,G2};
<BR>/////////////////////////////////////////////////////////////////////////////
<BR>// CMyPropertySheet
<P>IMPLEMENT_DYNAMIC(CMyPropertySheet, CPropertySheet)
<P>CMyPropertySheet::CMyPropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
<BR> :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
<BR>{
<BR> dlg11 = new CDialog11;
<BR> dlg12 = new CDialog12;
<BR> dlg21 = new CDialog21;
<BR> dlg22 = new CDialog22;
<P> AddPage(dlg11);
<BR> AddPage(dlg12);
<BR> AddPage(dlg21);
<BR> AddPage(dlg22);
<P> AddPage(&dlg1);
<BR> AddPage(&dlg2);
<BR> AddPage(&dlg3);
<BR> AddPage(&dlg4);
<BR> AddPage(&dlg5);
<BR> AddPage(&dlg6);
<BR> AddPage(&dlg7);
<BR> AddPage(&dlg8);
<BR>
<BR> EnableStackedTabs(FALSE);
<BR>}
<P>CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
<BR> :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
<BR>{
<BR> dlg11 = new CDialog11;
<BR> dlg12 = new CDialog12;
<BR> dlg21 = new CDialog21;
<BR> dlg22 = new CDialog22;
<P> AddPage(dlg11);
<BR> AddPage(dlg12);
<BR> AddPage(dlg21);
<BR> AddPage(dlg22);
<BR>
<BR> AddPage(&dlg1);
<BR> AddPage(&dlg2);
<BR> AddPage(&dlg3);
<BR> AddPage(&dlg4);
<BR> AddPage(&dlg5);
<BR> AddPage(&dlg6);
<BR> AddPage(&dlg7);
<BR> AddPage(&dlg8);
<BR>
<BR> EnableStackedTabs(FALSE);
<BR>}
<P>CMyPropertySheet::~CMyPropertySheet()
<BR>{
<BR>}
<P>BEGIN_MESSAGE_MAP(CMyPropertySheet, CPropertySheet)
<BR> //{{AFX_MSG_MAP(CMyPropertySheet)
<BR> ON_COMMAND(G1, OnGroup1)
<BR> ON_COMMAND(G2, OnGroup2)
<BR> //}}AFX_MSG_MAP
<BR>END_MESSAGE_MAP()
<P>/////////////////////////////////////////////////////////////////////////////
<BR>// CMyPropertySheet message handlers
<P>BOOL CMyPropertySheet::OnInitDialog()
<BR>{
<BR> BOOL bResult = CPropertySheet::OnInitDialog();
<BR>
<BR> RECT rt ={0,0,0,0};
<BR>
<BR> tool = new CToolBar ;
<BR> tempTab = new CTabCtrl;
<P> if (tool->Create(this, WS_CHILD | WS_VISIBLE |CBRS_ALIGN_LEFT ))
<BR> {
<BR> tool->LoadBitmap(IDR_TOOLBAR1);
<BR> tool->SetButtons(uIDToolBar, sizeof(uIDToolBar)/sizeof(UINT));
<BR> }
<P> tool->GetItemRect(0,&rt);
<P> tool->SetHeight(rt.bottom);
<BR> MakeRoom(rt.bottom,0,TRUE);
<BR> RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
<P> CToolBarCtrl & toolBar = tool->GetToolBarCtrl();
<BR>// toolBar.EnableButton(G1,FALSE);
<P> tempTab = GetTabControl();
<BR> //get item for First item
<BR> TabCtrlItem[0].mask = TCIF_STATE | TCIF_TEXT | TCIF_PARAM; //TCIF_ALL;
<BR> HPROPSHEETPAGE hPSP = CreatePropertySheetPage(&dlg11->m_psp);
<BR> TabCtrlItem[0].pszText = "Dialog 11";
<BR> TabCtrlItem[0].lParam =(long)hPSP;
<BR> tempTab->GetItem(0,&TabCtrlItem[0]);
<P> //Get Item for second item
<BR> TabCtrlItem[1].mask = TabCtrlItem[1].mask | TCIF_TEXT | TCIF_PARAM; //TCIF_ALL;
<BR> hPSP = CreatePropertySheetPage(&dlg12->m_psp);
<BR> TabCtrlItem[1].pszText = "Dialog 12";
<BR> TabCtrlItem[1].lParam =(long)hPSP;
<BR> tempTab->GetItem(1,&TabCtrlItem[1]);
<P> //Get item for third item
<BR> TabCtrlItem[2].mask = TabCtrlItem[2].mask | TCIF_TEXT | TCIF_PARAM; //TCIF_ALL;
<BR> hPSP = CreatePropertySheetPage(&dlg21->m_psp);
<BR> TabCtrlItem[2].pszText ="Dialog 21";
<BR> TabCtrlItem[2].lParam =(long)hPSP;
<BR> tempTab->GetItem(2,&TabCtrlItem[2]);
<P> //get item for fourth item
<BR> TabCtrlItem[3].mask = TabCtrlItem[3].mask | TCIF_TEXT | TCIF_PARAM; //TCIF_ALL;
<BR> hPSP = CreatePropertySheetPage(&dlg22->m_psp);
<BR> TabCtrlItem[3].pszText = "Dialog 22";
<BR> TabCtrlItem[3].lParam =(long)hPSP;
<BR> tempTab->GetItem(3,&TabCtrlItem[3]);
<BR>
<P>// tempTab->DeleteItem(3);//,&pTabCtrlItem);
<BR>// tempTab->DeleteItem(2);//,&pTabCtrlItem);
<P> return bResult;
<BR>}
<P>void CMyPropertySheet::MakeRoom(int horiz, int vert, BOOL bMove)
<BR>{
<BR> RECT rt;
<BR>
<BR> GetWindowRect(&rt);
<BR> rt.bottom+=vert;
<BR> rt.right+=horiz;
<BR> MoveWindow(&rt); // move existent controls down to make room for menubar
<BR> CWnd* pCtrl=this; // start with this and get the first children control
<BR> UINT relation = GW_CHILD|GW_HWNDFIRST;
<BR> if(bMove)
<BR> {
<BR> while((pCtrl = pCtrl->GetWindow(relation)))
<BR> {
<BR> pCtrl->GetWindowRect(&rt);
<BR> ScreenToClient(&rt);
<BR> OffsetRect(&rt,horiz,vert);
<BR> pCtrl->MoveWindow(&rt);
<BR> relation = GW_HWNDNEXT;
<BR> CString cs;int id;
<BR> pCtrl->GetWindowText(cs);
<BR> id=pCtrl->GetDlgCtrlID();
<BR> }
<BR> }
<BR>}
<P>void CMyPropertySheet::OnGroup1()
<BR>{
<BR> CToolBarCtrl & toolBar = tool->GetToolBarCtrl();
<BR> toolBar.EnableButton(G1,FALSE);
<BR> toolBar.EnableButton(G2,TRUE);
<BR> AfxMessageBox("Group 1");
<BR>// HPROPSHEETPAGE hPSP = CreatePropertySheetPage(&dlg2->m_psp);
<P>/* TabCtrlItem.mask = TabCtrlItem.mask | TCIF_TEXT | TCIF_PARAM; //TCIF_ALL;
<BR> HPROPSHEETPAGE hPSP = CreatePropertySheetPage(&dlg11->m_psp);
<BR> TabCtrlItem.pszText = "Dialog 11";
<BR> TabCtrlItem.lParam =(long)hPSP;
<BR> tempTab->GetItem(0,&TabCtrlItem);
<P> tempTab->InsertItem(0,&TabCtrlItem);
<P> hPSP = CreatePropertySheetPage(&dlg12->m_psp);
<BR> TabCtrlItem.pszText = "Dialog 12";
<BR> TabCtrlItem.lParam =(long)hPSP;
<BR> tempTab->GetItem(1,&TabCtrlItem);
<P> tempTab->InsertItem(1,&TabCtrlItem);
<P> tempTab->DeleteItem(3);//,&pTabCtrlItem);
<BR> tempTab->DeleteItem(2);//,&pTabCtrlItem);
<P>*/
<BR> tempTab->DeleteItem(3);//,&TabCtrlItem);
<BR> tempTab->DeleteItem(2);//,&TabCtrlItem);
<P>}
<P>void CMyPropertySheet::OnGroup2()
<BR>{
<BR> CToolBarCtrl & toolBar = tool->GetToolBarCtrl();
<BR> toolBar.EnableButton(G2,FALSE);
<BR> toolBar.EnableButton(G1,TRUE);
<P>/* TabCtrlItem.mask = TabCtrlItem.mask | TCIF_TEXT | TCIF_PARAM; //TCIF_ALL;
<BR> HPROPSHEETPAGE hPSP = CreatePropertySheetPage(&dlg21->m_psp);
<BR> TabCtrlItem.pszText = "Dialog 21";
<BR> TabCtrlItem.lParam =(long)hPSP;
<BR> tempTab->GetItem(2,&TabCtrlItem);
<BR>*/
<BR> tempTab->InsertItem(2,&TabCtrlItem[2]);
<P>/* hPSP = CreatePropertySheetPage(&dlg22->m_psp);
<BR> TabCtrlItem.pszText = "Dialog 22";
<BR> TabCtrlItem.lParam =(long)hPSP;
<BR> tempTab->GetItem(3,&TabCtrlItem);
<BR>*/
<BR> tempTab->InsertItem(3,&TabCtrlItem[3]);
<P>// tempTab->DeleteItem(0);//,&pTabCtrlItem);
<BR>// tempTab->DeleteItem(1);//,&pTabCtrlItem);
<P>// TabCtrlItem[0].state = 0; //TCIS_HIDDEN;
<BR>// tempTab->SetItem(0,&TabCtrlItem[0]);//,&pTabCtrlItem);
<P>// AfxMessageBox("Group 2");
<BR>}
<P>
</P>
<A NAME="Responses"><HR></A><P ALIGN=CENTER><BIG><BIG><STRONG>Responses</STRONG></BIG></BIG>
<P><UL><LI><STRONG><A HREF="read.cgi-read=10270.htm" tppabs="http://www.codeguru.com/mfc_bbs/read.cgi?read=10270">Re: How to hide the tabs in PropertyPage</A></STRONG> : Nathalie -- <EM>4/23/98 11:32p.m.</EM>
<UL>
</UL>
</UL></P>
<A NAME="PostResponse"><HR></A><P ALIGN=CENTER><BIG><BIG><STRONG>Post a New Response</STRONG></BIG></BIG>
<P><FORM METHOD=POST ACTION="http://www.codeguru.com/mfc_bbs/index.cgi?post">
<INPUT TYPE=HIDDEN NAME="followup" VALUE="10269">
<P><CENTER><TABLE><TR>
<TD ALIGN=RIGHT><P><STRONG>Your Name:</STRONG></TD><TD><INPUT TYPE=TEXT NAME="name" SIZE=40></TD></TR><TR>
<TD ALIGN=RIGHT><P><STRONG>E-Mail Address:</STRONG></TD><TD><INPUT TYPE=TEXT NAME="email" SIZE=40></TD></TR><TR>
<TD ALIGN=RIGHT><P><STRONG>Subject:</STRONG></TD><TD><INPUT TYPE=TEXT NAME="subject" SIZE=40 VALUE="Re: How to hide the tabs in PropertyPage"></TD></TR><TR>
<TD COLSPAN=2 ALIGN=CENTER><P><STRONG>Message:</STRONG><BR><TEXTAREA COLS=80 ROWS=15 NAME="body" WRAP=PHYSICAL>
</TEXTAREA></TD></TR><TR>
<TD COLSPAN=2 ALIGN=CENTER><HR WIDTH=50%><P><SMALL>If you'd like to include a link to another page with your message,<BR>please provide both the URL address and the title of the page:</SMALL></TD></TR><TR>
<TD ALIGN=RIGHT><P><STRONG>Optional Link URL:</STRONG></TD><TD><INPUT TYPE=TEXT NAME="url" SIZE=40 VALUE="http://"></TD></TR><TR>
<TD ALIGN=RIGHT><P><STRONG>Optional Link Title:</STRONG></TD><TD><INPUT TYPE=TEXT NAME="url_title" SIZE=40></TD></TR><TR>
<TD COLSPAN=2 ALIGN=CENTER><HR WIDTH=50%><P><SMALL>If you'd like to include an image (picture) with your message,<BR>please provide the URL address of the image file:</SMALL></TD></TR><TR>
<TD ALIGN=RIGHT><P><STRONG>Optional Image URL:</STRONG></TD><TD><INPUT TYPE=TEXT NAME="imageurl" SIZE=40 VALUE="http://"></TD></TR><TR>
<TD COLSPAN=2 ALIGN=CENTER><HR WIDTH=50%><P><SMALL>If you'd like e-mail notification of responses, please check this box:</SMALL> <INPUT TYPE=CHECKBOX NAME="wantnotice" CHECKED VALUE="yes"></TD></TR><TR>
<TH COLSPAN=2><HR WIDTH=50%><P><INPUT TYPE=SUBMIT NAME="Preview" VALUE="Preview Message"> <INPUT TYPE=SUBMIT NAME="Post" VALUE="Post Message"></TH></TR></TABLE></CENTER></P></FORM>
<HR><P ALIGN=CENTER><SMALL>The MFC Discussion Board is maintained with <STRONG><A HREF="http://awsd.com/scripts/webbbs/">WebBBS 2.24</A></STRONG>.</SMALL></P>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -