4

How can you write a C++ program to open a window like this one... alt text

Is it possible or can apps only be ran from the command line?

I'm using the G++ compiler... Do I need something else like visual studio?

Can I do it just by writing code?

2

7 Answers 7

7

Take a look at Qt which is a cross-platform framework that easily builds GUIs.

Then check out a Qt tutorial, do a google search. Here is one that will get you to "hello world"

Also, you might want to check out Code::Blocks as an IDE. It will use your already installed g++ compiler.

0
2

You can use Borland C++, Visual C++ they has GUI or wxWindow or GTK library.

2

The best and most low-level way of doing this would be by using the Windows API:

https://learn.microsoft.com/en-us/windows/win32/learnwin32/learn-to-program-for-windows

Microsoft itself provides excellent tutorials and documentation on how to program with their Windows Application Programming Interface, but there are also numerous other tutorials out there that can be found quickly with a google search.

To create a window like the one you ask about in the question, you would be looking for the following link:

https://learn.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program

It might seem daunting at first, but the Windows API is extensive and provides a huge amount of functionality, on top of just creating GUIs. It would probably be worthwhile familiarising yourself with it if you are interested in Windows programming.

1

GUI programming requires the use of additional libraries. There is a C++ GUI library supplied by Microsoft for Windows called MFC. There are many other GUI libraries out there.

If you use these GUI libraries, you don't need to run the application from the command line.

1

Search for WinApi Tutorials like this one

there are alot or you can also you the Visual Studio MFC application wizard and create a dialog application

1

Microsoft provides a tuturial for doing that:

http://msdn.microsoft.com/en-us/library/bb384843.aspx

0

You need to use the Windows api from within C++.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.