home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sftick.zip / beg / winfont / WIN1.C < prev    next >
Text File  |  1994-05-05  |  3KB  |  108 lines

  1. #define INCL_WIN
  2. #include <os2.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. #define CLS_CLIENT               "WindowClass"
  8.  
  9. MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
  10.    ULONG ulMsg,
  11.    MPARAM mpParm1,
  12.    MPARAM mpParm2 ) ;
  13.  
  14. INT main ( VOID )
  15. {
  16.    HAB         habAnchor ;
  17.    HMQ         hmqQueue ;
  18.    ULONG       ulFlags ;
  19.    HWND        hwndFrame ;
  20.    HWND        hwndClient ;
  21.    QMSG        qmMsg ;
  22.  
  23.    /* initialization */
  24.    habAnchor = WinInitialize ( 0 ) ;
  25.    hmqQueue = WinCreateMsgQueue ( habAnchor, 0 ) ;
  26.  
  27.    /* register client class */
  28.    WinRegisterClass ( habAnchor,
  29.                       CLS_CLIENT,
  30.                       ClientWndProc,
  31.                       CS_SIZEREDRAW,
  32.                       0 ) ;
  33.  
  34.    ulFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
  35.              FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST ;
  36.  
  37.     /* create frame window and others */
  38.    hwndFrame = WinCreateStdWindow ( HWND_DESKTOP,
  39.                                     WS_VISIBLE,
  40.                                     &ulFlags,
  41.                                     CLS_CLIENT,
  42.                                     "Titlebar",
  43.                                     0,
  44.                                     NULLHANDLE,
  45.                                     0,
  46.                                     &hwndClient ) ;
  47.  
  48.    if ( hwndFrame ) {
  49.         /* typical message processing */
  50.       while ( WinGetMsg ( habAnchor,
  51.                           &qmMsg,
  52.                           NULLHANDLE,
  53.                           0,
  54.                           0 ))
  55.          WinDispatchMsg ( habAnchor, &qmMsg ) ;
  56.  
  57.       WinDestroyWindow ( hwndFrame ) ;
  58.    } /* endif */
  59.  
  60.     /* clean-up */
  61.    WinDestroyMsgQueue ( hmqQueue ) ;
  62.    WinTerminate ( habAnchor ) ;
  63.    return 0 ;
  64. }
  65.  
  66. MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
  67.                                  ULONG ulMsg,
  68.                                  MPARAM mpParm1,
  69.                                  MPARAM mpParm2 )
  70. {
  71.    HPS hps ;
  72.    RECTL rectl ;
  73.    ULONG ulSize ;
  74.    static CHAR achFont[15] ;
  75.  
  76.    switch ( ulMsg ) {
  77.    case WM_PAINT:
  78.        hps = WinBeginPaint( hwndWnd,
  79.                             NULLHANDLE,
  80.                             &rectl );
  81.  
  82.         /* clear screen */
  83.         GpiErase( hps ) ;
  84.         /* actually draw the text */
  85.         WinDrawText( hps, strlen( achFont), achFont, &rectl, 0, 0,
  86.                      DT_CENTER | DT_VCENTER | DT_TEXTATTRS | DT_ERASERECT ) ;
  87.         /* end paint */
  88.         WinEndPaint( hps ) ;
  89.         break;
  90.    case WM_CREATE:
  91.  
  92.         /* use 18 pt Times Roman */
  93.         strcpy( achFont, "18.Tms Rmn") ;
  94.         /* change the font */
  95.         WinSetPresParam( hwndWnd, PP_FONTNAMESIZE, strlen( achFont),
  96.                          achFont ) ;
  97.         break;
  98.  
  99.    default:
  100.       return WinDefWindowProc ( hwndWnd,
  101.                                 ulMsg,
  102.                                 mpParm1,
  103.                                 mpParm2 ) ;
  104.    } /* endswitch */
  105.  
  106.    return MRFROMSHORT ( FALSE ) ;
  107. }
  108.