Hey guys,

I recently wrote a C++ program for a company I'm doing an internship with that asks the user for the location of .txt files and then the program opens each .txt file, gets the necessary information from each files, then outputs the information to a .txt file that the user specifies. Currently, the program receives the output file by prompting the using and then using a simple getline, same for the folder location. However, I was told today that they would like the program to produce a dialog box that allows the user to browse for these options, not type them into the console. I have searched all over for how to do this, but haven't had any luck. I'm beginning to think this is impossible to do with a console app since all I keep seeing is information on MFC. Is this right? Any help is appreciated. Thanks guys.

Have a look at Qt. It is an excellent GUI development kit for c++, and the basics are really easy to pick up. Qt's developers also offer a fully integrated IDE for both developing the code and designing the gui. It is called Qt Creator. There is extensive documentation available as well as tons of helpful tutorials. Additionally, Qt is completely portable across most platforms. For example, I develop applications on a Linux workstation, but I can build and deploy them on Windows as well. It is definitely worth a look: http://qt.nokia.com/products/developer-tools

Look at Midnight Commander. It's an open source, so feel free to study how they have done all those fancy widgets in a console. Or, better yet, make your program as a plugin.

Qt has nothing to do here (and not used anymore in Europe...)

On Windows, just call the DialogBox() api
That's all.

I've decided to try and write my program using Windows API. However, I'm still running into some trouble as I've never used this before. Would anybody be able to give me sample code that will open a dialog box where somebody can browse for a folder? Thanks.

I have looked over that thread and it has helped me understand Win32 API better, but I am still having trouble figuring out how to make a program that will do what I want it to do. I need to make a program that will ask a user to browse for a folder which contains .txt files then I need to scan all of these files and get the necessary information from them, then I need to output this information into a .txt file that the user selects from another dialog box, which is then imported into excel. I wrote the program as a console app that asked for user inputs, but I need to make it with dialog boxes now. Therefore, I pretty much have to start from scratch and use Win32 API.

I wrote the program as a console app that asked for user inputs, but I need to make it with dialog boxes now. Therefore, I pretty much have to start from scratch and use Win32 API.

It's doable to have a console app using dialog box(es), so starting from scratch writing a full-blown Windows app is not really obligatory. You can use the DialogBox() API for example, as mentioned above. I gather there are several examples of this available, if you search sites like codeproject etc.

So I can use API commands without having to start a new "Win32 Project". I can use them if I'm using Win32 Console App?

So I can use API commands without having to start a new "Win32 Project". I can use them if I'm using Win32 Console App?

You need to #include <windows.h> and then you can. Depending on what API functions you end up using, you may have to link with additional libraries.

Anyway, a simple example,

#include <windows.h>
int main()
{
    // testing ...
    return ::MessageBox(NULL, "Says hello", "Console", MB_ICONINFORMATION);
}

Be warned though, that you might be spending quite some time to get the thing working - trying to say that Windows programming is not actually 'easy'.

*sorry double posted*

Thanks. I know it won't be easy, but it can't be worse than starting from scratch. I got your example to compile. Now I suppose I just need to search for a function I can call that will display a folder browser. Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.