Sign in to follow this  

Examples of win32 Gui code?

This topic is 815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All,

 

Not sure if this is the right place for this. Apart from the "Programming Windows" book by Pretzold. Does anyone know of any sites or resources where I can find simple win32 programs and also their source code? I am talking super simple like a window and maybe a 'File - Open' tab. Maybe something that shows an example of opening a text file and displaying some text in a panel... Just things like that.

 

Even full working programs that are simple enough to get your head around the code would be fine (like stuff on github), but i really have no idea where to look.

 

Thanks

Share this post


Link to post
Share on other sites

Thanks guys, some great links here to get me started.

 

 

Win32 is old. It's expanded here and there, but alot of the "old" stuff is still how it's done. It's not like DirectX where Microsoft discards the API and gets to redesign it from the ground up - older applications must still work on newer systems, so the "old" Win32 is still Win32.

 

Were you wanting to learn the newer Microsoft APIs? You probably want WinRT or .NET then.

 

Are you just wanting to make desktop applications? I'm a huge fan of Qt (which is free even for closed-source commercial use if you link by DLL; don't get mislead by the website).

Qt provides cross-platform native-interface GUIs, and is very powerful, and also has fantastic documentation, a large community, and plenty of open-source example applications. It's best used with the QtCreator IDE, though.

 

I didn't know that about WinRT or .NET, I will look into them, thanks.

 

I am looking to make a desktop gui for myself and maybe a few others, for data processing. I have heard Qt is the way to go for making Win32 apps so I will probably play around a bit with the API to get a general feel for things then dive into Qt.

 

Quick question, I am getting a bit confused about all the terminology they are throwing around. In terms of the Win32 API, which is pretty much raw C and C++ (isint it?), where does WinRT and .NET fit into things?

 

I find examples of things I have used can help me understand. When making a game using D3D11 I used the DirectX tool kit, and SFML. Are WinRT and .NET anything like them?

 

Thanks

Share this post


Link to post
Share on other sites

I am looking to make a desktop gui for myself and maybe a few others, for data processing. I have heard Qt is the way to go for making Win32 apps so I will probably play around a bit with the API to get a general feel for things then dive into Qt.

Qt is definitely the way to go for desktop applications.
Note: You'll want to use QtCreator as your IDE, it makes things alot easier with Qt development.
Note 2: Qt is free, even for commercial use, as long as you dynamically link to the DLLs, but the website is confusing and often misleads people into thinking they have to pay licensing fees. Ignore that.
 

I didn't know that about WinRT or .NET, I will look into them, thanks.
...
Quick question, I am getting a bit confused about all the terminology they are throwing around. In terms of the Win32 API, which is pretty much raw C and C++ (isint it?), where does WinRT and .NET fit into things?


Win32 is written in C (or at least its interface is exposed as C). This means that any language that can "talk with" C can use Win32.

For Microsoft's new way of doing things, they created what they call a "Common Language Runtime" - this means any language that uses Microsoft's Common Language Runtime can use the .NET framework. C# was designed for .NET, but other languages have added some support.

 

Microsoft also created a different version of C++ that they call C++/CLI, which runs on the Common Language Runtime (the recommended IDE for that is Visual Studio). I haven't used "C++/CLI" (I've only used regular C++), so I don't know how good it is.

 

Whether you use C++ and Qt (in QtCreator), or C++/CLI and .NET (in Visual Studio), or C# and .NET (in Visual Studio), you'll definitely have alot of learning to do, and at first it'll seem confusing, but once you get over the hill, things will make sense.

 

WinRT is for the new Windows 8/10 style of apps ( [1] [2] ), which might not be what you are going for.

WinRT is built on the CLR, so anything that can use .NET can use WinRT.

 

As I said before, I'm biased in favor of Qt. Qt lets you make native applications looking the same visually like .NET does, but you can also theme them how you want and design your own widgets and such. Here's a complicated messy screenshot of my own project written in Qt. Mind the overuse of gradients and non-standard widgets - I get carried away. biggrin.png

Share this post


Link to post
Share on other sites

Many moons ago, my introduction to Win32 was Andre Lamothe's "Tricks of the Game Programming Gurus"...

 

