Select File or Folder in MFC VS2010 - c++

I have converted a MFC application which was run on VS2005 to VS2010
In there I've functionality to select either a file or folder from CSelectDialog and it worked fine.
But when I convert the project into VS2010 now I can select files only.
How can I get rid of that? I couldn't find any libraries that I can use for this.
Simply I want to select either a file or folder using MFC in VS2010
Don't consider this as a duplication of
https://stackoverflow.com/questions/15852106/how-to-use-open-file-dialog-to-select-either-a-file-or-a-folder-in-vc-mfc
or
How do you configure an OpenFileDialog to select folders?
Because those answers are not applicable to this.

The source has a lot of assumptions about the types and ids of child controls on the file dialog. And the assumptions are broken if the file dialog upgraded to vista style. You can use the bVistaStyle parameter in the constructor to disable the automatic upgrade.
SHBrowseForFolder with BIF_BROWSEINCLUDEFILES is the only documented way I know of to choose file and folder at once. You can also consider supporting Shell Data Transfer between Windows Explorer and your program (e.g. drag/drop, copy/paste).

It looks like you're using some code from CodeProject that may not be compatible with 2010. You should use the standard CFileDialog to avoid any compatibility issues.

Related

Libraries VS2015

Good evening
I'm trying to set up a development environment on my newly Boot-Camped Windows 10.
I know how to link the include/lib in VS. On my Mac all my external libraries and include files are at either:
/use/local/ or /opt/local/
I'm wondering whether there is an easy way to do this on windows, or are there a way to force VS to always look in a particular dir?
Cheers
VS has the concept of property sheets which basically are a predefined set of properties for your project. Every C++ project includes by default few property sheets and there's even a special property sheet called Microsoft.Cpp.[Platform].user where [Platform] is either Win32 or x64. By editing the contents of this file you can set the paths for all your projects (or other arbitrary values such as macros).
To edit these files do either of the following:
Make a new CPP project in VS. Go to View->Other Windows->Property Manager. This will show a new pane in the current window and from there you can find the property sheet and edit as you see fit. This approach has the benefit of being more user-friendly as VS provides some nice GUI. Here's one tutorial
Find the files themselves (they are located in %LOCALAPPDATA%\Microsoft\MSBuild\v4.0), open them using your favourite text editor and do your magic. The files are XML-based so it's not awfully difficult.

Qt Creator 3.3.0: Open file in project without using mouse

