How do I bring a CDockablePane which is docked into a tab to the front - mfc-feature-pack

I have an MFC application (which is using the feature pack), it has multiple classes which inherit from CDockablePane that can be docked around the application, my application much like visual studio has docked multiple of these panes to a tabbed area at the botton.
Output | Error List | Watch | Thread
etc...
However on some event I would like to bring "Watch" to the front of that tabbed document so that its contents is visible.
Does anyone know how I do that, bearing in mind that "Watch" may also be docked on a side on its own, but also maybe floating
Many thanks in advance

You need to set this as the active tab, and the easiest way to do that is using the ShowPane() method:
m_MyPane.ShowPane(TRUE, FALSE, TRUE);
The last parameter is "bActivate".

Related

MFC EditBrowse control does not display the folder icon at runtime

I have a dialog type application that includes a MFC EditBrowse Control. This control includes a folder/magnifier icon on the right side where the user is supposed to click to bring up a folder browser pop-up.
That folder/magnifier icon displays properly in the dialog editor within Visual Studio, but at runtime it displays as a plain flat button. It behaves properly otherwise - that is, the browser pop-up pops up and the selected folder is displayed when the user clicks OK.
When run with the debugger a message is displayed in the VS Output Window saying "Can't load bitmap: 4299". That message is displayed after the CDialogEx::OnInitDialog() line within my OnInitDialog().
I've written test programs and they display the icon properly. I've also added additional EditBrowse controls in my original program, but they experience the same problem and just add another line of "can't load bitmap". I've also added other MFC controls and some of them also do not display their icons (or other stuff).
I've managed to affect the problem slightly by making calls to EnableBrowseButton() and EnableFolderBrowswButton() from my OnInitDialog. If I do that, I get an icon that looks like 3 horizontal dots:
which is better, but I'd prefer the folder/magnifier icon.
It's a complicated enough application I'd rather not re-write it from the beginning and furthermore I'd like to understand what is going on. I'm fairly certain this is a result of adding/deleting controls as the app was developed, but don't have a good idea on where to begin tracking down where things went awry.
Thoughts on how to debug this? BTW, this is VS 2010.
CMFCEditBrowseCtrl uses the Visual Manager to load the bitmap from MFC resources.
This resource is loaded in "afxribbon.rc"
Make sure the following these lines are included in the main *.rc file (this is how VS Wizard creates the *.rc file)
#if !defined(_AFXDLL)
#include "afxribbon.rc" // MFC ribbon and control bar resources
#endif
(I guess you can omit the #if/end statement, but it's probably there for a reason)
Alternatively, CMFCEditBrowseCtrl::SetBrowseButtonImage can be used to assign user icon.

How to display two classes at the same time with Visual Studio 2013

I need to see and edit multiple classes at the same time.
With Eclipse I can achieve it with drag&drop.
Is it possible with Visual Studio 2013 Express and how?
Something similar to this:
With at least two files open, you can use the "Window->New Vertical Tab Group" or "New Horizontal Tab Group".
This will create a new pane and you can move tabs between them.
You can do the same with a single file by using 'Window->New Window'. That creates a second view of the same file and you can then split as a separate group.
You can split a window by dragging an almost-invisible handle at the top down, this shows you 2 areas for the code. I don't think you can do it side-by-side however, unless you undock the code window for one of the files you're working on and position it to the side.
You can dock one code window to the side of another. Marc Gravell's answer below to a similar question shows how:
Undocking a code window in Visual Studio

How do I add a window from the resources as a child window?

I am creating a windows using win32:
HWND mainWnd = CreateWindow(...);
Now I can add gui elements as children of mainWnd. However this soon becomes a bit tedious and I want to use the designer built into Visual Studio to help me.
I noticed that under Add Resource there is a Dialog entry. Among the dialogs IDD_FORMVIEW seems the most general so I added one of these. Next I added gui elements to it using the designer.
Now I want to use this as a child of my mainWnd. How do I do this?
I found some examples using DialogBox, but I do not want a separate dialog, I want this window as a child of my mainWnd.
The designer in Visual Studio is appropriate for creating dialog boxes, not arbitrary windows.
That being said, there are a couple of approaches (in increasing order of difficulty):
Make your main window a dialog. Petzold's book has an example of using a dialog as the main window of the program. (If I recall correctly, it's the calculator example.)
Create the dialog and, before you show it, change its style to WS_CHILD, change its extended style to WS_EX_CONTROLPARENT, and parent it to your main window. For all the navigation stuff to work, you'll have to add IsDialogMessage calls in your message pump. This is do-able, but it's likely hard to get everything working well.
A mixture of 1 and 2 where you create one dialog for your main window, then create a second dialog for the content (with DS_CONTROL), and put the second dialog in the first. I've never tried this approach myself, but it seems like it should work.
Write your own code to parse the dialog resource and create the child windows, which is basically re-doing a lot of the work that CreateDialog does for you.
Given your desire to use the GUI to design the UI, I suspect only the first solution is simple enough that you would be interested.
Use the CreateDialog API to create the window from the resource. If you do not want it to look like a dialog then remove the titlebar style from the resource properties.
To use a dialog created from a dialog resource template you have to specify the DS_CONTROL window style in the template.
Read more about dialog boxes here.
Dialog resources are explained here

