|
-
September 14th, 2009, 03:04 AM
#1
MFC TabControl Pages
Hello everyone!!
I've created a MFC Dialog Application, and I put a tabcontrol on it, then I've read somewhere to manage with pages I have to create modeless dialog template and class turning off titlebar and border, so I did.
BUT, to put that modeless dialog template into the page of tabcontrol I've read also to use MoveWindow to position all of the dialogs on the control...what would that mean?...Since MoveWindow would change simply position and dimensions, how it would be used to put templates in tabcontrol's page?...
Thanks
Ciao,
Luigi
-
September 14th, 2009, 06:51 AM
#2
Re: MFC TabControl Pages
Of course you have to have all your dialogs already created (by templates you mentioned), and have them all invisible except the one you currently show up.
Best regards,
Igor
-
September 14th, 2009, 07:34 AM
#3
Re: MFC TabControl Pages
 Originally Posted by Igor Vartanov
Of course you have to have all your dialogs already created (by templates you mentioned), and have them all invisible except the one you currently show up.
Yes in fact I did that...I removed titlebar and border plus I settled visible = false... but how I can put that template in tabcontrol's page?...
-
September 14th, 2009, 11:23 AM
#4
Re: MFC TabControl Pages
See this sample. And forget about template. Template is a resource. Since a dialog is created (by a template), it's already window but not template.
Last edited by Igor Vartanov; September 14th, 2009 at 02:00 PM.
Best regards,
Igor
-
September 14th, 2009, 01:35 PM
#5
Re: MFC TabControl Pages
 Originally Posted by Igor Vartanov
See this sample. And forget about template. Template is a resource. Since a dialog is created (by a template), it's already window but not template.
Ehm, the link doesn't work....returns a 404 page....
-
September 14th, 2009, 01:59 PM
#6
Re: MFC TabControl Pages
Yep, sorry. Try this one.
Best regards,
Igor
-
September 15th, 2009, 09:26 AM
#7
Re: MFC TabControl Pages
Hiya Igor,
I saw the template but that example refers to a non-resource modeless CDialog, when I need to have a template resource because I put controls on each like EditBox, RichEdit..etc etc...
Actually I started with a main CDialog interface where I put from component's toolbox a tabcontrol and creating 4 tabpages...
Then I created four CDialog class templates with resource where I removed border (Border = none), titlebar and settled Style as Child.
In one of them I put another tabcontrol with 2 tabpages.
The issue I have actually is I made a ShowTabDlg function as following your example:
ShowTabDlg(int TabSel)
{
for(int idx=0; idx < ARRAYSIZE(m_dlg); idx++)
m_dlg[idx]->ShowWindow(SW_HIDE);
CRect rc;
pTabDlg->GetClientRect(rc);
pTabDlg->AdjustRect(FALSE, rc);
pTabDlg->ClientToScreen(rc);
m_dlg[tabSel]->SetWindowPos(NULL, rc.left, rc.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_SHOWWINDOW|SWP_NOACTIVATE);
}
and a OnSize (related to WM_SIZE message and ON_WM_SIZE() on begin_message_map) always for each tabpage:
OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CWnd* pWnd = GetDlgItem(IDC_TABPAGE1);
if (pWnd)
{
CRect rect;
pWnd->GetWindowRect(rect);
ScreenToClient(rect);
rect.right = cx - rect.left;
rect.bottom = cy - 10;
pWnd->MoveWindow(rect);
}
}
BUT I couldn't get those CDialog templates fit in each TabPage....it goes like in the bottom-right of the main window if main CDialog isn't maximized and when maximized it goes indeed at almost the top-left of the tabcontrol... what could I have missed?...
-
September 15th, 2009, 07:52 PM
#8
Re: MFC TabControl Pages
that example refers to a non-resource modeless CDialog
My sample deals with resource dialogs, you can easily see that in .rc file. 
what could I have missed?
You've missed to upload a sample project (you could take mine) along with comprehensible description of your problems (maybe including screenshots).
Best regards,
Igor
-
September 21st, 2009, 08:25 AM
#9
Re: MFC TabControl Pages
Hello Igor and everyone...
I figured out using easier's CPropertyPage and CPropertySheet which are similar to tabcontrol....
BUT Just a little doubt: since I want to have a container component to put some controls like edit box, buttons, labels and stuff so I can reposition the container at the center when I resize the form and there is no Panel... I was thinking about creating something like a Frame...but how I could create a frame by resource then putting it in the PropertyPage since I don't see something like IDD_FRAME or whatever in the Dialog Resources.... (IDD_DIALOGBAR, IDD_FORMVIEW, IDD_OLE_PROPPAGE_LARGE...)
Thanks
Ciao,
Luigi
-
September 21st, 2009, 12:45 PM
#10
Re: MFC TabControl Pages
In MFC, for each property page, you create a dialog resource with the frame style set to 'child'.
Then you create a class for the dialog derived from CPropertyPage.
In the later versions of visual studio, to create a class, just right click on the dialog when opened in the resource studio, and choose "Add Class...".
From there, choose CPropertyPage as the derived class.
This will create the necessary CPropertyPage class that can be used with a CPropertySheet.
In VC6, create the CPropertyPage derived class using the Class Wizard.
-
September 21st, 2009, 06:35 PM
#11
Re: MFC TabControl Pages
Hello Arjay,
I did that! Just I'd like to have a container to keep some controls inside so I can "center" the container when I resize the dialog application window which resizes also the propertysheets....
But I don't need to resize also the controls, indeed I need to center the controls in the propertysheet and I thought I'd do with a "container" like an IDD_FORMVIEW or so like it's a Frame container.... any idea?...
Thanks
Luigi
-
September 21st, 2009, 08:03 PM
#12
Re: MFC TabControl Pages
Not sure of your approach. What I would do is replace the main application dialog with the propertysheet dialog in CMyWinApp::InitInstance( ).
-
September 22nd, 2009, 12:21 AM
#13
Re: MFC TabControl Pages
I'm finding a way to have a container where to put some controls inside like edit box, labels, checkboxs because I tried to use a Group Box, then putting those controls inside and in OnSize of the CPropertyPage I put this:
CWnd* pWnd = GetDlgItem(IDC_GRP_BOX);
if (pWnd)
{
CRect rctDlg;
pWnd->GetWindowRect(&rectDlg);
ScreenToClient(&rectDlg);
pWnd->MoveWindow(rectDlg.left, rectDlg.top, cx - 2 * rectDlg.left, cy - rectDlg.top - rectDlg.left, TRUE);
}
but the GroupBox doesn't keep inside the controls and move them where the GroupBox goes... so that's why I'm looking for a way to have a controls container which I can center in the CPropertyPage. In this way I was thinking about something like a Frame with a fixed dimensions where to fill with those controls; then load the Frame inside the CPropertyPage so in the OnSize I can MoveWindow the frame in the center of the CPropertyPage.
So the question is how I can create a Frame-like with resources?...
-
September 22nd, 2009, 10:03 AM
#14
Re: MFC TabControl Pages
Groupbox isn't a control container like it is in a different environment like VB or .Net. In Win32 (i.e. MFC), GroupBox is just another control so you need to resize it like any other control.
When you need to resize several controls within the OnSize handler, use DeferWindowPos to help reduce flickering.
Code:
void CMyDialog::OnSize(UINT state, int cx, int cy)
{
HDWP hdwp = BeginDeferWindowPos(3);
if (hdwp) hdwp = DeferWindowPos(hdwp,
m_GroupBoxCtrl.GetSafeHwnd( ),
NULL, 0, 0, cx, cy,
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
if (hdwp) hdwp = DeferWindowPos(hdwp,
m_NameFirstCtrl.GetSafeHwnd( ),
NULL, 10, 10, cx-20, 30,
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
if (hdwp) hdwp = DeferWindowPos(hdwp,m_NameLastCtrl.GetSafeHwnd( ),
NULL, 10, 50, cx-20, 30,
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
if (hdwp) EndDeferWindowPos(hdwp);}
Note: the actual size params aren't correct - I just threw in some values for the example.
-
September 23rd, 2009, 02:00 AM
#15
Re: MFC TabControl Pages
 Originally Posted by npuleio
I'm finding a way to have a container where to put some controls inside like edit box, labels, checkboxs because I tried to use a Group Box...
The container name is... a dialog. I have no idea why did you do that (finding a way to have a container other than the main dialog), but you always can have a child dialog window belonging to your main dialog. The evident demerit is: you need to have separate dialog procedure for a child dialog, and therefore, some way of communiction between the dialogs.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|