How Windows Interacts with the User


The first thing that you must learn about Windows programming is how the user and Windows interact, because this defines the architecture that all Windows programs share. This interaction is fundamentally different from the console-based programs shown in the other parts of this book. When you write a console program, it is your program that initiates interaction with the operating system. For example, it is the program that requests such things as input and output by calling Read( ) or WriteLine( ). Thus, programs written in the “traditional way” call the operating system. The operating system does not call your program. However, in large measure, Windows works in the opposite way. It is Windows that calls your program. The process works like this: A program waits until it is sent a message by Windows. Once a message is received, your program is expected to take an appropriate action. Your program may call a method defined by Windows when responding to a message, but it is still Windows that initiates the activity. More than anything else, it is the message-based interaction with Windows that dictates the general form of all Windows programs.

There are many different types of messages that Windows may send to your program. For example, each time the mouse is clicked on a window belonging to your program, a mouse-clicked message will be sent. Another type of message is sent when a button is pressed or when a menu item is selected. Keep one fact firmly in mind: As far as your program is concerned, messages arrive randomly. This is why Windows programs resemble interrupt-driven programs. You can’t know what message will be next.




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net