Is it better to disable or omit context/popup menu options?

My application is context-sensisitve and I dynamically build menus for the main window / context/popup, and other places. I typically know if a given menu command will be valid given the current state of the application. Is it better practice to DISABLE/GREY the menu options which currently do not apply OR since I'm generating the menu anyway, OMIT them entirely?
The application is a Java/Swing is anyone is curious. The question seems GUI toolkit agnostic but may be platform dependent.
The old apple guidelines say to Disable for fixed menus (in the menu bar), and omit for context menus.
I guess the motivation is that a context menu is supposed to only show options that are available to the particular context, and the main menus are supposed to show all commands, so the user knows where "Save" would be even if it's not selectable at the moment.
For right-click menus, I'd say that if the item is applicable to what was right-clicked but is for some other outside reason unavailable, disable it. If it is not applicable to the right-clicked thing then hide it as there's no chance of it ever showing up. Case in point:
When I right-click on the background area of this page in Firefox the first four items are Back, Forward, Reload, and Stop. Forward and Stop are disabled because they aren't valid actions right now (I have no forward history and the page is not loading anymore). These four guys are very consistently offered, they are expected, global, often-used commands. They are the four main "navigation" controls and by default they have toolbar counterparts (in the form of big dedicated buttons).
However, if I right-click on an image, I get completely different options in the context-menu all related to viewing, saving, and copying the image under where I clicked. These options don't appear at all (not even disabled) under normal use because they are very specific to what I right-clicked on. When right-clicking on the background area, Stop and Forward, while currently not valid actions, are still applicable to what I clicked on (the page) but they are unavailable for other reasons...
Like the rule for menus on the top menu bar, the goal is not to surprise users with commands suddenly appearing for, from the user's point of view, inexplicable reasons.

Multiple Monitors with Visual Studio 2008

I've got 2 monitors, and most of the time I've got some reference material open on one screen, and Visual Studio on the other. To really get in the zone, though, I need my code to be the only thing I see. Does anyone know if it's possible to have multiple code windows in Visual Studio? So far the best I can do is put debugger output and the solution explorer on my left monitor, and the rest of VS on the right. I would love to have code on both windows, however.
If you right click on the file tabs, there's an option for "New Vertical Tab group" Just maximize across both monitors and put the divider on the monitor divide and I think that's what you're after.
See also the "Visual Studio and dual/multiple monitors: how do I get optimized use out of my monitors?" question.
Though I use StudioTools for other purposes, it has a "Tear off Editor" option, with which you can "tear off" the file to a window and resize the window. Find it quite helpful
Instead of enlarging the VS2008 window to span the two monitors, you can display the 'Code Definition Window' on another monitor: just drag it outside the main window! I find this very handy to avoid switching between code windows: it is very often that one is interested in the definition of the symbol under the cursor...
The same is true for other windows like the 'Class View', the 'Call Browser', etc. You can choose to keep them grouped in the same group with tabs, or drag each of them separately (click on the label of the tab to start the drag).

Resources