Sometimes people come on IRC and ask “How do I make a window? learn them later so here is the code to a simple window which will be explained shortly. The book to get on Win32 API. If you want to write programs using just the API . Why you should learn the API before MFC. The Controversy. Too many people.

Author: Tuzuru Brazragore
Country: Gambia
Language: English (Spanish)
Genre: History
Published (Last): 23 August 2009
Pages: 126
PDF File Size: 15.24 Mb
ePub File Size: 7.39 Mb
ISBN: 277-7-95949-312-6
Downloads: 84607
Price: Free* [*Free Regsitration Required]
Uploader: Yogore

It is meant to be read as a whole, so please read it from beginning to end gorgers asking questions Each section builds on the sections before it. I have also added some solutions to common errors in Appendix A. If you ask me a question that is answered on this page, you will look very forger. Or Download the entire tutorial source included for browsing in the convenience of your own harddrive.

This file may not include minor changes such as spelling corrections that are present on the website.

If you are viewing this locally or on another website, visit the winprog website for the current official copy. Contents q Basics 1. A Simple Window 3. Understanding The Message Loop 5. Menus and Icons 7. Dialogs, GUI coders best friend 8. Button, Edit, List Box, Static Dialog FAQ Creating a simple application 1. Creating controls at runtime 2. Using files and the common dialogs 3. Tool and Status bars 4.

Bitmaps, Device Contexts and BitBlt 2. Timers and Animation 4. Text, Fonts and Colours Tools and Documentation 1. Recommended Books and References 2. Solutions to Common Errors r Appendix B: Resource file notes I’ve had reports that the source code presented in the documents itself doesn’t display line breaks properly in very old versions of Netscape, if you encounter this problem please refer to the code in the source files included in the zip download.

You may use this tutorial for forgefs no charge, however there are costs associated with hosting it on the web. If you found it to be of use to you and want to give something back, I would be grateful for donations of any amount to help pay for this website. This page gets approximately 15, hits a month, and it adds up after a while: Once again, there is absolutely no obligation to pay, and you won’t get anything in addition to what’s already here, but if you want to help out, that would be great Enjoy the win2, Brook file: As well as those who have simply written to say they’ve found the tutorial useful.

In general I will freely answer any questions that I receive by email, or point you in the direction of forgefs resource that may be of assistance. At the moment I am busy with a couple of large ongoing projects and don’t have the time to work on custom examples or small software projects.

I would however be willing to entertain job offers: Feel free to contact me. Getting Started [ contents winprog ] Getting Started What this tutorial is all about This tutorial is intended to present to you the basics and common extras of writing programs using the Win32 API.

  DIN 50961 FE ZN PDF

As a matter of fact, most of the information is applicable to any language that can access the API, inlcuding Java, Assembly and Visual Basic. I will not however present any code relating to these languages and you’re on your own in that regard, but several people have previously used this document in said languages with quite a bit of success. I will however take a few moments in the appendix to forgerx some notes on using the compilers I have knowledge of.

If you don’t know what a macro or a typedef are, or how a fkrgers statement works, then turn back now and read a good book or tutorial on the C language first. Because they screw up so many people, if you don’t read it, you’ll likely get caught too.

The first one is this: The source provided in the example ZIP file is not optional! I don’t include all the code in the text itself, only that which is relevant to whatever I’m currently discussing. In order to see how this code fits in with the rest of the program, you must take a look at the source provided in the ZIP file.


And here’s the second one: Read the whole thing! If you have a question during one section of the tutorial just have a little patience and it might just be answered later on.

If you just can’t stand the thought of not knowing, at least skim or search yes computers can do that the rest of the document before asking the nice folks on IRC or by email. Getting Started Another thing to remember is that a question you might have about subject A might end up being answered in a discussion of B or C, or maybe L.

So just look around a little. Ok I think that’s all the ranting I have to do for the moment, lets try some actual code. The simplest Win32 program If you are a complete beginner lets make sure you are capable of compiling a basic windows application.

Slap the following code into your compiler and if all goes well you should get one of the lamest programs ever written. It probably doesn’t matter, but since all the code here is C only, it makes sense to start off on the right track. In most cases, all this requires if you add your code to a. If all of this hurts your head, just call the file test. Unfortunately I can’t help much with this part either, as errors and how to fix them vary from compiler to compiler and person to person.

You may get some warnings about you not using the parameters supplied to WinMain. Now that we’ve established you can in fact compile a program, lets go through that little bit of code This is where your program starts execution.

Forger’s Win32 API Tutorial

The parameters are as follows: NOT including the program name. We’ll get to this later. For most if not all of this tutorial, there will only be one forvers to worry about, the EXE. This no longer applies. In Win32 you ignore this parameter. If you don’t know wi3n2 this means, don’t worry about it as it will not really affect us for the scope of this tutorial. Just remember that it’s needed here. Which you choose is really up to you. Just make sure that you know what a type is before you substitute something else.


Just remember a few things and they will be easy to interpret. An LP prefix stands for Long Pointer. In Win32 the Long part is obsolete so don’t worry about it. And if you don’t know what a pointer is, you can either 1 Go find a book or tutorial on C, or 2 just go ahead anyway and screw up a lot. I’d really recommend 1, but most people go with 2 I would: But don’t say I didn’t warn you. Next thing is a C following a LP indicates a const pointer. Getting Started const string, one that can not or will not be modified.

LPSTR on the other hand is not const and may be changed.

You might also see a T mixed in there. Don’t worry about this for now, unless forgerss are intentionally working with Unicode, it means nothing. Well it’s not entirely that simple I’m afraid. It’s not difficult once you know what you’re doing but there are quite a few things you need to do to get a window to show up; And they’re more than can be simply explained over a chat room, or a quick note.

I always liked to do things first and learn them later PostQuitMessage 0 ; break; default: Registering the Window Class wc. A Simple Window wc. A Simple Window For most part this is the simplest windows program you can write that actually creates a functional window, a mere 70 or so lines. If you got the first example to compile then this one should work with no problems. Registering the Window Class A Window Wi32 stores information about a type of window, including it’s Window Procedure which controls the window, the small and large icons for the window, and the background color.

This way, you can register a class once, and create as many windows as you want from it, without having to specify all those attributes over and over. Most of the attributes you set in the window class can be changed on a per-window basis if desired.

theForger’s Win32 API Tutorial

The members of the struct affect the window class as follows: A Simple Window The size of the structure. Don’t worry if that doesn’t make much sense to you yet, the various parts that count will be explained more later. Another thing to remember is to not try and remember this stuff. I rarely never memorize structs, or function parameters, this is a waste of effort and, more importantly, time.

If you know the functions you need to call then it is a matter of seconds to look up the exact parameters in your help files. If you don’t have help files, get them.

You are lost without.

Author: admin