DOC PREVIEW
UCSD CSE 125 - Taming Windoze

This preview shows page 1-2-3-4-5 out of 16 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 16 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Taming Windoze by Telemachos Introduction Hi guys, guess what - time for another tutorial from Peroxide! It has been a loooong time since my last tutorial and much has happened both in MY little world but also in the big mean world of graphical programming. The most significant change must be the definite death of DOS! I know, some of you will start screaming in anger at me now, others might faint in disbelief - has Telemachos, the extreme DOS fanatic, finally lost his mind? Has he turned to embrace the enemy, has he gotten himself a job at M$? (no) Well, the fact is that I realized I didn't really had a choice anymore. All new graphic cards only support Windows, making my old VESA code for DOS useless. Also with the release of Direct-X we, the old graphic "hackers" from the glory days of DOS, have gotten the direct access to hardware we need to make FAST graphics in Windows! And I actually MEAN fast! Often quite a bit faster than we could make it in DOS because Direct-X takes care of using the hardware acceleration found on just about any graphics card these days - but thats another topic which I'll cover in my next tutorial. So, the series has turned into a Windows/Direct-X tutorial series - but as you might know this also means the end of the Pascal support :( From now on the language used will be C++ only, sorry all you Pascal fans - I know that it has been the fact that my tutorials were mostly written in pascal that has made the series as popular as it is now, and I thank you all for all your inputs, feedback and praising words! It is you that made the series worth writing back then! If there is interest I might put together a small "crash course" in C/C++ programming to help those of you that might want to switch into C++ - it's actually quite easy to change to a new language as you don't have to learn all the basic programming stuff again. In fact it's mostly a question of syntax used to achieve the same things! (And then there is the object oriented programming style etc, etc.. ) Those of you who prefer to read my tutorials offline can download this package which also contains the small demo program which demonstrates how to build a "skeleton" to use as starting point when developing a windows program. Thanks to André LaMothe who is the original source for much of the stuff I'll cover.What is THIS tutorial about ? The primary goal of my turning this series into a Windows series is to show you how to use Direct-X (DirectDraw to be precise) for making fast game-like graphics. BUT, those of you who have been reading my previous tutorials will know that I like to start at the bottom slowly working my way up towards the final goal - and these Windows tutorials wont be any different! So, today I'm not going to use Direct-X. Instead I'm going to show you how to program some basic stuff using the normal Win32 functions. This approach serves TWO main purposes : • You will learn to understand how Windows work and you will learn how to code the "frame" code which must surround every Windows program and you will learn to use the GDI to do simple graphics and text. Even when using Direct-X you might often want to use the GDI for simple things like text - so learn it well! Finally you will learn a few neat tricks about handling input from keyboard and mouse. • You will learn to appreciate the work Direct-X does for you :) Here is the stuff the tutorial covers : • Creating a Windows class. • Creating a Window. • Learn about the Windows messages. • Learn how to code an event handler. • Learn about the GDI and GDC. • Learn to draw graphics using the GDI. • Learn about input through keyboard and mouse. About notation : Something which can become slightly confusing when discussing Windows programming is to make clear when I talk about Windows 95/98 and when I talk about a window in Windows :) When I refer to the OS Windows 95/98 I will write : Windows (with a capital W). When I refer to a window in Windows I will write it in all lower-caps like : window, your windows etc. Get it ? :)The Windows Class - what the #&%# is that ?!? You might think a window is just a window - but NO, there are MANY things you need to tell Windows about any window you want to create. You describe a specific class of windows in a class called the Windows Class. Technically the name class is a bit misleading as we are not talking about a class like we use the word when talking about object oriented code - for this "class" the name structure might be more fitting. Anyway, here is how it looks like : typedef struct _WNDCLASS { UINT style; // some flags which describes the window, see below WNDPROC lpfnWndProc; // A pointer to the event handler for this window int cbClsExtra; // We will not use this. int cbWndExtra; // We will not use this. HANDLE hInstance; // handle to the instance of the window HICON hIcon; // handle to the icon of the application HCURSOR hCursor; // Take a guess HBRUSH hbrBackground; // handle to the background "brush" LPCTSTR lpszMenuName; // This will become clear later. LPCTSTR lpszClassName; // We give the class a name through which we will refer to it later. } WNDCLASS; WNDCLASS windowsClass; The style field is very interesting and at the same time it introduces you to one of the most confusing things in windows coding - all the damn flags!!! There are SOOOO many flags you must remember when coding windows applications - and its NOT getting any better once I introduce direct-X in the next tutorial. Anyway, here are the flags you should normally use. Usually I'll only show a small part of the flags available - namely those I find important. If you are curious look up the rest in the help for your compiler. windowsClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; Remember you put more flags together by "or'ing" them together. ( | is the bitwise or operation ) Pay attention to the CS_OWNDC flag - the meaning of that should become clear later on in this text. For now, just write it. The next field we need to fill out is the lpfnWndProc. That is a function pointer to the event handler. Those of you who have read PXDTUT6 about interrupts and keyboard handlers have seen something like this before - the event handler basically does the same as an keyboard handler. It reacts - not on interrupts this time - but on MESSAGES sent to it by


View Full Document

UCSD CSE 125 - Taming Windoze

Download Taming Windoze
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Taming Windoze and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Taming Windoze 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?