








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Windows Common Controls, Common control Library, DLL Versions, Common control Styles, Initialize Common Controls, List View, Image List, Screen Shot of an Example Application. 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
1 / 14
This page cannot be seen from the preview
Don't miss anything!









A control is a child window an application uses in conjunction with another window to perform simple input and output (I/O) tasks. 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 the means to type text, choose options, and direct a dialog box to complete its action. Controls in other windows provide a variety of services, such as letting the user choose commands, view status, and view and edit text. The user control overviews discuss how to use these controls.
The following table lists the Windows controls.
Control Description
Animation An animation control is a window that displays an Audio-Video Interleaved (AVI) clip.
Button Button controls typically notify the parent window when the user chooses the control.
Combo Box Combo box controls are a combination of list boxes and edit controls, letting the user choose and edit items.
ComboBoxEx ComboBoxEx Controls are an extension of the combo box control that provides native support for item images.
Date and Time Picker
A date and time picker (DTP) control provides a simple and intuitive interface through which to exchange date and time information with a user.
Drag List Box Drag List Boxes are a special type of list box that enables the user to drag items from one position to another.
Edit Edit controls let the user view and edit text.
Flat Scroll Bar Flat scroll bars behave just like standard scroll bars except that you can customize their appearance to a greater extent than standard scroll bars.
Header
A header control is a window that is usually positioned above columns of text or numbers. It contains a title for each column, and it can be divided into parts.
Hot Key A hot key control is a window that enables the user to enter a combination of keystrokes to be used as a hot key.
Image Lists An image list is a collection of images of the same size, each of which can be referred to by its index.
IP Address Controls
An Internet Protocol (IP) address control allows the user to enter an IP address in an easily understood format.
List Box List box controls display a list from which the user can select one or more items.
List-View A list-view control is a window that displays a collection of items. The control provides several ways to arrange and display the items.
Month Calendar A month calendar control implements a calendar-like user interface.
All 32-bit versions of Windows include common controls DLL, Comctl32.dll. However, this DLL has been updated several times since it was first introduced. Each successive version supports the features and application programming interface (API) of earlier versions. However, each new version also contains a number of new features and a correspondingly larger API. Applications must be aware of which version of Comctl32.dll is installed on a system, and only use the features and API that the DLL supports.
Because new versions of the common controls were distributed with Microsoft Internet Explorer, the version of Commctl32.dll that is present is commonly different from the version that was shipped with the operating system. It may actually be several versions more recent. It is thus not enough for your application to know which operating system it is running on. It must directly determine which version of Comctl32.dll is present.
This style enables a toolbar's built-in customization features, which enable the user to drag a button to a new position or to remove a button by dragging it off the toolbar. In addition, the user can double-click the toolbar to display the Customize Toolbar dialog box, which enables the user to add, delete, and rearrange toolbar buttons. CCS_BOTTOM: Causes the control to position itself at the bottom of the parent window's client area and sets the width to be the same as the parent window's width. Status windows have this style by default. CCS_LEFT: This style causes the control to be displayed vertically on the left side of the parent window. CCS_NODIVIDER: This style prevents a two-pixel highlight from being drawn at the top of the control. CCS_NOMOVEX: This style causes the control to resize and move itself vertically, but not horizontally, in response to a WM_SIZE message. If CCS_NORESIZE is used, this style does not apply. CCS_NOMOVEY: This style causes the control to resize and move itself horizontally, but not vertically, in response to a WM_SIZE message. If CCS_NORESIZE is used, this style does not apply. Header windows have this style by default. CCS_NOPARENTALIGN: This style prevents the control from automatically moving to the top or bottom of the parent window. Instead, the control keeps its position within the parent window despite changes to the size of the parent. If CCS_TOP or CCS_BOTTOM is also used, the height is adjusted to the default, but the position and width remain unchanged.
This style prevents the control from using the default width and height when setting its initial size or a new size. Instead, the control uses the width and height specified in the request for creation or sizing. CCS_RIGHT: This style causes the control to be displayed vertically on the right side of the parent window. CCS_TOP: This style causes the control to position itself at the top of the parent window's client area and sets the width to be the same as the parent window's width. Toolbars have this style by default. CCS_VERT: This style causes the control to be displayed vertically.
For initialization common controls there are two function available:
Registers and initializes the common control window classes.
According to the Microsoft documentation this little function is obsolete. New applications should use the InitCommonControlsEx function. So you should not use this function.
void InitCommonControls(VOID);
This little function does not return anything.
Registers specific common control classes from the common control dynamic-link library (DLL).
BOOL InitCommonControlsEx( LPINITCOMMONCONTROLSEX lpInitCtrls );
lpInitCtrls: Pointer to an INITCOMMONCONTROLSEX structure that contains information specifying which control classes will be registered.
Return Value Returns TRUE if successful, or FALSE otherwise.
Today we are going to create a List Box. This list box will be explorer style list box. In this list box you can see large, small, list, report styles.
An image list is a collection of images of the same size, each of which can be referred to by its index.
HIMAGELIST ImageList_Create( int cx , int cy , UINT flags , int cInitial , int cGrow );
cx: Width, in pixels, of each image.
Cy: Height, in pixels, of each image. Flags: Set of bit flags that specify the type of image list to create. This parameter can be a combination of the following values, but it can include only one of the ILC_COLOR values. ILC_COLOR: Use the default behavior if none of the other ILC_COLOR* flags is specified. Typically, the default is ILC_COLOR4, but for older display drivers, the default is ILC_COLORDDB: ILC_COLOR4: Use a 4-bit (16-color) device-independent bitmap (DIB) section as the bitmap for the image list. ILC_COLOR8: Use an 8-bit DIB section. The colors used for the color table are the same colors as the halftone palette. ILC_COLOR16: Use a 16-bit (32/64k-color) DIB section. ILC_COLOR24: Use a 24-bit DIB section. ILC_COLOR32: Use a 32-bit DIB section. ILC_COLORDDB: Use a device-dependent bitmap. ILC_MASK: Use a mask. The image list contains two bitmaps, one of which is a monochrome bitmap used as a mask. If this value is not included, the image list contains only one bitmap. ILC_MIRROR: Microsoft® Windows® can be mirrored to display languages such as Hebrew or Arabic that read right-to-left. If the image list is created on a mirrored version of Windows, then the images in the lists are mirrored, that is, they are flipped so they display from right to left. Use this flag on a mirrored version of Windows to instruct the image list not to automatically mirror images. ILC_PERITEMMIRROR cInitial: This member is number of images that the image list initially contains. cGrow: This member is a number of images by which the image list can grow when the system needs to make room for new images. This parameter represents the number of new images that the resized image list can contain.
#define ID_LISTVIEW 5
hWndListView = CreateWindow(WC_LISTVIEW, "Window Name", WS_TABSTOP | WS_CHILD | WS_BORDER | WS_VISIBLE | LVS_AUTOARRANGE | LVS_REPORT, 10, 10, 350, 280, hWndMain, (HMENU)ID_LISTVIEW, hInstance, NULL );
if(!hWndListView) { return 0; }
hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), ILC_MASK, 1, 1); hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK, 1, 1);
hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_FOLDER)); ImageList_AddIcon(hLarge, hIcon); ImageList_AddIcon(hSmall, hIcon); hIcon = LoadIcon(.. MAKEINTRESOURCE(IDI_ICON_FILE))
ListView_SetImageList(hWndListView, hLarge, LVSIL_NORMAL); ListView_SetImageList(hWndListView, hSmall, LVSIL_SMALL);
HIMAGELIST ListView_SetImageList( HWND hwnd, HIMAGELIST himl, int iImageList type of IL: LVSIL_NORMAL | LVSIL_SMALL | LVSIL_STATE );
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.cx = COL_WIDTH;
for(i=0; i<3; ++i) { lvc.iSubItem = i; lvc.fmt = alignments[i]; lvc.pszText = columnHeadings[i]; if(ListView_InsertColumn(hWndListView, i, &lvc) == -1) return 1; }
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.cx = COL_WIDTH;
for(i=0; i<3; ++i) { lvc.iSubItem = i; lvc.fmt = alignments[i]; lvc.pszText = columnHeadings[i]; if(ListView_InsertColumn(hWndListView, i, &lvc) == -1) return 0; }
FileTimeToLocalFileTime(&findFileData.ftLastWriteTime, &fileTime); FileTimeToSystemTime(&fileTime, &systemTime);
strcpy(strAMPM, systemTime.wHour>=12? "PM" : "AM"); if(systemTime.wHour>=12) systemTime.wHour -= 12; if(!systemTime.wHour) systemTime.wHour = 12;
wsprintf(buf, "%d/%d/%d %2d:%02d %s", systemTime.wMonth, systemTime.wDay, systemTime.wYear, systemTime.wHour, systemTime.wMinute, strAMPM); lvi.iSubItem = 2; lvi.pszText = buf; if(ListView_SetItem(hWndListView, &lvi) == -1) return 1;
VOID SetView(HWND hwndListView, DWORD dwStyle) { DWORD dwCurrentStyle;
dwCurrentStyle = GetWindowLong(hwndListView, GWL_STYLE); SetWindowLong(hwndListView, GWL_STYLE, (dwCurrentStyle & ~LVS_TYPEMASK) | dwStyle); }
Common Controls are the part of Microsoft Windows Graphics Operating System. Almost all the WYSIWYG application use Common Controls for their compatibility and user friendliness with windows. In this lecture, we studied about common controls, their styles and behavior. We also created an application which best demonstrates the List View control of common controls. Common controls include controls like page controls, tree controls, list view controls that is modified from windows original control, button control that is also modified from windows original controls, data and time picker control, status bar, progress bar, rebar controls. These all controls reside in common controls library and the library has shipped with many versions. Before using the library you must check the valid version of the library because different version of library contains different controls properties.