Sign in to follow this  
Followers 0
Thsotus

I want to study the WIndows API, need help.

6 posts in this topic

Hello, everyone, I want to learn the Windows API. I am planning just to create a meager calculator for Windows, and I need to learn the functions needed to create the text boxes and the buttons. Can someone give me a reference to the msdn database and a short explanation on how to use them? Thanks.

I don't understand how to create ANYTHING except an empty window within the Windows API. It's been hard to break into this.



Also, is the Windows API hard to port to other platforms such as Linux or Mac OS X?

Should I use OpenGL or the Windows API to create a 2d game? I know OpenGL is used for heavy 3d graphics, but it seems to hard for me. Is the Windows API better?
0

Share this post


Link to post
Share on other sites
You are better off using something like Winforms to create your program. You can visually design your little calculator app, and then just fill in the code that executes when a button is pressed. There is no need to bother writing out all the widgets by hand.

There are also multi-platform GUI creators. I believe one is called QT, but I have no experience with them.
0

Share this post


Link to post
Share on other sites
Most (or all) behavior of a control is determined by it window procedure which is part of its [url="http://msdn.microsoft.com/en-us/library/ms632596%28v=vs.85%29.aspx"]class[/url].
Using CreateWindow and specifying "Button" as the class name would create a button for example.
I second Daaark and can personally recommend [url="http://www.wxwidgets.org/"]wxWidgets[/url].
0

Share this post


Link to post
Share on other sites
The Windows API isn't [i]that[/i] difficult (in some ways it's more straightforward than many of the wrapper APIs that exist) but it does have quite a steep initial learning curve, and does require quite a lot of code to accomplish what seems like fairly small things. [url="http://www.winprog.org/tutorial/"]This page[/url] looks pretty good for getting started.

The one thing that might trip you up is that the Windows API is a procedural C-based API - no classes here! If you come from an OOP background this may be a little strange for you to get used to, so you're probably better off using a wrapper library. Some good suggestions upthread, but I'd like to add that you should think a little about your objective here. Do you want to specifically learn and use the Windows API or do you want to write programs to get stuff done? If the latter, then maybe going for something like Winforms is more suitable for your requirement.
0

Share this post


Link to post
Share on other sites
I second mhagain, the win32 API isn't that hard BUT results into very, very unclean code.

Now look the bottom [url="http://www.win32developer.com/tutorial/windows/windows_tutorial_3.shtm"]this[/url] page to see a example of a very small pure win32 api program. If you are fine with the idea of writing this kind of code, this is the way to go.

But if you come from a OO world, you should probably go with a OO framwork like wxWidgets or QT.




If you do want to use the win32 api, you NEED the 'Programming windows 5th edition' by Charles Petzold. And you need your favorite search engine to find documentation on the win32 api. Often you will be browsing in the msdn documentation.




Hope this helps,




assainator

1

Share this post


Link to post
Share on other sites
If your intent is to write a single Windows application and be done with the Windows API forever, it's overkill and expensive - [i]but[/i] I'd recommend looking for the latest edition of Charles Petzold's [i]Programming Windows[/i].

EDIT: Oops, missed the above post. So, I'd [i]second[/i] the vote for Petzold.
0

Share this post


Link to post
Share on other sites
It's not that the Windows API is difficult. It's just a horrible waste of time. Who the hell wants to write out all those widget coordinates, and WndProcs and message handlers, and then compile and run every 15 seconds just to see what the dialog ends up looking like? Even doing the simplest things end up being a giant pain in the ass and you have to fill in large structs and pass them around to a ton of functions that have seemingly 5000 arguments each (with half of them taking giant structs as input!)

You should use something like wxWidgets or Windows Forms. Than you can easily layout any custom form you like, and simply add the code that runs when those buttons are clicked, or something is entered into a control. With WinForms, a lot of things that took paragraphs of code with the regular API have been condensed down to a single function call.

There is also a program called ResEd that can make some Windows Resource scripts for you, but you still have to use the Windows API to use them. [url="http://radasm.cherrytree.at/resed/"]http://radasm.cherrytree.at/resed/[/url]
0

Share this post


Link to post
Share on other sites

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  
Followers 0