Mc9243 visual programming notes pdf




















These routines handle the events to which the main program will respond. For example, a single left-button mouse-click on a command button in a GUI program may trigger a routine that will open another window, save data to a database or exit the application. Many modern day programming environments provide the programmer with event templates so that the programmer only needs to supply the event code. The second step is to bind event handlers to events so that the correct function is called when the event takes place.

Graphical editors combine the first two steps: double- click on a button, and the editor creates an empty event handler associated with the user clicking the button and opens a text window so you can edit the event handler.

The third step in developing an event-driven program is to write the main loop. This is a function that checks for the occurrence of events, and then calls the matching event handler to process it. Most event-driven programming environments already provide this main loop, so it need not be specifically provided by the application programmer.

A GUI consists of one or more windows and each window contains one or more controls. A GUI offers graphical icons, and visual indicators to fully represent the information and actions available to a user. By utilizing the strengths of the GUI environment, applications can be improved to the point that end user training and problems are minimized, and a higher level of satisfaction is obtained by the vast majority of end users. There are two types of windows: 1.

Application window 2. Dialog box. The user sees these windows as objects on the screen and interacts directly with them using the keyboard or the mouse. A window also uses messages to communicate with other windows. Every window that a program creates has an associated window procedure.

This window procedure is a function that could be either in the program itself or in a dynamic-link library. The window class identifies the window procedure that processes messages to the window. Windows sends a message to a window by calling the window procedure. The window procedure does some processing based on the message and then returns control to Windows.

The use of a window class allows multiple windows to be based on the same window class and hence use the same window procedure. For example, all buttons in all Windows programs are based on the same window class. This window class is associated with a window procedure located in a Windows dynamic-link library that processes messages to all the button windows. In object-oriented programming, an object is a combination of code and data.

A window is an object. The code is the window procedure. A window procedure processes messages to the window. The data is information retained by the window procedure and information retained by Windows for each window and window class that exists in the system.

This message queue stores messages to all the windows a program might create. Select New from the File menu. In the New dialog box 2.

Pick the Projects tab. Select Win32 Application. In the Location field, select a subdirectory. In the Project Name field, type the name of the project. This will be a subdirectory of the directory indicated in the Location field. The Create New Workspace button should be checked. The Platforms section should indicate Win Choose OK.

A dialog box labeled Win32 Application — Step 1 of 1 will appear. Indicate to create an Empty Project. Press the Finish button. New Project Information dialog box appears. Click OK. Select New from the File menu again. In the New dialog box 6. Pick the Files tab. The Add To Project box should be checked.

The project name should be indicated in the field below. Type a file name in the File Name field. Type in the program. To compile, select Build from the Build menu, or press F7, or select the Build icon from the Build toolbar. During the compile stage, the compiler generates an. OBJ file from the C source code file. During the link stage, the linker combines the. OBJ file with.

LIB files to create the. EXE file. Creating a window first requires registering a window class, and that requires a window procedure to process messages to the window. Data Structures. A handle is simply a number 32 bits in size that refers to an object. A program obtains a handle by calling a Windows function. A variable-naming convention, in honor of the legendary Microsoft programmer Charles Simonyi.

The variable name begins with a lowercase letter or letters that denote the data type of the variable. H defines these identifiers. Used to reserve some extra space in the class structure that Windows maintains internally. Used to reserve some extra space in the window structure that Windows maintains internally. Sets an icon for all windows created based on this window class. The icon is a small bitmap picture that represents the program to the user.

The second argument identifies the icon. The LoadIcon function returns a handle to this icon. Similar to the previous, the LoadCursor function loads a predefined mouse cursor and returns a handle to the cursor.

Specifies the background color of the client area of windows created based on this class. A brush is a graphics term that refers to a colored pattern of pixels used to fill an area. The text name of the window class. This may be whatever the user wants. In programs that create only one window, the window class name is commonly set to the name of the program. The client area is the part of the window on which a program is free to draw and deliver visual information to the user. Displaying text or graphics in the client area is said to be painting the client area.

Windows is a message-driven system. This message informs the window procedure that the client area must be painted. In some cases when part of the client area is temporarily written over, Windows attempts to save the area of display and restore it later. This is not always successful. In a few cases, Windows always saves the area of the display it overwrites and then restores it.

This is the case whenever:. This structure contains, among other information, the coordinates of the smallest rectangle that encompasses the invalid region. A window procedure can invalidate a rectangle in its own client area by calling InvalidateRect. A window procedure can obtain the coordinates of the invalid rectangle. It can also obtain these coordinates at any other time by calling GetUpdateRect.

A program can also validate any rectangular area within the client area by calling the ValidateRect function. A handle, is a number that Windows uses for internal reference to an object. The handle is obtained from Windows. A device context is associated with a particular display device. When a program needs to paint, it must first obtain a handle to a device context. When the handle is obtained, Windows fills the internal device context structure with default attribute values.

These defaults can be changed by calling various GDI functions. After a program has finished painting its client area, it should release the device context handle. Two functions are involved: BeginPaint and EndPaint. H header file. To get a handle to the device context of the client area of the window, call GetDC to obtain the handle and ReleaseDC after done with it.

