A way to group controls in Visual Studio - visual-studio

In Adobe Illustrator and other drawing programs I can group objects so I can move them together, resize them together, or treat them as a single object when I'm doing alignments. Is there a way to do this in Visual Studio 2012? I've seen GroupBox, but that's not what I want because that's a programming object instead of a behavior of the IDE. And how can I make it such that I can, say, keep two controls fixed in position but still align or change the spacing of third a third with respect to them?

In Windows Forms you group controls by dropping them inside the same container. Then moving the container, or disabling it, or hiding it, anything really, also affects every child object too.
Rather than a GroupBox though, I'd recommend a Panel. It's a light weight object who's sole purpose is to just host controls.

Related

Override Visual Studio 2010 UI behavior

I would like to create an extension for visual studio in which some UI behaviors are overridden. I have found many examples of adding UI components to VS, but none where they change them. A very good example of what I want to do is make it so that each tab takes up exactly 50 pixels in width (at the top of the editor window group). Is this possible? If so, what would be a good resource for me?
For your specific example, the Document Tab Well extension inside the Productivity Power Tools pack lets you set minimum and maximum widths for the editor tabs, so you could force it to 50 pixels if you want.
In general, there is no uniform way you can override or replace UI components in Visual Studio. A few components were designed to be easily replaced, while some components cannot be replaced, but many aren't replacable. The general problem with replacing components is it fails the "what if two extensions want to do it test", because it's not clear which replacement wins. Thus most extension points are add-only.
My advice: if you want to replace a specific component, ask a separate question on Stack Overflow and hopefully somebody can chime in on how to customize that particular component.

Adornement layer in Visual Studio 2010 editor randomly moves by scrolling

I am trying decorate code lines with various metrics collected during an execution of a program. In order to do that I use VS extensibility and adornments layer. However it seems to be somewhat unstable and moves relative to the top of the document when the editor is scrolled and thus spoiling the alignment of code and the adornment. Also it is not always initialized in the top of the editor.
So how to anchor theadornment layer added to the code editor in Visual Studio 2010? I add a canvas into it by the folling way:
_adornmentLayer = view.GetAdornmentLayer("CodeAdornment");
_adornmentLayer.RemoveAllAdornments();
Canvas.SetTop(myOwnCanvas, 0);
adornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, myOwnCanvas, null);
I start to have a feeling that it is a bug in the editor layouting.
You might want to make a viewport adornment that will always be on the top of the editor. Otherwise, you might want to use AdornmentPositioningBehavior.TextRelative and give a span for the first line in the document.

MFC 10 - Is it possible to have a CFrameWnd within a CView?

I'm using MFC (yes must be MFC and no I can't interop with .Net) to create a CFrameWnd.
My goal is to create a CFrameWnd containing a CFormView which is based on a Dialog Template that resembles something like:
I have got the frame and view to display, and I have an Edit control on there. Now what I want is to have a CToolbar aligned to the top of the Edit Text control but not docked to the top frame.
Ideally I would like to have a child frame/view that I can dynamically add in place of the Statement Group. That way I could just dock the toolbar as normal.
The thing that I find odd is that I could easily achieve this if I had a splitter in there by using the CreateView function. I really don't want to have a splitter and feel there ought to be another way.
In summary, these are the question I need help with:
Q1 - How can I have a CFrameWnd within a CView (like what CSplitter::CreateView does)?
Q2 - How can I position a toolbar within a CView without docking or floating it within another frame (I'm more than willing to resize, position it manually if only I knew how)?
Now I really appreciate how easy things are in .Net.
I wouldn't recommend sticking a CFrameWnd within a CView. You'll be fighting MFC all the way, basically living in a world of ASSERTs as the internal functionality such as message routing assumes that Frames don't live in views.
Instead just use a CWnd instead of the CFrameWnd and in the 'Create' method manually create the toolbar and the edit ctrl and size and position them yourself (create a AdjustLayout method that uses CMFCToolbar::CalcFixedLayout to adjust the position of your other components).
A great example of this is in the Visual Studio sample app PropertiesViewBar.cpp:
http://msdn.microsoft.com/en-us/library/bb983983(v=vs.90).aspx
Note: You might need to override OnCmdMsg to extend the message routing to the internal controls.

Spacer between elements in visual studio

What shall i use to make a spacer between elements in visual studio like that in QT
http://www.tuxradar.com/files/qt_menq_spacers.jpg
You might be able to use the Margin and Padding properties of any control to that end.
Edit: In response to your comment, I get the impression that your main goal is not to add a certain amount of space between controls (which would be what the Margin and Padding properties are for), but that you want to align controls along certain lines or edges. In Winforms, this is usually done via a combination of panels and the proper use of a control's Anchor and Dock properties.
You can use Anchor property to position controls relative to the dialogs edges.
And you can use a couple of panels to separate controls into different areas.
But I donĀ“t think there is some thing like the spacers you mentioned in the question.

Need Help: VS 2005 Properties Changing

I am working in Visual Studio 2005. I have multiple splitters on the screen. I have set the splitters IsFixed and I have also set fixed panel sizes. In addition to this I have locked the control. For some reason, when I switch into debug mode the splitter distance value is changing entirely on its own. These changes do not take place with any consistency, the vary in distance changed. Other components, which are also locked, are moving all on their own as well.
Anyone with similar experience? Any ideas?
The settings will stick to either mode you are in. But sometimes plugins or parts of VS does mess it up :(
I recall seeing a plugin written to save 'views', but when I tried it, it didnt work.
I couldn't tell you what is causing this. The way that the windows forms splitter works is through the Docking property. There should be no need to lock the controls. All of the controls on the form should be docked. (Including the splitter)
For example, if you want to split vertically, you have your first panel docked left. Then the splitter (Orientation set to vertical) is also docked to the left. The second panel is docked to fill. The width of the first panel (which is docked left) will determine the location of the splitter. It should not change now.
The z-order is important here for layout purposes. If you want a more detailed look of how the controls are laid on on your form, open the Document Outline. This will list the controls in a tree, and you can see where they are in the z-order.

Resources