How to see the list of objects in current file in Visual C++ 2012? - c++

Assume we have the huge Visual Studio solution and there are many files (tabs) opened. Does Visual Studio 2012 (Visual C++ particularly) have any View panel which will show the interactive list of objects from the current file when I switch to the corresponding tab? Or maybe there is an official extension which will help me? The standart Object Browser is not exactly what I want, because I'd like to see the list of all objects from the current file and only them.
Thanks!
Edit: I mean the list of all classes, structures, variables, methods etc., no matter declared or only defined in this file.

Did you try Visual-Assist extension? It might be helpful.
http://www.wholetomato.com/default.asp

Use Object Browser.
The Object Browser lets you select and examine the namespaces, classes, methods, and other programming symbols available for use in your project. You can open the Object Browser from the View menu, by clicking the Object Browser button on the main toolbar, or by typing CTRL+ALT+J. It will work for VS2005, VS2008, VS2010 and VS2012. Check out here for more info.
EDIT: If you want to see a so-called global tree view. I only know this works for WPF projects. You can use the WPF Tree visualizer to explore the visual tree of a WPF object, and to view the WPF dependency properties for the objects that are contained in that tree. For more information about visual trees, see Trees in WPF. For more information about dependency properties, see Dependency Properties Overview. Check out here.

Related

In Visual C++ 2017: Where in the property pages does it say what Application Types correspond to the projets?

I am trying to recreate a Visual C++ Solution that had about 30 projects so that the general organization will be cleaner.
The original "solution" was in fact a Visual C++ 6 workspace from the turn of the century, migrated into VS 2017.
Some of the projects will be close to being clones of the old ones.
When I try to create a project, I am asked what Application Type it must be:
Single Document/Multiple document/Dialog based or Multiple top level documents.
I thought I could guess this by looking at the property pages of the existing documents, but I can't seem to find it. Or am I likely to be going in the wrong direction?
As far as I'm concerned, we couldn't guess this by looking at the property pages of the existing documents. I suggest that you could check MainFrm.cpp in the project source file to distinguish the project from a single document / multiple documents / dialog based or multiple top-level documents.
A multiple documents:the document's frame window can hold multiple child windows.
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx)
A single document:the document's frame window can hold only one document.
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)
dialog based: There is no MainFrm.cpp in the source file.
multiple top-level documents:Creates a multiple top-level architecture for your application, where a view class is based on CView.
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWndEx)
clicks New Frame on the File menu:
For more details, I suggest you could refer to the Application Type, MFC Application Wizard

How do you change your app icon in visual studio 2013?

I'm new to visual studios and I just created this very short calculator and I want to put it on mediafire for people to download but I wanted to change the icon..
I've heard that you select your app in solution explorer and Project>Properties
But my properties menu seems different.
It saids calculator property pages.
It doesnt have the tabs like ~Publish~ or ~Applications~ where people said you change your icon.
My properties is like this:
Configuration: Active(Debug)
and some other stuff below it some complicated stuff(to me)
Why doesnt mine have what other people have? I just want to share my first ever app with a custom icon. Help please, will appreciate it.
Create a text file, rename it res.rc, edit it to contain the line:
201 ICON "myicon.ico"
Add that file to your project. The file myicon.ico must exists.
Note: This is a bit hacky, the numerical vaulues should preferably be defined in a header.
You might be confused because Visual Studio supports different languages, and its UI is not consistent across those languages. Since you tagged it C++, the "old" rules apply. An application icon is a so-called resource.
You have to provide an .ico file, and reference it in a .rc file. The resource compiler (RC) compiles it into a .res file, and the linker then adds it to the EXE.
In C++, if you open the form in designer view, the properties window has an icon property that will allow you to browse for the icon of your choice.
Just for reference, i spent two hours trying to change it without any success until i resized the icon, it should be 32x32 and another one for small icon -not sure if its necessary though- with 16x16.
visual studio creates two icons when create the project , one is called small.ico and one is name yourexe.ico, just replace those and make sure to have correct sizes.

Renaming a form in Visual C++

I start Microsoft Visual Studio 2010. I chose to start a new project on the Welcome Page. Ofcourse my preferred language is Visual C++ and I'm chosing to begin a Windows Forms Application. I give up a name like Calculator for this one. I do not touch the other options on this dialog. The project gets created and a new Form1.h is automatically added to the project, and a Form1.resX is also added. Because 'Form1' is useless to me, I'dd like to rename it to something more VB6 style, like "frmMain.h". So I right click the Form and simply chose "Rename". After accepting my new name, the necessary changes seem to be occuring. first impression But now, when I try to build this project, It gives a BUILD FAILED. When I look into my files.. Form1 is still mentioned..
So my question is: How do you actually/OFFICIALLY rename Forms?
I've been reading a lot about this and mostly the answer is to delete the form, and re add a new with the right name.. I've heard also that VS asks to rename all references to it, but that doesn't show up to me. Some other people say, you have to use the quick replace function, and rename all references to this class and its file.. This is not a good way to me.. Or is it really the standard procedure?
I have programming experience in C++ and I know about classes and polymorfism and so on. But this is one of the simplest things that keeps me annoying!
You are using VC++.NET to create .NET applications (Windows Form in your case). I must warn you that VS is not very friendly for VC (refactoring, renaming, and little intellisense).
In this case, you renamed the form which will make VS also rename the Form1.resX, but it will not rename the class. It will do it if in C# or VB.NET. Just open the .h file and rename the class itself to match the name of the file.
You also need to update the main .cpp file where "main" resides, and update the Application::Run(gcnew Form1()); in there as well include the "#include".
A solution replace will work (Ctrl+Shift+H), but be careful with this.
click on the form -> properties -> text (usually named as Form1) -> change it.

