Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

User Interfaces - Computer Programming - Lecture Notes, Study notes of Computer Engineering and Programming

User Interfaces, Hierarchy of Windows, Threads, Windows, Window Attributes, Multithread Applications, Controls and Dialog Boxes, Common Controls, User Interface Elements. As you can see in this file, how descriptive above mentioned points are explained in this lecture of computer programming. VU is one of best university for computer science in our country.

Typology: Study notes

2011/2012

Uploaded on 11/06/2012

ahsen
ahsen 🇵🇰

4.5

(91)

86 documents

1 / 14

Toggle sidebar

Related documents


Partial preview of the text

Download User Interfaces - Computer Programming - Lecture Notes and more Study notes Computer Engineering and Programming in PDF only on Docsity! Chapter 11 CHAPTER 11 1 11.1 HIERARCHY OF WINDOWS 2 11.2 THREADS 2 11.2.1 USER-INTERFACE THREAD 3 11.2.2 WORKER THREAD 3 11.3 WINDOWS 3 11.3.1 DESKTOP WINDOW 3 11.3.2 APPLICATION WINDOWS 4 11.3.2.1 Client Area 5 11.3.2.2 Nonclient Area 5 11.3.3 WINDOW ATTRIBUTES 6 11.3.3.1 Class Name 6 11.3.3.2 Window Name 6 11.3.3.3 Window Style 7 11.3.3.4 Extended Window Style 7 11.3.3.5 Position 7 11.3.3.6 Size 8 11.3.3.7 Parent or Owner Window Handle 8 11.3.3.8 Menu Handle or Child-Window Identifier 9 11.3.3.9 Application Instance Handle 9 11.3.3.10 Creation Data 9 11.3.3.11 Window Handle 9 11.3.4 MULTITHREAD APPLICATIONS 10 11.4 CONTROLS AND DIALOG BOXES 10 11.4.1 EDIT CONTROL 10 11.4.2 STATIC CONTROLS 11 11.4.3 SCROLL BAR 11 11.5 COMMON CONTROLS 11 11.6 OTHER USER INTERFACE ELEMENTS 12 11.7 WINDOWS MESSAGES(BRIEF DESCRIPTION) 12 11.7.1 WM_SYSCOMMAND: 12 SUMMARY 14 EXERCISE 14 User Interfaces 2 11.1 Hierarchy of Windows The basic building block for displaying information in the Microsoft® Windows™ graphical environment is the window. Microsoft Windows manages how each window relates to all other windows in terms of visibility, ownership, and parent/child relationship. Windows uses this relationship information when creating, painting, destroying, sizing or displaying a window. A window can have many children’s and may or may not have one parent. An example of windows is Notepad, calculator, word pad etc, are all windows. A window shares the screen with other windows, including those from other applications. Only one window at a time can receive input from the user. The user can use the mouse, keyboard, or other input device to interact with this window and the application that owns it. 11.2 Threads A thread is basically a path of execution through a program. It is also the smallest unit of execution that Win32 schedules. A thread consists of a stack, the state of the CPU registers, and an entry in the execution list of the system scheduler. Each thread shares all of the process’s resources. A process consists of one or more threads and the code, data, and other resources of a program in memory. Typical program resources are open files, semaphores, and dynamically allocated memory. A program executes when the system scheduler gives one of its threads execution control. The scheduler determines which threads should run and when they should run. Threads of lower priority may have to wait while higher priority threads complete their tasks. On multiprocessor machines, the scheduler can move individual threads to different processors to “balance” the CPU load. Each thread in a process operates independently. Unless you make them visible to each other, the threads execute individually and are unaware of the other threads in a process. Threads sharing common resources, however, must coordinate their work by using semaphores or another method of inter process communication. So a thread is a process that is part of a larger process or application. A thread can execute any part of an application's code, including code that is currently being executed by another thread. All threads share the Virtual Address space Global variables Operating system resources of their respective processes. Threads are two types of threads. User Interfaces 5 11.3.2.1 Client Area The client area is the part of a window where the application displays output, such as text or graphics. For example, a desktop publishing application displays the current page of a document in the client area. The application must provide a function, called a window procedure, to process input to the window and display output in the client area. For more information, see Window Procedures. 11.3.2.2 Nonclient Area The title bar, menu bar, window menu, minimize and maximize buttons, sizing border, and scroll bars are referred to collectively as the window's nonclient area. The system manages most aspects of the nonclient area; the application manages the appearance and behavior of its client area. The title bar displays an application-defined icon and line of text; typically, the text specifies the name of the application or indicates the purpose of the window. An application specifies the icon and text when creating the window. The title bar also makes it possible for the user to move the window by using a mouse or other pointing device. Most applications include a menu bar that lists the commands supported by the application. Items in the menu bar represent the main categories of commands. Clicking an item on the menu bar typically opens a pop-up menu whose items correspond to the tasks within a given category. By clicking a command, the user directs the application to carry out a task. The window menu is created and managed by the system. It contains a standard set of menu items that, when chosen by the user, set a window’s size or position, closes the application, or performs tasks. The buttons in the upper-right corner affect the size and position of the window. When you click the maximize button, the system enlarges the window to the size of the screen and positions the window, so it covers the entire desktop, minus the taskbar. At the same time, the system replaces the maximize button with the restore button. When you click the restore button, the system restores the window to its previous size and position. When you click the minimize button, the system reduces the window to the size of its taskbar button, positions the window over the taskbar button, and displays the taskbar button in its normal state. To restore the application to its previous size and position, click its taskbar button. By clicking the close button, application exits. The sizing border is an area around the perimeter of the window that enables the user to size the window by using a mouse or other pointing device. The horizontal scroll bar and vertical scroll bar convert mouse or keyboard input into values that an application uses to shift the contents of the client area either horizontally or vertically. For example, a word-processing application that displays a lengthy document User Interfaces 6 typically provides a vertical scroll bar to enable the user to page up and down through the document. 11.3.3 Window Attributes An application must provide the following information when creating a window. (With the exception of the Window Handle, which the creation function returns to uniquely identify the new window.) • Class Name • Window Name • Window Style • Extended Window Style • Position • Size • Parent or Owner Window Handle • Menu Handle or Child-Window Identifier • Application Instance Handle • Creation Data • Window Handle These window attributes are described in the following sections. 11.3.3.1 Class Name Every window belongs to a window class. An application must register a window class before creating any windows of that class. The window class defines most aspects of a window's appearance and behavior. The chief component of a window class is the window procedure, a function that receives and processes all input and requests sent to the window. The system provides the input and requests in the form of messages. For more information, see Window Classes, Window Procedures, and Messages and Message Queues. 11.3.3.2 Window Name A window name is a text string that identifies a window for the user. A main window, dialog box, or message box typically displays its window name in its title bar, if present. A control may display its window name, depending on the control's class. For example, buttons, edit controls, and static controls displays their window names within the rectangle occupied by the control. However, list boxes, combo boxes, and static controls do not display their window names. To change the window name after creating a window, use the SetWindowText function. This function uses the GetWindowTextLength and GetWindowText functions to retrieve the current window-name string from the window. User Interfaces 7 11.3.3.3 Window Style Every window has one or more window styles. A window style is a named constant that defines an aspect of the window's appearance and behavior that is not specified by the window's class. An application usually sets window styles when creating windows. It can also set the styles after creating a window by using the SetWindowLong function. The system and, to some extent, the window procedure for the class, interpret the window styles. Some window styles apply to all windows, but most apply to windows of specific window classes. The general window styles are represented by constants that begin with the WS_ prefix; they can be combined with the OR operator to form different types of windows, including main windows, dialog boxes, and child windows. The class-specific window styles define the appearance and behavior of windows belonging to the predefined control classes. For example, the SCROLLBAR class specifies a scroll bar control, but the SBS_HORZ and SBS_VERT styles determine whether a horizontal or vertical scroll bar control is created. For lists of styles that can be used by windows, see the following topics: • Window Styles • Button Styles • Combo Box Styles • Edit Control Styles • List Box Styles • Rich Edit Control Styles • Scroll Bar Control Styles • Static Control Styles 11.3.3.4 Extended Window Style Every window can optionally have one or more extended window styles. An extended window style is a named constant that defines an aspect of the window's appearance and behavior that is not specified by the window class or the other window styles. An application usually sets extended window styles when creating windows. It can also set the styles after creating a window by using the SetWindowLong function. For more information, see CreateWindowEx. 11.3.3.5 Position A window's position is defined as the coordinates of its upper left corner. These coordinates, sometimes called window coordinates, are always relative to the upper left corner of the screen or, for a child window, the upper left corner of the parent window's client area. For example, a top-level window having the coordinates (10,10) is placed 10 User Interfaces 10 11.3.4 Multithread Applications A Windows-based application can have multiple threads of execution, and each thread can create windows. The thread that creates a window must contain the code for its window procedure. An application can use the EnumThreadWindows function to enumerate the windows created by a particular thread. This function passes the handle to each thread window, in turn, to an application-defined callback function, EnumThreadWndProc. The GetWindowThreadProcessId function returns the identifier of the thread that created a particular window. To set the show state of a window created by another thread, use the ShowWindowAsync function. 11.4 Controls and Dialog Boxes An application can create several types of windows in addition to its main window, including controls and dialog boxes. A control is a window that an application uses to obtain a specific piece of information from the user, such as the name of a file to open or the desired point size of a text selection. Applications also use controls to obtain information needed to control a particular feature of an application. For example, a word-processing application typically provides a control to let the user turn word wrapping on and off. For more information, see Windows Controls. Controls are always used in conjunction with another window—typically, a dialog box. A dialog box is a window that contains one or more controls. An application uses a dialog box to prompt the user for input needed to complete a command. For example, an application that includes a command to open a file would display a dialog box that includes controls in which the user specifies a path and file name. Dialog boxes do not typically use the same set of window components as does a main window. Most have a title bar, a window menu, a border (non-sizing), and a client area, but they typically do not have a menu bar, minimize and maximize buttons, or scroll bars. For more information, see Dialog Boxes. A message box is a special dialog box that displays a note, caution, or warning to the user. For example, a message box can inform the user of a problem the application has encountered while performing a task. For more information, see Message Boxes. 11.4.1 Edit Control An edit control is selected and receives the input focus when a user clicks the mouse User Interfaces 11 inside it or presses the TAB key. After it is selected, the edit control displays its text (if any) and a flashing caret that indicates the insertion point. The user can then enter text, move the insertion point, or select text to be edited by using the keyboard or the mouse. An edit control can send notification messages to its parent window in the form of WM_COMMAND messages. 11.4.2 Static controls • A static control is a control that enables an application to provide the user with informational text and graphics that typically require no response. • Applications often use static controls to label other controls or to separate a group of controls. Although static controls are child windows, they cannot be selected. Therefore, they cannot receive the keyboard focus. Example of static control is a text in message box. 11.4.3 Scroll Bar A window in a Win32®-based application can display a data object, such as a document or a bitmap that is larger than the window's client area. When provided with a scroll bar, the user can scroll a data object in the client area to bring into view the portions of the object that extend beyond the borders of the window. Scroll bar is of two types. Horizontal Scroll bars and Vertical Scroll bar. 11.5 Common Controls The common controls are a set of windows that are implemented by the common control library, which is a dynamic-link library (DLL) included with the Microsoft® Windows® operating system. Like other control windows, a common control is a child window that an application uses in conjunction with another window to perform I/O tasks. Common controls are of these types. • Date Time Picker Control. • List View Control. User Interfaces 12 11.6 Other user Interface Elements The following are the user interface elements used in Windows. • Cursors (Mouse shape) • Icons (Windows Desktop Icons) • Bitmaps (Images with RGB color values.) • Accelerators (CTRL + S) Short Key combinations. 11.7 Windows Messages (brief description) The following are the some of the windows messages • WM_CLOSE • WM_COMMAND • WM_CREATE • WM_DESTROY • WM_ENABLE • WM_LBUTTONDOWN • WM_PAINT • WM_RBUTTONDOWN • WM_SYSCOMMAND • WM_QUIT • WM_SETTEXT 11.7.1 WM_SYSCOMMAND A window receives this message when the user chooses a command from the window menu (formerly known as the system or control menu) or when the user chooses the maximize button, minimize button, restore button, or close button. wParam: This parameter specifies the type of system command requested. This parameter can be one of the following values. SC_MAXIMIZE SC_MINIMIZE SC_CLOSE SC_RESTORE SC_MAXIMIZE lParam This parameter is the low-order word specifies the horizontal position of the cursor, in screen coordinates, if a window menu command is chosen with the mouse. Otherwise, this parameter is not used. The high-order word specifies the vertical position of the cursor, in screen coordinates, if a window menu command is chosen with the
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved