mfc directory picker? - c++

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.

Related

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

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.

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.

How to choose and open a file during runtime with C++?

At the moment I am creating an Editor for Textures and I want to choose the textures during runtime. Later I would like to choose the save directory for new textures.
I found the
How to: Open Files Using the OpenFileDialog Component. But I think this is not the solution.
(assuming you are on Windows, pas per screenshot)
If you simply want to select a folder, you can use SHBrowseForFolder.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762115%28v=vs.85%29.aspx
M.
You need to look at the Common Dialog Library.
http://msdn.microsoft.com/en-gb/library/windows/desktop/ms645524(v=vs.85).aspx
Or, if you are only interested in Vista/Windows 7 support, you could consider the Common Item Dialogs instead.
http://msdn.microsoft.com/en-gb/library/windows/desktop/bb776913(v=vs.85).aspx
For 'native' C++ you wouldn't be able to easily use the .NET components that your link refers to.
I have solved my problem with using the dirent.h file. I have acknowledge of this file by founding this post How can I get the list of files in a directory using C or C++?
I have write my own fileexplorer by using dirent.h and SFML.
Sorry if i can't illustrate my problem.
but thanks for the replies (:

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.

Windows Explorer Context Menu

I want to add a context menu entry with C++. I've been searching but all I can find is some jackass trying to sell me some BS program that does it for me which is not what I am looking for. I'm not looking for anything that uses .NET or Visual C++ either. I want the straight C++ way of doing this.
You can add a right-click menu item that just runs a program, simply by registry editing. No need to do shell extension for that. E.g. I used to have an extract icon thing (copy to clipboard),
HKEY_CLASSES_ROOT\*\shell\copyIcon\=Copy icon to clipboard
HKEY_CLASSES_ROOT\*\shell\copyIcon\command="path to the program" %1
Cheers & hth.,
A decent tutorial, ignore the jackass title, is available here. This kind of shell programming requires COM, no escaping that. Trying to write COM code without MSVC support classes is character-building. But possible, as long as you know COM really well.