Unlike the device context handle returned from BeginPaint, the device context handle returned from GetDC has a clipping rectangle equal to the entire client area. To validate the entire client area, call. While GetDC returns a device context handle for writing on the client area of the window, GetWindowDC returns a device context handle that lets to write on the entire window. The attributes of the device context, control the characteristics of the displayed text.

For instance, the default text color is black and text background color is white. The size of the characters in the system font is based on the size of the video display. The system font is designed to allow at least 25 lines of 80 character text to fit on the screen.

A program can determine information about the sizes or metrics of user interface items by calling the GetSystemMetrics function. A program can determine font sizes by calling GetTextMetrics.

This function requires a handle to a device context because it returns information about the font currently selected in the device context. To use the GetTextMetrics function, first define a structure variable, commonly called tm as. These two values represent the maximum vertical extends of characters in the font above and below the baseline.

Accent marks and other diacritical characters may occur in this area. The designer may set this member to zero. This value does not include the overhang required for bold or italic characters. Scroll bars are positioned either vertically for up and down movement or horizontally for left and right movement. User can click with the mouse the arrows at each end of a scroll bar or the area between the arrows. The thumb can also be dragged with the mouse to move to a particular location.

The scroll bars specified in the CreateWindow function are always placed against the right side or bottom of the window and extend the full length or width of the client area. The client area does not include the space occupied by the scroll bars. The width of the vertical scroll bar and the height of the horizontal scroll bar are constant for a particular video driver and display resolution.

Windows takes care of processing all mouse messages to the scroll bars. However, scroll bars do not have an automatic keyboard interface. The scroll bar range is a pair of integers representing a minimum or maximum value associated with the scroll bar. The position is the location of the thumb with the range.

When the thumb is at the top or left of the scroll bar, the position of the thumb is the minimum value of the range and at the bottom or right of the scroll bar, the thumb position is the maximum value of the range.

By default, the range of a scroll bar is 0 top or left through bottom or right. To change the range. If TRUE, the scroll bar is redrawn. When the scroll bars are used within the program, responsibilities are shared with Windows for the maintaining the scroll bars and updating the position of the scroll bar thumb.

Scroll Bar Messages. Each mouse action on the scroll bar generates at least two messages, one when the mouse button is pressed and another when it is released. The wParam message parameter is divided into a low word and high word. The low word of the wParam is a number that indicates what the mouse is doing to the scroll bar.

The notification codes are:. When the mouse button is held down on the various parts of the scroll bar except thumb the program can receive multiple scroll bar messages. When the position of the mouse cursor is over the scroll bar thumb and the mouse button is pressed, the thumb can be moved. When the low word of wParam is. The window that receives a particular keyboard event is the window that has input focus active window.

As the user presses and releases keys on the keyboard, Windows and the keyboard device driver translate the hardware scan codes into formatted messages. Instead, Windows stores these messages in the system message queue. The system message queue is a single message queue maintained by Windows specifically for the preliminary storage of user input from the keyboard and the mouse. The reason for this is that the window that is supposed to receive keyboard input is the window with the input focus.

A user can be typing faster than an application can handle the keystrokes, and a particular keystroke might have the effect of switching focus from one window to another.

Subsequent keystrokes should then go to another window. When text is typed into a program, a little underline, vertical bar, or a box shows where the next character to be typed will appear on the screen. In Windows, the caret is customarily a horizontal line or box that is the size of a character, or a vertical line that is the height of a character. The vertical line caret is recommended to be used with proportional font in which the characters are not of a fixed size.

The caret is created hidden. After calling CreateCaret the window procedure must call ShowCaret for the caret to be visible. Post on Dec views. Category: Documents 1 download. Tags: visual programming languages visual programming slide visual programming vp visual expressions journal of visual languages evaluation slide wiki slide conventional textual. Visual Programming Slide 2 O. Nierstrasz PL Visual Programming Wikipedia : A Visual programming language VPL is any programming language that lets users specify programs by manipulating program elements graphically rather than by specifying them textually.

A VPL allows programming with visual expressions, spatial arrangements of text and graphic symbols. Most VPLs are based on the idea of boxes and arrows, that is, boxes or circles or bubbles, treated as screen objects, connected by arrows, lines or arcs.

Burnett : Visual programming is programming in which more than one dimension is used to convey semantics. Examples of such additional dimensions are the use of multidimensional objects, the use of spatial relationships, or the use of the time dimension to specify before- after semantic relationships. Myers : Visual Programming VP refers to any system that allows the user to specify a program in a two or more dimensional fashion.

Conventional textual languages are not considered two dimensional since the compiler or interpreter processes it as a long, one-dimensional stream. Visual Programming includes conventional flow charts and graphical programming languages. It does not include systems that use conventional linear programming languages to define pictures.

This eliminates most graphics editors, like Sketchpad [Sutherland 63]. Slide 6 O. Pygmalion would then infer the actual algorithm. David Canfield Smith, Pygmalion: a creative programming environment, Ph. Allen Cypher, et al. Smith, Experiences with the alternate reality kit: an example of the tension between literalism and magic, Slide 11 O. Slide 12 O. As a consequence, certain system properties are obtained.

Slide 13 O.



0コメント

  • 1000 / 1000