I have a design like below:
So basically, I want to embed three dialogs in the application main dialog and switch between them, for each button click i.e., button 1 will show dialog one , button 2 will hide dialog 1 and show dialog 2 .. and so on.
Each dialog will be having a different design and functions.
I tried using CPropertySheet class to Add pages but its GUI is different. It has either option for navigating the dialogs using next / back button , or from a tab control.
None of which is as per my requirement.
So I want to know is it possible to have a design like this in MFC ? If yes how? Which Class/ control should I use.
Any help will be appreciated.
What you can do is use a normal CDialog class, add your buttons to it and also create a frame/rect as a placeholder for where your embedded dialogs are to appear. The following piece of code will create and position your embedded dialog.
CRect rect;
CWnd *pHost = GetDlgItem(ID_OF_YOUR_FRAME_RECT);
pHost->GetWindowRect(&rect);
ScreenToClient(&rect);
pDialog->Create(ID_OF_YOUR_DIALOG, this);
pDialog->MoveWindow(&rect);
pDialog->ShowWindow(SW_SHOW);
On button clicks, you hide the previously shown dialog (SW_HIDE) and show your selected dialog(SW_SHOW) with ShowWindow(...).
If you create your embedded dialogs with IDD_FORMVIEW style in the add resource editor it'll have the proper styles for embedding.
Another option is probably to use an embedded PropertySheet and hide the tab row and programatically change the tabs on the button clicks. I just find it to be too much fuzz with borders, positioning, validation and such for my liking.
If you have the MFC Feature Pack, that first came with VS2008 SP1 and is in all later versions, you might like to consider CMFCPropertySheet. There are a number of examples on the linked page, that are very similar to your design.
For example, this:
What worked for me just using dialog based application is SetParent() method. Dont know why nobody mentioned it. It seems to work fine.
I am doing like below:
VERIFY(pDlg1.Create(PanelDlg::IDD, this));
VERIFY(pDlg2.Create(PanelDlg2::IDD, this));
VERIFY(pDlg3.Create(PanelDlg2::IDD, this));
::SetParent(pDlg1.GetSafeHwnd(), this->m_hWnd);
::SetParent(pDlg2.GetSafeHwnd(), this->m_hWnd);
::SetParent(pDlg3.GetSafeHwnd(), this->m_hWnd);
Now I can show or hide a child dialog at will (button clicks) as below:
pDlg1.ShowWindow(SW_SHOW);
pDlg2.ShowWindow(SW_HIDE);
pDlg3.ShowWindow(SW_HIDE);
I have created a custom toolbar for IE. After I install opens IE9 browser, the toolbar is displayed.
1) When I open InPrivate browsing, my toolbar is not displayed in the browser. It is not listed in context menu too. This happens in IE 9 & 10 versions.
2) When I switch to Fullscreen mode by pressing F11 in IE, my custom toolbar is not displayed.
Are these expected behaviors for IE or do I need to add any code to make it visible.
Please suggest.
Regards,
Santhosh
We have two ways in which we scroll through the tabs in the CMFCTabCtrl, either using the two buttons to scroll the window tabs or an interface that displays a pop-up menu of tabbed windows. This option depends on the EnableTabDocumentsMenu method in the CMFCTabCtrl. Be defualt the tooltip option on this button(menu) is "Active Files".
Same tabbed control seems to be used in Visual Studio even and I see the same tooltip there?
Is there any way we can change this tooltip text?
The tool tip is set to IDS_AFXBARRES_OPENED_DOCS ("Active Files") in afxtabctrl.cpp when you EnableTabDocumentsMenu. To change it try calling:
m_btnScrollRight.SetToolTip(_T("My Customized ToolTip"));
Your main problem is that m_btnScrollRight is protected so you're probably best off inheriting from CMFCTabCtrl and doing it in your own class (after calling EnableTabDocumentsMenu).
Is it possible to have enabled radio buttons though the user cannot change the value?
It is possible. If you create your radio buttons with the BS_RADIOBUTTON style instead of BS_AUTORADIOBUTTON then Windows will not automatically change the selection when the user clicks a radio button. (In the dialog editor in Visual Studio, right click the radio button and set the Auto property to False.)
Read the "Using Radio Buttons" section of this page in MSDN for more information.
either you can setchek it to BST_CHECKED and the EnableWindow to FALSE
or..
on every other selection of radio button make the radio button that you need selected
I have an MFC CToolBar (dockable to a CFrameWnd) containing a checkbox and a button.
This works fine now, but I need to remove the button, and then the CToolBar does not show properly any more. As it seems because it gets "zero" height. The checkbox style is "turned into" a TBBS_SEPARATOR using a call to CToolBar::SetButtonInfo before it is "created".
How can I make the toolbar visible also without that dummy button?
I solved this by overriding the CToolBar::CalcDynamicLayout method and provided the size of the toolbar there. Then the button was not needed any more. This assumes the toolbar is created with CBRS_SIZE_DYNAMIC.