[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters ]

Arc de Triomphe clipart (2486 bytes)

Programming Windows 95/NT with Visual Eiffel


Written by Sven Ehrke.

petzold2.zip (561,369 bytes) - source code - Version 2


Introduction

Because many people in the Visual Eiffel mailing list and other people said Charles Petzold's book Programming Windows 95 is a must if one wants to write programs or understand how this OS works I decided to buy the current version of it.

Some years ago at Windows 3.0 times I had to make a presentation of how to write a GDI program. I was shocked when I saw that I had to write 3 pages of source code just to show a simple empty window. Because of the near and far pointers and the segments I have never been very keen to write those C-programs under Windows. Thats the reason why I did not spend more effort learning this stuff those days.

With the flat memory model it is much easier (even in C) to write programs for Windows. So when I saw the first Petzold example (a Hello World version) I decided to try it with Visual Eiffel.

I think Perzold makes his example programs interesting by using features one wouldn't expect. The "Hello World" program doesn't just print Hello Windows 95 on a window. It also plays a wave file which says Hello Windows 95. I was especially interested if I could play this wave file using VE. With the help of Roger Browne I made it. After this I thought it would be a very good motivation for learning to program the Win32 API to do it with Visual Eiffel. So I tried to reprogram every example of Petzold's book in Visual Eiffel. To be honest: at the moment not everyone is done. I have finished Chapter 1 thru 4. I would be glad if there is anyone interested to take over some other examples of the book.

If you want to examine or use the examples you should have Petzold's book. I won't give any explanations of the code or how the programs work because he did it already. What I will document here is just the special things involved because of Visual Eiffel.

I tried to keep the Visual Eiffel versions of the examples as close as possible to the original C-examples to facilitate the comparison of the two source texts. In many situation one thinks that it would be better to do it in a more object oriented way. I didn't do that because it's done already in GRAPE.

The examples make heavy use of library WINLIB.
The only OO thing I did is to use a general application class. When you look at the C-examples you recognize very soon that about 2 to 3 pages of the source code are almost the same in every example. And in every new example they have to be there again. This really cries for OO and so I created an application class from which almost every example application class inherits from. This class and some other helper classes are in a common cluster which I called XWINLIB. While converting the C-code to VE I recognized that some WIN32 API functions and data structures are not yet in WINLIB. Thus I put them into XWINLIB hoping that some day the will go into WINLIB and I can remove them.

Literature

Version 2

Extended to include all chapters up to and including Chapter 8.

About the Author

I am working as a software developer since over eight years and with Eiffel since about five years.
You can reach me at
sven.ehrke@sven-ehrke.de
11 September 1998

[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters ]