Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMMON CONTROLS A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often.

Similar presentations


Presentation on theme: "COMMON CONTROLS A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often."— Presentation transcript:

1 COMMON CONTROLS A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often used within dialog boxes, but they can also be used in other windows. Controls within dialog boxes provide the user with a way to type text, choose options, and initiate actions. Controls in other windows provide a variety of services, such as letting the user choose commands, view status, and view and edit text.

2 Standart controls Standart Windows Controls (user32.dll): buttons
edit field listbox combobox static scrollbar We can differ controls I two part – first one is simple windows controls which were implemented by user32.dll and which we have already talk about oday. There you can see some examples of simple controls.

3 COMMON CONTROLS Animation Progress bar ComboboxEx Status bar
Date/time picker Tab Header Toolbar Hotkey Tooltip Hyperlink Trackbar Windows 95 came with several user-interface enhancements. They make the GUI richer. Several of them were in widely used before Windows 95 hit the shelf, such as status bar, toolbars etc. But you had to code them yourself.

4 How to START use them TheInitCommonControlsEx() comctl32.lib
#include <commctrl.h> If we want to use one of the common controls we need to add comctl32.lib to our linker settings if it is not already there. You must call InitCommonControls() function BEFORE you try and use them. The function InitCommonControls() does nothing but ensures that the library is loaded when you don't link to any other Common Controls library function (like CreateToolBar()). You will need to #include <commctrl.h> in order to use this function and to get the functions and declarations necessary for use of the Common Controls.

5 Controls classes ICC_ANIMATE_CLASS Load animate control class. ICC_BAR_CLASSES Load toolbar, status bar, trackbar, and tooltip control classes. ICC_COOL_CLASSES Load rebar control class. ICC_DATE_CLASSES Load date and time picker control class. ICC_HOTKEY_CLASS Load hot key control class. ICC_INTERNET_CLASSES Load IP address class. ICC_LINK_CLASS Load a hyperlink control class. ICC_LISTVIEW_CLASSES Load list-view and header control classes. ICC_NATIVEFNTCTL_CLASS Load a native font control class. ICC_PAGESCROLLER_CLASS Load pager control class. ICC_PROGRESS_CLASS Load progress bar control class. ICC_STANDARD_CLASSES Load one of the intrinsic User32 control classes. The user controls include button, edit, static, listbox, combobox, and scroll bar. ICC_TAB_CLASSES Load tab and tooltip control classes. ICC_TREEVIEW_CLASSES Load tree-view and tooltip control classes. ICC_UPDOWN_CLASS Load up-down control class. ICC_USEREX_CLASSES Load ComboBoxEx class. ICC_WIN95_CLASSES Load animate control, header, hot key, list-view, progress bar, status bar, tab, tooltip, toolbar, trackbar, tree-view, and up-down control classes. As we already know, controls are windows too. They are created using the CreateWindow() functions. Controls have their specific predefined window class names; therefore, we do not call the RegisterClassW() when we create controls. There you can see common controls classes.

6 Examples A progress bar is a control that is used when we process lengthy tasks. It is animated so that the user knows that our task is progressing. In our example, we have a progress bar and a button. The button starts a timer which updates the progress bar. We create a progress bar control with PROGRESS_CLASS class name and PBS_SMOOTH style. A combo box is a combination of an edit box or static text and a list. A combo box is used when we need to select an item from a list of available options. To create a combo box, we use the L"Combobox" window class. The CBS_DROPDOWN flag creates a drop-down list.

7 Tab control joins multiple windows with corresponding tabs
Tab control joins multiple windows with corresponding tabs. We use the WC_TABCONTROL window class to create a tab control. A List Box contains a simple list from which the user can generally select one or more items. Selected items are marked. The LBS_NOTIFY flag causes the list box to send a notification code to the parent window whenever the user clicks a list box item , double-clicks an item, or cancels the selection.

8 Messages Types: System-Defined Messages Application-Defined Messages
Before talking next about controls, I would like to remind you about messages in Windows. Windows-based applications are event-driven. They do not make explicit function calls (such as C run-time library calls) to obtain input. Instead, they wait for the system to pass input to them. Each window has a function, called a window procedure, that the system calls whenever it has input for the window. The window procedure processes the input and returns control to the system. There are two messages types: First - The system sends or posts a system-defined message when it communicates with an application. It uses these messages to control the operations of applications and to provide input and other information for applications to process. General window messages cover a wide range of information and requests, including messages for mouse and keyboard input, menu, dialog box input, window creation and so on. Second - Application can create messages to be used by its own windows or to communicate with windows in other processes. If an application creates its own messages, the window procedure that receives them must interpret the messages and provide appropriate processing.

9 Control messages Controls are child windows that send notification messages to the parent window when events, usually triggered by input from the user, occur in the control. The application relies on these notification messages to determine what action the user wants it to take. Each common control has its own message. For example, there is messages list available for progress bar. We can directly send messages with function SendMessage - it sends the specified message to a window. This function calls the window procedure for the specified window and does not return until the window procedure has processed the message. A handle to the window whose window procedure will receive the message. The message to be sent. Additional message-specific information. The return value specifies the result of the message processing; it depends on the message sent. In this example we set the range of the progress bar and its step.

10 Main Points TheInitCommonControlsEx() comctl32.lib
#include <commctrl.h> Control classes Control messages To sum up, main points you should while talking about common controls are these. Yu have to have commcontrol library, the initcommoncontrolex function and include common control headear file. When creating control, you should know control class. When sending messages, you should what message

11 Questions?


Download ppt "COMMON CONTROLS A control is a child window that an application uses in conjunction with another window to enable user interaction. Controls are most often."

Similar presentations


Ads by Google