I'm trying Qt Creator to see if it can be used as Visual Studio replacement. (seeing that Mingw 4.9 is bundled with it and has decent C++11 support and u8 strings which aren't present in VC2013).
I can't, however, find a way to open existing file in a project without using mouse. "projects" sidebar/panel(?) can be closed and opened with Alt+0, however doing that does not place input focus there, and so I can't really navigate it without clicking it with mouse first. Am I missing anything?
What I need:
Given project that has multiple files, in qt creator open file that already exist in project without using mouse. Files are initially closed (so opening them all first and then using Ctrl+Tab is not a solution). Any way to do that?
You can use Alt+X to navigate to the project tree.
Also, Ctrl+K allows you to open files by name (and, in fact, a lot more - just press it and you'll see all available features, including searching for classes, methods/functions, and even some git integration).
Unfortunately, I don't know where to find some docs about these shortcuts (I found them myself).

What type of Visual Studio project should I use?

I am going to be making a project with OpenCV and (probably) Qt for GUI and I was just wondering what kind of project I should create in visual studio? Would it be the Win32 Project or Win32 Console Application or just an Empty Project? A lot of them are quite obvious as I am not making a Dll or makefile but do not know the difference between the others. Thanks in advance.
Which type of project you decide to pick in Visual Studio depends what will best fits your needs. Since I do not know your exact needs, the best answer I can give is explain the difference between the types of Project Options and give examples when you would choose to use the given project:
Win32 Project: A Win32 Project is one of the options Visual Studio provides to you, and if chosen will provide the user with template code that generates a "window", that window being just like any other window (browser window, folder window, etc), but one that your program controls.
Examples: Making a calculator, making an application that needs a window with buttons for the user to communicate with the program, etc.
Win32 Console Application: In this option, Visual Studio provides a Command Prompt interface where the user can input data and also where output can appear. Basically it's the black window where you can input commands and receive information of what is happening in your program.
Examples: When testing out code (it makes debugging easier in some cases), when the program really doesn't need to be too elaborate, etc.
There are other options available, thou these two were mentioned in your post and are probably the most popular among developers.
After installing Qt and maybe a Qt-VisualStudio-Plugin you have some new options when creating a New Project:
You should choose Qt Application in most cases. Not sure if you can use a GUI with Qt Console Application, but you'll get a terminal/console in that case.
After choosing project name, you can easily choose the Qt Modules you'll need. This adds them to your project settings, so you don't have to add the manually (but I guess you can do so later if you need more modules).
The project will create a .ui file which you can open/edit with QtDesigner. The project will perform all the moc and uic compile steps automatically and you don't have to add those things manually.
I think this is the easiest way to use the combination of Qt and Visual Studio.
Adding OpenCV to Visual Studio is easy:
Just add the include directories and the correct OpenCV libraries.
The question whether to use a consolse application or not depends on your needs.
Personally, I like printing development output to a console, but maybe you don't want that in your final project ;)

C++ parsing a text file that is located online

Information about what I want to do:
-read in a few integer variables from a text file that will be located on a dropbox public folder.
-the variables will be used to trigger some if statements thus controlling my application remotely if I need to have it do something ( I would just save the variable I need to that text file and my program with would read from it every 5 seconds would see it and perform the required actions).
-this is a console application which is being built and compiled in visual studio 2010 on windows 7. The software will also be running on a win7 computer.
I need help with:
I already have read on using a library called libcurl. The problem is that I do not know how to link this library with my project in vs2010. Detailed instructions on how to do this on vs 2010 would be very helpful.
OR
if you can think of a better and easier way to accomplish what I need done, offer some advice and direction
It sounds like you're a novice, is that correct? If not then apologies for stating the obvious.
To use your compiled DLL in your application you need to 'add a reference' to it. You can do this by adding what is called a binary reference, where you simply tell visual studio where to find the dll. Or you can add a project reference if the project which is producing the dll is within the same solution. The best approach is to use something called nuget. It's a visual studio extension which automates the adding of binary references available from a public repository.
I have just done a search for libcurl on nuget.org and drew a blank. As I am unfamiliar with this library you may have better luck finding a nuget package as you will be a le to search using better terms that I did (curl and libcurl)
Whatever approach you take, just right-click on the project in which you want to use libcurl within the solution explorer and you should find an add reference option in the menu.

Setting file version number in Visual Studio 2005 C++

Can anyone point me in the right direction how to configure Visual Studio 2005 with our C++ console project how we can include a 'File Version' in the details section of the file properties.
I've tried resource files without any luck. This is with a C++ project just for clarification, and big thank you for the guys you responded with C# suggestions.
Thanks in advance.
If you are talking about unmanaged c++, you need to add a version resource to the project.
right-click on the project, choose add - Resource.... Choose Version and press new.
There you can enter all info you need.
You have to have one VS_VERSION_INFO section in your resource (*.rc) file(s) that compile into your project.
In the Visual Studio 2005 Solution Explorer, open the context menu on your C++ project and choose Add, Resource.
Mark Version and click "New".
Fill in the fields as desired and save the file.
Build.
Now your project output has a FileInfo resource.
Please be aware that Windows Vista does not show all available version info in the Explorer context menu's "Details" tab.
For c++ projects I use StampVer and call it as a post build operation including check in/out of revision control for release builds.
Unless you have a good reason for your file version to be different than the version of the assembly inside, I think it is a better idea to provide the AssemblyVersion alone. If you do not specify an AssemblyFileVersion, it will automatically get the same value, so you can see your assembly's version directly in the file's properties.
The advantage is that you can use a wildcard and allow the version to be automatically incremented, so that every time you compile the library you get a different build and/or revision number. As far as I can tell, this trick does not work with AssemblyFileVersion, so you have to increment it by hand.
Of course, all this only applies if you're writing .NET code. Are you by any chance talking about a project using unmanaged code?