home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / s12133.zip / WNDPROC.C < prev   
C/C++ Source or Header  |  1988-11-23  |  3KB  |  138 lines

  1. #define INCL_WIN
  2. #define INCL_GPI
  3.  
  4.  
  5. #include <os2.h>
  6. #include "APP.h"
  7. #include <stddef.h>
  8. #include <string.h>
  9.  
  10. extern char szAppName[];
  11. extern char szEdit[];
  12. LONG   FontsAvail=30;
  13. extern HAB    hAB;
  14. HPS    hPS;
  15. FONTMETRICS fm[30];
  16. FATTRS     vfat;
  17. FONTMETRICS FontMetrics;
  18. OWNERITEM FAR * oi;
  19. int i=0;
  20.  
  21. MRESULT FAR PASCAL APPWndProc( hWnd, message, mp1, mp2 )
  22. HWND    hWnd;
  23. USHORT  message;
  24. MPARAM  mp1;
  25. MPARAM  mp2;
  26. {
  27.  
  28.     switch( message )
  29.     {
  30.     case WM_CREATE:
  31.         hPS = WinGetPS (hWnd);
  32.     /*load courier font set */
  33.         GpiLoadFonts( hAB, (PSZ) "c:\\os2\\dll\\courier.fon");
  34.     /*query all available private fonts */
  35.         GpiQueryFonts (hPS, (ULONG)QF_PRIVATE,
  36.                NULL, &FontsAvail, (LONG) sizeof(FONTMETRICS), fm);
  37.  
  38.     /*find suitable fixed pitch font */
  39.         while((i<=FontsAvail))
  40.         {
  41.  
  42.            if((fm[i].fsDefn & 0x8000) && (fm[i].fsType & FATTR_TYPE_FIXED))
  43.           break;
  44.            i++;
  45.         }
  46.  
  47.       /*prepare FATTRS stuct for later use in WM_DRAWITEM processing in
  48.     GpiCreateLogFont call                   */
  49.         vfat.usRecordLength  =  sizeof(FATTRS) ;
  50.         vfat.lMatch      =  fm[i].lMatch;
  51.         vfat.fsSelection     =  fm[i].fsSelection;
  52.         strcpy(vfat.szFacename, fm[i].szFacename) ;
  53.         vfat.idRegistry     =  fm[i].idRegistry ;
  54.         vfat.usCodePage     =  850;
  55.         vfat.lMaxBaselineExt =  fm[i].lMaxBaselineExt;
  56.         vfat.lAveCharWidth     =  fm[i].lAveCharWidth;
  57.         vfat.fsType      =  FATTR_TYPE_FIXED;
  58.         vfat.fsFontUse     =  0;
  59.  
  60.      /* Get metrics  */
  61.         GpiCreateLogFont( hPS, (PSTR8) szAppName,(LONG)i+1, &vfat );
  62.         GpiSetCharSet(hPS,(LONG)i+1);
  63.         GpiQueryFontMetrics (hPS, (long) sizeof FontMetrics, &FontMetrics);
  64.         GpiSetCharSet(hPS,0L);
  65.         WinReleasePS (hPS);
  66.             return (0);
  67.  
  68.  
  69.  
  70.     case WM_CLOSE:
  71.     hPS = WinGetPS (hWnd);
  72.  
  73.     GpiDeleteSetId ( hPS,(LONG)2);
  74.     WinReleasePS (hPS);
  75.  
  76.         WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
  77.         break;
  78.  
  79.     case WM_COMMAND:
  80.         switch (LOUSHORT(mp1)) {
  81.  
  82.             case IDITEM:
  83.                 APPCommand( hWnd, message, mp1, mp2 );
  84.                 break;
  85.  
  86.             case IDENTER:
  87.         if (WinDlgBox( HWND_DESKTOP, hWnd, (PFNWP)EditDlg, NULL, IDD_INPUT,
  88.             NULL )) {
  89.             WinMessageBox( HWND_DESKTOP, hWnd,
  90.                        szEdit,
  91.                        "Edit Control", NULL,
  92.                        MB_OK | MB_ICONEXCLAMATION );
  93.                 }
  94.                 break;
  95.  
  96.             case IDABOUT:
  97.         WinDlgBox( HWND_DESKTOP, hWnd, (PFNWP)About, NULL, IDD_ABOUT,
  98.             NULL );
  99.                 break;
  100.  
  101.             default:
  102.                 break;
  103.             }
  104.             break;
  105.  
  106.  
  107.     case WM_PAINT:
  108.         APPPaint( hWnd, message, mp1, mp2 );
  109.         break;
  110.  
  111.     case WM_ERASEBACKGROUND:
  112.     return TRUE;
  113.     break;
  114.  
  115.     case WM_DRAWITEM:
  116.        oi = mp2;
  117.     /*create log font and set char set for Presentation Space of Listbox (oi->hps)*/
  118.        GpiCreateLogFont(oi->hps, (PSTR8) szAppName,(LONG)i+1, &vfat );
  119.        GpiSetCharSet(oi->hps,(LONG)i+1);
  120.     /*return false to tell listbox proc to draw items  */
  121.        return(FALSE);
  122.  
  123.  
  124.  
  125.     default:
  126.         return WinDefWindowProc( hWnd, message, mp1, mp2 );
  127.         break;
  128.  
  129.     }
  130.  
  131.     return( 0L );
  132. }
  133. /*
  134. */
  135.  
  136. /*
  137. */
  138.