MFC Tabbed Views - c++

I need a basic on how to declare/implement and use the CTabView class for an MFC SDI. I have searched in vain for samples and reference. I assume because MFC is not the most current foundation information is hard to find on certain topics, anything about tabs in particular. How declare an create the tabbed view object? When using add/delete view in the control, is the control creating the view or adding a tab to a view that is already created. Moving and Sizing? Truly appreciate any help. Need native C++ in this app, so answers that tell me how much easier in C# with a different foundation do not help.

Simply derive your view class from CTabView.
You can add as many tabs as you need by calling:
AddView(RUNTIME_CLASS(CMyView),_T("Tab1"));
AddView(RUNTIME_CLASS(CMyView),_T("Tab2"));
AddView(RUNTIME_CLASS(CMyView),_T("Tab3"));
You can also customize the location and other things of tab control by calling:
GetTabControl().SetLocation(CMFCBaseTabCtrl::LOCATION_BOTTOM);
GetTabControl().ModifyTabStyle(CMFCTabCtrl::STYLE_3D_ONENOTE);
GetTabControl().EnableTabDocumentsMenu(TRUE);
GetTabControl().EnableActiveTabCloseButton(TRUE);
GetTabControl().EnableTabSwap(TRUE);
from int CMyTabView::OnCreate(LPCREATESTRUCT lpCreateStruct)

Related

iOS Custom Tab Bar

I am looking to implement a custom Tab Bar in iOS where selected item is bigger size than the rest of the tabs and peeks out over the content similar to this screenshot.
Could someone point to a tutorial of how to accomplish this preferably in Swift?
I faced with this task several times. I found a lot of tutorials but I've never found one that gives the ability to create a center button that part of it is out of the tab bar.
At the end, I created an approach to have it done correctly. I implemented a simple example project with instructions how to do that. Please check my Custom Tabbar Center Button repo as an example.
One more benefit of it it's center button hides correctly with the tab bar when you use Hide Button Bar on Push property.
A UITabBar contains an array of UITabBarItems, which inherit from
UIBarItem. But unlike UIBarButtonItem that also inherits from
UIBarItem, there is no API to create a UITabBarItem with a customView.
So instead of trying to create a custom UITabBarItem, we’ll just
create a regular one and then put the custom UIButton on top of the
UITabBar
Not swift, but should be easily translated.
https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar
This one is Swift:
https://github.com/itsKaynine/SwiftRaisedTab
Source code for a similar question, using Swift 3:
https://stackoverflow.com/a/36016377/300897

Nondynamic Doc/View Architecture Usage in MFC

I have a problem in which there is bunch of data that will be displayed in two different ways and they should always be synchronized with data . Logically i thought of exploiting the Doc/View architecture on which mfc is based .
However The usage of MFC Doc/View architecture imposes the dynamic creation of document , view class by the Framework which is sth i don't want since i have to create the views myself within tab controls and DockablePane . Is there a workaround which let me take benefit of the Doc/View archiecture so i can create a view and corresponding document without the usage of dynamic creation by frameowrk ? sth like the qt's model/view technology !
What you want can be done within the MFC doc/view framework. It just takes more study. You can prevent MFC from creating a view at new document by passing NULL as the view class to AddDocTemplate. Then you can create views where you like using MFC's dynamic creation, specifically the CreateObject method. See the MFC source code for CSplitterWnd::CreateView as an example.
Yes, you can create two different views of the same document. If you always want both, the method MFC supports the most directly is a window with a static splitter, so you have one view in each pane of the splitter.
It's not (at all) clear what dynamic creation has to do with any of this though.

Creating tabbed document interfaces in Qt Designer?

I am trying to write a program that will use a tabbed document interface (TDI) like seen in Notepad++ or most web browsers. I know how to build GUIs using Qt Designer, and code in Qt C++ (after a few days of playing around).
I have created an example of what each page widget will look like using Designer, and now I want to add the ability to create and testroy tabs at runtime, each containing a unique instance of the page widget. However, I have no idea how to do this without adding a class that extends QWidget, and building the page widget with code. I could go down this route, but I'm sure there must be a better way of creating a TDI; but I can't find any tutorials or examples of how to do this.
Does anyone have any suggestions?
For creating tab interfaces you should look into QTabWidget.
It is a container widget included in Qt Designer which automatically handles operations on tabs. It has several build in methods for manipulating its tabs and theirs contents.
Each page of QTabWidget is handled separately and can have different layouts and functionality.
If you want to include several different objects to one page assign a layout to it and then assign the objects to the layout.

wxSmith a good way to manage wxPanel

I have a project where I'd like to have many wxPanel which are displayed or hide, depending the selection of the user. All panel are on the same position, only one is displayed at a time.
On a code side, there is no problem at all. Where it gets tricky, is how to manage this with wxSmith and keep a clear view while having many wxpanel at the sample location?
One way which is really not proper is to user the wxNotebook, and then when you start the soft delete all tabs and then show the needed panel.
I have look around to try to have the panel on a "other" wxSmith window and then load it, like a class but haven't find anything good.
I'm sure, as wxSmith is really a great tool that it must have a way to do this.
Thanks for your help!
See ya
"One way which is really not proper is to user the wxNotebook, and then when you start the soft delete all tabs and then show the needed panel."
Why not? I use that technique for AtomWeaver, and it works fine. The plus side is that you can design each page normally on a RAD GUI builder.
I've created a class called GUI_NotebookPageData that holds a pointer to a single notebook page. Create an array of these, holding info about all notebook pages.
Then, by index, or by name, get the info of the page you want to show/hide, and use wxNotebook's RemovePage()/InsertPage() methods.
This method is specially good for having several pages shown at the same time.
Actually it's possible to use external ressources with wxSmith, then it's very simple to manage the frames.
It create a derived class from wxPanel (or other window) on a new wxSmith window, easy to manage then just required to include it on the project.

How can I visually design a component in C++ Builder?

I have been away from C++ for a couple of years now doing AS3/Flex work. I have gotten used to being able to create a component and place it in design mode with very little fuss and I am struggling to get my head around the C++ Builder way of doing the same thing.
I have written many components for C++ Builder in the past, but none of them have been visual. What I would like to do now is create a component for customer search and another for order processing because I want to be able to create a new instance of these on the fly. What I don't want to do is have to place each of the components like the dbgrid and search fields manually in code. I would like to do this (as well as set their properties) in design mode.
How do I go about this? I have browsed the source for other Delphi components and I notice they have dfm files which seems to be what I need. How do I do this in C++ Builder? The only option I see is to add a new form if I want a dfm, but this isn't what I want as my components will be based on TPanel.
Is there a way to do this or do I have to resort to doing it all in code with no visual reference?
Pursuing the DFM idea I did a test this morning where I created a component based on TPanel and added a new form to it which I create and parent in the constructor of the component. In design mode I set the form border to none and placed a grid on it. This all looks OK until I place the component in my application, at that point it looks like a panel with a standard looking form in it and the grid is missing. If I run the app the panel shows as expected, borderless and with a grid. The DFM appears to be ignored in design mode for some reason.
If you know a better way to do this than using components then please give me some pointers.
Any help and advice will be appreciated beyond words
You might want to have a look at frames (look for "Frame objects"). They are "subforms" you can design visually and then place on forms.
Just as an FYI item, you can also drop the panel on a form, put any other controls on it, position them, set captions, etc..
Now, click the panel to select it, and use Component->Create Component Template from the IDE's main menu. This creates a unit you can install as a component which will add the panel and it's sub-controls (as a single component) to the IDE's component palette.
Of course, you can then modify the source for that new component like any other component source.