http://www.amazon.co.uk/Tricks-Windows-Programming-Gurus-CD-Rom/dp/0672313618/ref=sr_1_2?ie=UTF8&qid=1442131560&sr=8-2&keywords=tricks+of+the+game+programming+gurus

 

...DirectX wise, its ancient but there is still a lot in the book you can learn from such as 2D rendering algorithims, maths, how to add resources(bmps, wavs) to your exe files and much more. 

 

The wonderful thing about this book is that it made excellent preparation for when I went on to take a degree in computing, and the first module in C++/WinAPI I pretty much breezed through it and gained very high marks on assignments.

Share this post


Link to post
Share on other sites

Hi Servant, thanks for your detailed reply, I think I am getting the picture now. As you said, eventually it comes down to picking one and going for it...

 

 

As I said before, I'm biased in favor of Qt. Qt lets you make native applications looking the same visually like .NET does, but you can also theme them how you want and design your own widgets and such. Here's a complicated messy screenshot of my own project written in Qt. Mind the overuse of gradients and non-standard widgets - I get carried away. biggrin.png

 

 

wow, thats insane! So you made that whole program using Qt? Is all of the logic behind the scenes c++? The use of tabs and selectors etc is similar to how I want my GUI to look (although urs is a lot more complex)

 

So with QT it doesn't have to look like a typical windows program (for which I think of something like winRAR looks like...). Can the same effect be achieved with just the Win 32 API?

 

Thanks again for the info

Share this post


Link to post
Share on other sites

I'll second Qt here. Its excellent if you want to build GUI programs. Win32 API can be used to achieve the same results, but it is painful, error-prone and takes an enormous amount of effort. The only real gain is that you don't end up with a large set of dependencies, so I use it for games to make a window and respond to basic window messages, but I'd never want to use it to write a GUI-based program again.

The problem with Win32 is it has to be backwards compatible and is essentially a C-based library. Most of the interactions you have with controls are via sending messages using SendMessage, which then require casting of all the various parameters to the WPARAM and LPARAM types so you essentially throw away the type-safety we are all used to these days and have to be incredibly careful that you know what you are doing.

But, yes, it is possible, of course.

Qt sort of extends C++ with its meta-object compiler system (the main reason I suspect Servant said it was easier to work with QtCreator although you can work around this) and adds a generic SIGNALS/SLOTS system that is then used to communicate between controls, which is a real boon. This is improved further in Qt 5 I believe to start using more native C++ to achieve this, although they still have the MOC.

Oh, and your last question, it is indeed possible to write any type of program with Qt. Qt is divided into modules, so you can write a command-line program just using QtCore, a GUI application using QtCore and QtGui, and there are a bunch of other modules you can mix and match as you see fit (QtXml, QtWebKit etc).

Can seem a bit daunting setting it all up for the first time, but once you are up, running and comfortable, if you are anything like me you'll never look back. I learned to use it for work, but within months I'd scrapped and rewritten my 3D modelling software (previously in Win32) in Qt from the ground up.

My Qt-based application: http://www.gamedev.net/gallery/image/6633-charm/

 

I'm using Direct3D 9.0c to do the actual rendering in there because I'm a bit of a dinosaur but it was fairly easy to host a D3D window inside a Qt Widget (obviously I don't have any cross-platform ability now on this project as a result).

And if you use Qt throughout without falling back on any Windows-only libraries, you essentially have cross-platform for as close to free as you are ever going to get, since Qt will work on Linux, Mac etc.

Edited by Aardvajk

Share this post


Link to post
Share on other sites

^-- what Aardvark said. smile.png 
 

So you made that whole program using Qt?

Yes. The main window in the middle is OpenGL (exposed by Qt), but the rest is Qt.
 

Is all of the logic behind the scenes c++?

Yes.
 

So with QT it doesn't have to look like a typical windows program (for which I think of something like winRAR looks like...). Can the same effect be achieved with just the Win 32 API?

Win32 and Qt both allow the use of "normal" Windows programs, and also allow great customization to make programs look however you want.

Qt just makes it easier to do, while also being cross-platform.

Share this post


Link to post
Share on other sites

This topic is 815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this