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

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

unix.superglobalmegacorp.com

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