home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / PEN / PENTKT / UTIL / PENCAL / PMMAIN.C < prev    next >
C/C++ Source or Header  |  1995-04-14  |  3KB  |  116 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. #define INCL_WIN
  13. #define INCL_GPI
  14. #define INCL_DOSPROCESS
  15. #include <os2.h>
  16. #include <stdio.h>
  17. #include <cal.h>
  18. #include <calres.h>
  19. #include "penei.h"
  20.  
  21. HAB  habMain;
  22. HMQ  hmqMain;
  23. FONTMETRICS  fm;
  24.  
  25. char  IOName[20]  = "\\dev\\PENDD$";
  26. char _DriverName[SIZEOF_DEVICE_NAME+1];
  27. char _DeviceName[SIZEOF_DEVICE_NAME+1];
  28. char  appName[] = "CAL";
  29. ULONG scrWidth,scrHeight;
  30. #ifdef DEBUG
  31. BOOL  dbfile;
  32. FILE  *stream;
  33. #endif
  34. BOOL  yinvert;
  35.  
  36. LONG createAlign (HWND owner);
  37. void destroyAlign(void);
  38. void registerAlign(void);
  39.  
  40. void main(int argc,char * argv[])
  41. {
  42.    ULONG flCreateFlags;
  43.    QMSG qmsg;
  44.    HPS  hpsTemp;
  45.  
  46. #ifdef DEBUG
  47. // debug log file. Use presence of the file as a flag to use the file.
  48. // If its not there, then don't create one.
  49.  
  50.    dbfile = FALSE;
  51.    if ((stream=fopen("pencal.log","r"))!=NULL) {
  52.       fclose(stream);
  53.       if ((stream=fopen("pencal.log","w"))!=NULL) {
  54.          fprintf(stream,"debug file open\n");
  55.          dbfile = TRUE;
  56.       } /* endif */
  57.    } /* endif */
  58. #endif
  59.  
  60. // process parm line
  61.  
  62.    if (argc > 1) {
  63.       strcpy(&(_DriverName),argv[1]);
  64.    } /* endif */
  65.  
  66.    if (argc > 2) {
  67.       strcpy(&(_DeviceName),argv[2]);
  68.    } /* endif */
  69.  
  70. #ifdef DEBUG
  71.    if (dbfile) {
  72.       fprintf(stream,"DriverName=%s DeviceName=%s\n",
  73.               _DriverName,_DeviceName);
  74.    }
  75. #endif
  76.  
  77. // start doing PM stuff
  78.  
  79.    habMain=WinInitialize(0);
  80.    hmqMain=WinCreateMsgQueue(habMain,0);
  81.  
  82. // Query screen size, used in several places ahead
  83.  
  84.    scrWidth=WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN);
  85.    scrHeight=WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN);
  86.  
  87.    hpsTemp = WinGetPS    (HWND_DESKTOP);
  88.    GpiQueryFontMetrics (hpsTemp,(LONG)sizeof fm, &fm);
  89.    WinReleasePS(hpsTemp);
  90.  
  91. // create a client window for alignment
  92.  
  93.    registerAlign ();
  94.    createAlign (HWND_DESKTOP);
  95.  
  96. // main processing loop
  97.  
  98.    while (WinGetMsg(habMain,&qmsg,(HWND)NULL,0,0)) {
  99.       WinDispatchMsg(habMain,&qmsg);
  100.    } /* endwhile */
  101.  
  102. // clean up and terminate
  103.  
  104.    destroyAlign();
  105.    WinDestroyMsgQueue(hmqMain);
  106.    WinTerminate(habMain);
  107. #ifdef DEBUG
  108.    if (dbfile) {
  109.       dbfile = FALSE;
  110.       fclose (stream);
  111.    }
  112. #endif
  113.  
  114.    DosExit (EXIT_PROCESS,0);
  115. }
  116.