MFC: allow docking to main view - mfc

In Visual Studio, you can dock arbitrary panes to the main view in the center of the window:
In the above image, the Error List pane is being docked to the main view.
I'd like to do that with CDockablePanes in MFC. However, it appears that by default, docking panes to the main view isn't allowed. Is this possible with MFC? If so, how is it done?

Panes are normally docked to the CMainFrame, and they can be docked above the main view.
If you need to dock them inside your view they should be created (and docked to) in the CChildFrame.
Make sure to use .EnableDocking(CBRS_ALIGN_ANY); and EnableDocking(CBRS_ALIGN_ANY);
In case you are referring to converting a dockable pane to a tabbed document, right click on the pane header and select 'Tabbed Document'.
Also check out CDockablePane::ConvertToTabbedDocument and m_bCanCovertControlBarToMDIChild.

Related

Is there a way to attach or anchor two QWidgets together?

I'm getting started with Qt and decided to build a full-screen text editor. I want to have a button (button with arrow in screenshot) attached to a QDockWidget which opens and closes it so the button is always visible to the right side of the screen and stay anchored to it when dock is visible or resized.
My current app is a simple fullscreen textEdit set to centeralwidget in Mainwindow.
I haven't found a way to do this yet with layouts or existing addAnchor() functions so any help or direction is appreciated.
You can achieve what you want by using a container for your text edit and the button. A QWidget instance can be used as an "invisible"*** container for other widgets.
So in Qt Designer you add a widget as a central widget of the main-window, inside this widget you add the text edit and the button, then you set a vertical layout for this container widget.
Don't forget to restrict the docking widget to only dock to the right side, you can do that with: dock->setAllowedAreas(Qt::DockWidgetArea::RightDockWidgetArea); //assuming dock is the pointer to your QDockWidget.
In case you want the dockWidget to be able to dock to any side and the button to follow, you can do that too, but it get a little bit more complicated. Basically you need to connect a slot to dockLocationChanged of your dockWidget and based on where it's docked you need to set-up a new layout for the container widget to be vertical or horizontal and the order of the textEdit and the button based on the side the dock happened.
LE:*** you will most likely need to set the margins you want, since both the widget and it's layout can have them and the actual content might have higher spacing than you want.

Docking on MDI Client area in C++

I need Mdi application with docked panels on all sides of MainFrame.
but dock panels I created can't to be docked to center of the screen, because of MDI Client area.
Is there any way to hide or remove mdi client area and enable dock panes to be docked to center of the screen?
Thank you for your help!!
There seems to be some issues with your design.
"Docking" itself means taking help of the sides of the window so that your panes can fit & rest over there.
If you want something to appear in the center then you would create a document that has a form view (CFormView). The form view will use the pane's dialog template.

How can I insert QDockWidget as tab

I have a lot of widgets in my application and I know I can drag them during runtime and place over another widget in order to merge them (both widgets are on same place and there are tabs under them which I can use to switch them).
How can I insert QDockWidget like this programmatically from start?
For example I want to add 2 QDockWidgets to bottom that are tabbed so that they are in same area and I can tab-switch them
If you want to layout two or more dock widgets as tabbed windows, you can either drag one dock widget over the other (as you properly described), or do that programaticaly using QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) function. As the function description says:
Moves second dock widget on top of first dock widget, creating a
tabbed docked area in the main window.

how to set the controls right aligned with the view in MFC SDI application

I have created a MFC SDI application, and the view is derived from CFormView, so i can put some controls on the dialog. I have put a groupbox at the right side of the dialog and put some other controls inside the groupbox, such as edit box etc.
What i want is the groupbox and the controls inside right aligned with the dialog when i am resizing the view, just like the followingbehavior in C#: set the anchor property of groupbox to be "Right"
The EasySize is what i want

Float a control over a CView

I've got an app that uses several CView-derived classes (actually CScrollView) to display document data. For one particular view, I want to add a fly-out edit box to add notes. That is, you'd see a tab at the bottom of the window labeled "Page Notes", and clicking on that would bring up the edit box. Clicking the tab while the edit box is visible would reduce it back to just the tab.
I thought I could use a one-tab CTabCtrl holding an edit box and just position it so that only the tab is visible initially. Capture the tab click notification and move the entire control, with edit box, into view. Clicking the tab again would move it back down so only the tab is visible.
Hosting the CTabCtrl on the CView is fine, and I can get it positioned correctly. The problem is that if the view is scrolled, the tab control is scrolled along with it, whereas I need it to "float" over the view and not be affected by any scrolling. I can move it back into place after the scroll, but the flickering is unsightly.
Is there a straightforward way to accomplish the "floating" effect? I mainly want the tab embedded in the view for maintenance, since it's the only view class out of the several in use that needs the "Page Notes" feature.
Should I just buckle down and put the tab in the view's parent window instead? I know it won't be affected by scrolling there, but I like the idea of keeping the tab as part of the view if possible.
It sound like the tab is functioning like a button. You click the tab and a fly out edit box appears. You could use a modeless dialog.
Select the "Page Note" and the modeless dialog comes up to edit your notes allowing you to scroll your view under the dialog.