Annotation of q_a/samples/getdev/getdev.c, revision 1.1.1.1

1.1       root        1: /**************************************************************************\
                      2: *  getdev.c -- sample program demonstrating the getdev... APIs
                      3: *
                      4: *  written March 92 by Steve Firebaugh
                      5: *
                      6: *  In this sample the main window is a dialog box.  There is no need to
                      7: *   register a new window class or create a new window.  Instead just call
                      8: *   DialogBox() and use the template defined in the .RC file.  All of the
                      9: *   interesting code is thus in the window procedure for the dialog box.
                     10: *
                     11: *  The dialog template currently specifies a "monospaced font."  This makes
                     12: *   the dialog look somewhat odd, but makes text formatting much easier.  If
                     13: *   the specified font does not exist on the system running this sample, the
                     14: *   program will work fine, but the contents of the listbox will not look
                     15: *   very good.
                     16: *
                     17: \**************************************************************************/
                     18: 
                     19: #include <windows.h>
                     20: #include "getdev.h"
                     21: 
                     22: 
                     23: /**************************************************************************\
                     24: *
                     25: *  function:  WinMain()
                     26: *
                     27: *  input parameters:  c.f. generic sample
                     28: *
                     29: \**************************************************************************/
                     30: int APIENTRY WinMain(HANDLE hInstance, HANDLE hPrevInstance,
                     31:                      LPSTR lpCmdLine, int nCmdShow)
                     32: {
                     33: int ret;
                     34: 
                     35:     UNREFERENCED_PARAMETER( hPrevInstance );
                     36:     UNREFERENCED_PARAMETER( lpCmdLine );
                     37:     UNREFERENCED_PARAMETER( nCmdShow);
                     38: 
                     39:     ret = DialogBox (hInstance, "getdevDlg", NULL, MainDlgProc);
                     40:     return ret;
                     41: }
                     42: 
                     43: 
                     44: 
                     45: /**************************************************************************\
                     46: *
                     47: *  function:  MainDlgProc()
                     48: *
                     49: *  input parameters:  standard window procedure parameters.
                     50: *
                     51: * At initialization time, call GetDeviceCaps() repeatedly and place the
                     52: *  results in the list box.
                     53: *
                     54: \**************************************************************************/
                     55: LONG APIENTRY MainDlgProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
                     56: {
                     57:   UNREFERENCED_PARAMETER(lParam);
                     58: 
                     59: 
                     60:   switch (message) {
                     61: 
                     62:     case WM_INITDIALOG: {
                     63:       int i;
                     64:       int value;
                     65:       HDC hdc;
                     66: 
                     67:       hdc = GetDC (hwnd);
                     68: 
                     69:       for (i = 0; i < NINDEX ; i++) {
                     70:         value = GetDeviceCaps (hdc , DevCaps[i].Value);
                     71:         wsprintf (buffer,"%s %8d", DevCaps[i].String, value);
                     72:         SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG) buffer);
                     73:         ExpandInfo (hwnd, DevCaps[i].Value, value);
                     74:       }
                     75: 
                     76:       ReleaseDC (hwnd,hdc);
                     77:     } break;
                     78: 
                     79: 
                     80:     /********************************************************************\
                     81:     * WM_SYSCOMMAND
                     82:     *
                     83:     * ignore all syscommand messages, except for SC_CLOSE.
                     84:     *  on this one, call EndDialog().
                     85:     \********************************************************************/
                     86:     case WM_SYSCOMMAND:
                     87:       if (wParam == SC_CLOSE) {
                     88:         EndDialog (hwnd, TRUE);
                     89:         return TRUE;
                     90:       } else
                     91:         return FALSE;
                     92:     break;
                     93: 
                     94: 
                     95:     default: return FALSE;
                     96:   } /* end switch(message) */
                     97: }
                     98: 
                     99: 
                    100: 
                    101: 
                    102: 
                    103: /**************************************************************************\
                    104: *
                    105: *  function:  ExpandInfo()
                    106: *
                    107: *  input parameters:
                    108: *   hwnd  - parent of the list box with the info.
                    109: *   index - the input value which was sent to GetDeviceCaps().
                    110: *   value - the return value from calling GetDeviceCaps().
                    111: *
                    112: *  global variables:
                    113: *   buffer - string to hold info sent to list box.
                    114: *   space  - format string to wsprintf
                    115: *
                    116: *  Some of the return values from GetDeviceCaps() are bit strings
                    117: *   where each bit has a constant defined for it in wingdi.h.  This
                    118: *   function simply translates the bits into the string constant and
                    119: *   then places that in the listbox.
                    120: *
                    121: \**************************************************************************/
                    122: VOID ExpandInfo (HWND hwnd, int index, int value)
                    123: {
                    124:   int i;
                    125: 
                    126:   switch (index) {
                    127: 
                    128:     case TECHNOLOGY   :
                    129:       for (i = 0 ; i< NDevice ; i++) {
                    130:         if (value == Device[i].Value) {
                    131:           wsprintf (buffer,space, Device[i].String);
                    132:           SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG)buffer);
                    133:         }
                    134:       }
                    135:     break;
                    136: 
                    137: 
                    138: 
                    139:     case CURVECAPS    :
                    140:       for (i = 0 ; i< NCurveCaps ; i++) {
                    141:         if (value & CurveCaps[i].Value) {
                    142:           wsprintf (buffer,space, CurveCaps[i].String);
                    143:           SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG)buffer);
                    144:         }
                    145:       }
                    146:     break;
                    147: 
                    148: 
                    149: 
                    150:     case LINECAPS     :
                    151:       for (i = 0 ; i< NLineCaps ; i++) {
                    152:         if (value & LineCaps[i].Value) {
                    153:           wsprintf (buffer,space, LineCaps[i].String);
                    154:           SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG)buffer);
                    155:         }
                    156:       }
                    157:     break;
                    158: 
                    159: 
                    160: 
                    161:     case POLYGONALCAPS:
                    162:       for (i = 0 ; i< NPolygonalCaps ; i++) {
                    163:         if (value & PolygonalCaps[i].Value) {
                    164:           wsprintf (buffer,space, PolygonalCaps[i].String);
                    165:           SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG)buffer);
                    166:         }
                    167:       }
                    168:     break;
                    169: 
                    170: 
                    171: 
                    172:     case TEXTCAPS     :
                    173:       for (i = 0 ; i< NTextCaps ; i++) {
                    174:         if (value & TextCaps[i].Value) {
                    175:           wsprintf (buffer,space, TextCaps[i].String);
                    176:           SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG)buffer);
                    177:         }
                    178:       }
                    179:     break;
                    180: 
                    181: 
                    182: 
                    183:     case CLIPCAPS     :
                    184:       for (i = 0 ; i< NClipCaps ; i++) {
                    185:         if (value & ClipCaps[i].Value) {
                    186:           wsprintf (buffer,space, ClipCaps[i].String);
                    187:           SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG)buffer);
                    188:         }
                    189:       }
                    190:     break;
                    191: 
                    192: 
                    193: 
                    194:     case RASTERCAPS   :
                    195:       for (i = 0 ; i< NRasterCaps ; i++) {
                    196:         if (value & RasterCaps[i].Value) {
                    197:           wsprintf (buffer,space, RasterCaps[i].String);
                    198:           SendDlgItemMessage (hwnd, DID_LISTBOX, LB_ADDSTRING, 0, (LONG)buffer);
                    199:         }
                    200:       }
                    201:     break;
                    202: 
                    203: 
                    204:     default:
                    205:     break;
                    206: 
                    207:   } /* end switch */
                    208: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.