|
























| |
Name: CEDevCaps
Download: CEGetDev.zip
What is it: Demonstrates some of the information that can be determined using the
GetDeviceCaps API.
Features: This demo has a somewhat novel way of iterating through the
GetDeviceCaps.
In the WM_CREATE message.
GetClientRect(hWnd, &rc);
rc.top += CommandBar_Height(hwndCB);
hwndListBox = CreateWindow(_T("LISTBOX"), NULL, WS_CHILD|WS_VISIBLE|WS_VSCROLL,
rc.left, rc.top, rc.right, rc.bottom - rc.top, hWnd, (HMENU)ID_LB, hInst,NULL);
The client window size is obtained and a ListBox control is created to fill the client
window area.
if (hwndListBox){
//Iterate through the values to GetDeviceCaps
hdc = GetDC (hWnd);
for (i = 0; i < NINDEX
; i++) {
value = GetDeviceCaps (hdc , DevCaps[i].Value);
wsprintf (szbufW,_T("%s %8d"), DevCaps[i].String, value);
SendMessage (hwndListBox, LB_ADDSTRING,
0, (LPARAM) szbufW);
//Expand information returned from GetDeviceCaps if required
ExpandInfo (hwndListBox, DevCaps[i].Value, value);
}...
If the ListBox control is created successfully. Then the possible values for a call to
GetDeviceCaps in a loop .
ReleaseDC (hWnd,hdc);
ShowWindow(hwndListBox, SW_SHOW);
UpdateWindow(hwndListBox);
If GetDeviceCaps has extra info to explain then a call is made to ExandInfo .
void ExpandInfo (HWND hwnd, int index, int value){
int i;
switch (index) {
case TECHNOLOGY
:
for (i = 0 ; i< NDevice
; i++) {
if (value == Device[i].Value)
{
wsprintf (szbufW,space, Device[i].String);
SendMessage (hwndListBox,
LB_ADDSTRING, 0, (LPARAM)szbufW);
}
}
break;
}
|