Mark Lalor
Mark Lalor

Reputation: 7887

C++ open window hello world

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?

Upvotes: 4

Views: 28143

Answers (7)

Gregor Hartl Watters
Gregor Hartl Watters

Reputation: 606

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.

Upvotes: 2

Dennis Miller
Dennis Miller

Reputation: 992

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.

Upvotes: 7

sum1stolemyname
sum1stolemyname

Reputation: 4552

Microsoft provides a tuturial for doing that:

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

Upvotes: 1

Baget
Baget

Reputation: 3346

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

Upvotes: 1

jcubic
jcubic

Reputation: 66490

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

Upvotes: 2

Starkey
Starkey

Reputation: 9781

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.

Upvotes: 1

spig
spig

Reputation: 1715

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

Upvotes: 0

Related Questions