Chapter 3: Simple Programs Written in Assembly Language

This chapter is dedicated to simple examples intended to demonstrate the techniques of creating windows and their elements, a topic covered in Chapter 2.

Principles of Building Windowing Applications

I'll formulate several general statements that later will help you to easily manipulate windows and create powerful, flexible, and high-performance applications.

  • The properties of a specific window are set when calling the CreateWindow function by setting the Style parameters. The constants specifying the window properties are set in special files, which are included at the compile time. Since function properties are defined by the value of the specific bit of the constant, the combination of properties is nothing but the sum of bit constants (obtained using the or command). In contrast to recommendations for software developers, most constants are defined directly in programs. Among other aspects, this ensures your psychological comfort because your program will be self-sufficient.

  • The window is created on the basis of the registered class. It can contain various controls, such as command buttons, edit fields, lists, and scroll bars. All these elements can be created as windows characterized by predefined properties (e.g., for buttons , this might be the button class; for edit fields, this might be the edit class; and for the lists, this might be the listbox class).

  • The system communicates with the windowand, consequently, with the applicationby exchanging messages. These messages must be processed by the window procedure. Windows programming in many respects represents the programming of message processing. Messages are also generated by the system if some visual events take place in respect to the window or some of its controls. [i] The list of such events might include moving a window, changing its size , clicking a button, selecting some of the list elements, and moving the mouse cursor. All these events are obvious, since the program must react to such events anyway.

  • The message has its assigned code ( designate it as MES in your program) and two parameters ( WPARAM and LPARAM ). For each message code, there is a macro name , although it is just an integer value. The WM_CREATE message arrives only once, when the window is created; WM_PAINT is sent to the window when it has to be redrawn; [ii] WM_RBUTTONDOWN is generated if you right-click the mouse when placing the cursor somewhere in the window area; etc. Message parameters can play some role intended to clarify their sense, or they may not play a role. For example, the WM_COMMAND message is generated if something happens to the window controls. In this case, parameter values allow you to detect the window element and what happened to it. ( LPARAM is the element descriptor; the most significant word of WPARAM specifies the event; and the least significant WPARAM word usually stands for the resource identifier. See Part II.) Thus, it is possible to say that the WM_COMMAND message is the message from a window element.

  • The message can be generated both by the system and by the program. For example, it is possible to send the command message to some of the window controls (to add an element to the list, to pass a string to the edit field, and so on). Sometimes, messages are sent to implement some programming technique. For example, it is possible to construct custom messages so that the program carries out specific operations when receiving such messages. Naturally, such messages must be handled either in the window procedure of some window or in the message-processing loop. This approach is convenient because it allows you to execute looping algorithms so that possible changes to the window would be displayed immediately at execution.

[i] It is possible to classify all window elements as controls (e.g., buttons or checkboxes) or controllable elements (e.g., edit fields). However, all window elements generally are called controls.

[ii] Although the window procedure is called with the appropriate values of its parameters, now and further on I will say that the message is sent to the window.



The Assembly Programming Master Book
The Assembly Programming Master Book
ISBN: 8170088178
EAN: 2147483647
Year: 2004
Pages: 140
Authors: Vlad Pirogov

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