Implementing a custom wizard for Visual Studio for custom C++ classes

in order to make new C++ classes conform to some rather picky coding conventions (upfront: I am not in the position to discuss these...), I was thinking about a way of generating stubs for new C++ classes. Currently, everyone is doing copy-paste, regularly missing some detail. The IDE in use is MS Visual Studio 2005, but I think there has not been much of a change in 2008 and 2010 regarding these topics.
My first idea was to implement a command line script to do this, which would be fairly straight forward to do. Alternatively, I thought about using a default VS extension mechanism for better IDE integration. So, this would be hooking in some custom stuff when selecting Add->New Item... on a filter (Solution Explorer).
After some investigation, I found out there is an easy-to-use templating mechanism, which unfortunately does not work for C++ (http://msdn.microsoft.com/en-us/library/6db0hwky%28v=vs.80%29.aspx). For C++, it seems like you have to implement a custom wizard instead, incorporating html for the layout and javascript for the logic.
Regarding the custom wizard approach, I've come to the conclusion that this would require some effort (at least for me) to get this done. MSDN is not very detailed on this topic. I've found some walkthroughs in the web, which are dealing with custom wizards for projects only (Add->New Project... instead of Add->New Item...).
So, here's the qn: Anyone having done this or something similar? Is it (better IDE integration) worth the effort (coping with the details of custom wizard implementation), or would you suggest the go for the command line tool instead? More than two days of work would not pay off in the current project, I guess.
If you think custom wizards are great, maybe you can give some hints to get started. Also, maybe there are alternatives I did not come up with. VS Add-Ins seemed to be over the top for this, and adapting e.g. VC\vcprojectitems\newc++file.cpp will not do the job.
Thanks in advance and best regards...
Jerb
I have done something similar using a custom wizard.
For my purposes I just wanted to inject some simple macros into each class to insert it into a static factory object.
I didn't need to modify the actual wizard, just copied the default generic class wizard and modified the code generation javascript.
The documentation is rubbish on the topic, but here is a good place to start for the javascript (that is where you are going to get the most power):
http://msdn.microsoft.com/en-us/library/t41260xs(v=VS.71).aspx
The default class wizard javascript is located here:
C:\Program Files\Microsoft Visual Studio
10.0\VC\VCWizards\CodeWiz\Generic\Class\Scripts\1033\default.js
Duping the Project
Duplicating this is trickier than I thought, you need to copy and paste the
Microsoft Visual Studio 10.0\VC\VCWizards\CodeWiz\Generic\
folder, then head to:
C:\Program Files\Microsoft Visual Studio 10.0\VC\VCAddClass\Generic
Dupe this folder and modify the Generic.vsdir inside it to point to a dupe of ..\Simple.vsz (a file in the VCAddClass folder).
The Simple.vsz file points back to the location of the "Generic" folder in VCWizards you duped at the start, so point your new simple.vsz at that.
Code Generation
As for the actual code generation, its not all that difficult to pick up. To get things started faster, here is the General way the default.js works:
Once the wizard is finished, the code gen method kicks off from:
function OnFinish(selProj, selObj)
selProj is (as far as I can tell) an instance of EnvDTE.Project
http://msdn.microsoft.com/en-us/library/envdte.project.aspx
Getting information from the wizard seems to be based around:
wizard.FindSymbol("CLASS_NAME")
The real magic starts to happen on the selProj.CodeModel object
oCM.AddClass(strClassName, strHeader, vsCMAddPositionEnd, "", "", vsCMAccessDefault);
It seems the convention for these methods to add anything to a file simply modifies the file as a single action, as it requires the file path as its paramter.
This returns a CodeClass instance and can be added to by its methods like:
AddAttribute
AddFunction
...
This is quite restricting if you are looking for very strict code formatting (or in my case inserting macros that don't fit normal code syntax.
The simple way around this is to just build a string on your own for the parts that you need full control over using the EditPoint interface.
An EditPoint is a location inside a code file to which you can call methods like:
EditPoint.Insert(string)
Editpoint.InsertFromFile(path)
To get an EditPoint in a location where you would want to insert code, simply use the location of one of the existing items in the code gen file (like class or constructor) and get a TextPoint using .StartPointOf or .EndPointOf and manipulating the parameters.
Once you have a TextPoint you can create an EditPoint like so:
newclass.EndPointOf(vsCMPartBody).CreateEditPoint().Insert("\nprivate:\n REGISTER_TYPE_MEMBER("+strClassName+");\n");
To get a TextPoint inside the .cpp file instead:
oConstructor.StartPointOf(vsCMPartWhole,vsCMWhereDefinition).CreateEditPoint().Insert("REGISTER_TYPE_BODY_ID("+strClassName+",REPLACE_ID);\n\n\n");
This gives you the power to do anything you want via JScript string manipulation as long as you can find the input data you need via the wizard (which I have not yet delved into)

mfc directory picker?

I did see this to modify CFileDialog (http://support.microsoft.com/kb/105497) but it looks like a lot more than I need.
I'm using the CFileDialog to pick files, is there a simple way to use it to just select a directory?
Any other suggestions?
(I also saw this but is for XP only?
http://msdn.microsoft.com/en-us/library/aa163948%28office.10%29.aspx)
(VS 6.0 C++)
You will probably want to use the SHBrowseForFolder API. There are lots of wrapper classes out there that make it easier to use. Like this one.
Dundas Ultimate Toolbox has a folder selection drop-down tree. It is nice because you don't need to open a new window just for selecting a folder.
The class is defined in FolderTree.h and is called CFolderTree.