# Win32 Tutorial Introduction

Some of the first few lessons in this tutorial consist of the text originally posted on the Euphoria mailing list by Ad Rienks, which started this whole effort to "save" these tutorials, and others, for all Euphoria users, and present them in this format for everyone. These lessons are not intended to teach Euphoria programming in general, but only to give beginners an easy introduction to Windows programming using Win32lib.ew, by David Cuny.

To be brief, all the normal text is plain HTML,
all the program examples start with this little icon ,
and all the program comments are in blue. (Wolf)

Hi All,

Someone on the mailing list asked for a Win32 tutorial. I am learning to program in Win32, using David Cuny's Win32lib and other stuff I've collected during the last few months. Here is my first attempt at starting some tutorial lessons. I hope it is appreciated by at least some of you.

A short introduction to programming in Win32.

When programming in Windows, you have a huge library of functions at your disposal. These functions are called API-routines. API stands for Application Programming Interface.
This API, although provided by Microsoft, is callable from all kinds of programs, including 'Euphoria for Win32'. One big advantage of the Graphical User Interfaces of Windows over Dos is that these API-routines are not specific to one compiler, and the graphical mode is the only possible mode.

If you are new to Win32 programming and see such a program for the first time, you ask yourself : 'Is all this really needed to open a plain 'vanilla' window?'

Look at the file window.exw, provided as an example with Euphoria. It is more than 200 lines long and a total of 17 API-routines are called. Apparently these are the basic routines for building even the simplest Windows application.

But it's been a while now since Euphoria 2.0 for Windows was launched, and as Robert Craig expected, there are already some 'wrappers' available, that hide the dirty details and give an application developer tools for building his programs in a simpler way.

As I am a starter myself in this field, I will mainly be concentrating upon one of these include files, Win32lib.ew by David Cuny. This library is constantly updated and improved, so be sure to always download and use the latest edition. As I'm writing this, version 0.12a is the most recent contribution.
The simple window program now really looks quite simple, as can be seen here:

-- example1.exw

    -- This opens a blank window

    include win32lib.ew

    constant SimpleWin =
        create( Window, "Simple Window", 0, Default, Default, 200, 100, 0 )

    WinMain( SimpleWin, Normal )

    -- 'Normal' is a new parameter in win32lib.ew, version 0.30 (Aug.1999)
    -- which defines the screen attribute on startup.

    -- end of example1.exw

If you run this program it will just give you this tiny window with not even an EXIT menu, so you have to [x] it to end it !

At the risk of repeating what is already written in Win32lib.doc, I will try to explain what the function create() does and what the parameters are. The function create() reserves (allocates) space in memory and pokes the information given in the parameters there. Further on, your application can read, act upon and sometimes change this information.

The integer value it returns is used to identify the object that is created. This identifier, ( 'handle' ) can subsequently be used to refer to this 'creation'.

... so, for example, in:
yourid = create(1, 2, 3, 4, 5, 6, 7, 8)

... 'yourid' is the object's identifier or 'handle',

... and the numbered parameters are:

1. Type of control. You can create windows, buttons, lists, check-boxes
etc. Later I will explain this further.
2. The name or 'Caption' of the control.
3. The 'owner' or 'parent' of the control.
4. The 'x position' (upper left corner) of the control.
5. The 'y position' (ditto).
6. The width of the control.
7. The height of the control.
8. 'Flags' or 'Special Properties' of the control.

In this example, the use of 'Default' for the fourth and fifth parameters, simply tells Windows to decide where to place the window for you, since it normally cascades windows so they don't overlap exactly.

This ends the introduction. Provided there is further interest, I will be posting and writing more of this tutorial.

..and on to the next lesson.

CONTENTS