コード例 #1
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static HBITMAP hbm ;
     HPS            hps ;
     RECTL          rcl ;

     switch (msg)
          {
          case WM_CREATE:
               hps = WinGetPS (hwnd) ;
               hbm = GpiLoadBitmap (hps, 0, IDB_HELLO, 0L, 0L) ;
               WinReleasePS (hps) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;
               GpiErase (hps) ;

               WinQueryWindowRect (hwnd, &rcl) ;

               if (hbm)
                    WinDrawBitmap (hps, hbm, NULL, (PPOINTL) &rcl,
                                   CLR_BACKGROUND, CLR_NEUTRAL, DBM_STRETCH) ;

               WinEndPaint (hps) ;
               return 0 ;

          case WM_DESTROY:
               if (hbm)
                    GpiDeleteBitmap (hbm) ;               
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #2
0
ファイル: ZIN.C プロジェクト: OS2World/APP-EDITOR-Zed
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, 
                                        MPARAM mp1, MPARAM mp2)

{
HPS hps;
RECTL rcl;

switch (msg)
    {
    case WM_CREATE:
        return 0;

    case WM_PAINT:
        hps=WinBeginPaint(hwnd, NULLHANDLE, NULL);
        WinQueryWindowRect(hwnd, &rcl);
        GpiErase(hps);
        WinFillRect(hps, &rcl, CLR_BLUE);
        PaintClient(hps, 100, 100);

        WinEndPaint(hps);
        return 0;

    case WM_DESTROY:
        return 0;
    }
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
コード例 #3
0
/****************************************************************\
 *  Main client painting routine
 *--------------------------------------------------------------
 *
 *  Name:   MainPaint(hwnd)
 *
 *  Purpose: Paints the main client window.
 *
 *  Usage:  Routine is called whenver the client window
 *          procedure receives a WM_PAINT message
 *
 *  Method:
 *          - begins painting by calling WinBeginPaint
 *              and retrieving the HPS for the window
 *          - performs any painting desired
 *          - ends painting by calling WinEndPaint
 *
 *  Returns:
 *
\****************************************************************/
VOID MainPaint(HWND hwnd,                                 /* handle to window */
               CHAR PipeMsgs[MAX_MESSAGES][MESSAGE_LEN],  /* array of messages */
               unsigned int uiIndex,                      /* beginning of circular array */
               SHORT sTotalMsgs)                          /* total number of messages */
{
   RECTL         rclInvalid;
   HPS           hps;
   LONG          sPaintBeg, sPaintEnd, sLine;
   POINTL        ptl;
   unsigned int  uiOffset;

   uiOffset = (sTotalMsgs < MAX_MESSAGES) ? 0 : uiIndex;

   hps = WinBeginPaint(hwnd, NULLHANDLE, (PRECTL)&rclInvalid);
   GpiErase(hps);

   sPaintBeg = max(0, sVscrollPos + (cyClient - rclInvalid.yTop) / cyChar);
   sPaintEnd = min(sTotalMsgs, sVscrollPos + (cyClient - rclInvalid.yBottom) / cyChar + 1);

   for (sLine = sPaintBeg ; sLine < sPaintEnd ; sLine++)
   {
      ptl.x = cxCaps - sHscrollPos ;
      ptl.y = cyClient - cyChar * (BUFF_OFFSET(uiOffset,sLine) + 1 - sVscrollPos) + cyDesc ;

      GpiCharStringAt (hps, &ptl,
                       (LONG) strlen (PipeMsgs[BUFF_OFFSET(uiOffset,sLine)]),
                       PipeMsgs[BUFF_OFFSET(uiOffset,sLine)]) ;
   }

   WinEndPaint (hps) ;
}   /* MainPaint() */
コード例 #4
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, 
                                MPARAM mp1, MPARAM mp2)
     {
     static HWND hwndMenuPopup ;
     HPS         hps ;
     POINTL      ptlMouse ;

     switch (msg)
          {
          case WM_CREATE:
               hwndMenuPopup = WinLoadMenu (hwnd, NULL, ID_POPUP) ;
               WinSetWindowPos (hwndMenuPopup, NULL, 
                                0, 0, 0, 0, SWP_SIZE) ;
               WinSetParent (hwndMenuPopup, HWND_DESKTOP, FALSE) ;
               return 0 ;

          case WM_BUTTON2UP:
               WinQueryPointerPos (HWND_DESKTOP, &ptlMouse) ;
               ptlMouse.y += WinQuerySysValue (HWND_DESKTOP, 
                                               SV_CYMENU) ;

               WinSetWindowPos (hwndMenuPopup, NULL,
                                (SHORT) ptlMouse.x, (SHORT) ptlMouse.y,
                                0, 0, SWP_MOVE) ;

               WinSendMsg (hwndMenuPopup, MM_SELECTITEM,
                           MPFROM2SHORT (IDM_POPUP, FALSE),
                           MPFROMSHORT (FALSE)) ;

               WinSetCapture (HWND_DESKTOP, hwndMenuPopup) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case IDM_ABOUT:
                         WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc,
                                    NULL, IDD_ABOUT, NULL) ;
                         return 0 ;
                    }
               break ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULL, NULL) ;
               GpiErase (hps) ;
               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #5
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static INT  cxClient, cyClient ;
     static LONG alJoin [] = { LINEJOIN_BEVEL, LINEJOIN_ROUND, LINEJOIN_MITRE },
                 alEnd  [] = { LINEEND_FLAT, LINEEND_SQUARE, LINEEND_ROUND } ;
     HPS         hps ;
     INT         i ;

     switch (msg)
	  {
          case WM_SIZE:
               cxClient = SHORT1FROMMP (mp2) ;
               cyClient = SHORT2FROMMP (mp2) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;

               GpiErase (hps) ;

               for (i = 0 ; i < 3 ; i++)
                    {
                              // Draw the geometric line

                    GpiSetLineJoin (hps, alJoin [i]) ;
                    GpiSetLineEnd  (hps, alEnd  [i]) ;
                    GpiSetLineWidthGeom (hps, cxClient / 20) ;
                    GpiSetColor (hps, CLR_DARKGRAY) ;

                    GpiBeginPath (hps, 1) ;
                    DrawFigure (hps, i, cxClient, cyClient) ;
                    GpiEndPath (hps) ;

                    GpiStrokePath (hps, 1, 0) ;

                              // Draw the cosmetic line

                    GpiSetLineWidth (hps, LINEWIDTH_THICK) ;
                    GpiSetColor (hps, CLR_BLACK) ;

                    DrawFigure (hps, i, cxClient, cyClient) ;
                    }

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #6
0
/*------------------------------------------------------------------------*/
MRESULT EXPENTRY SplashWndProc(HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
   static HBITMAP hbm;
   static SWP     swp;
   HPS    hps;
   RECTL  rcl;

   switch(msg)
   {
      case WM_CREATE:
         hps = WinGetPS (hwnd);
         hbm = GpiLoadBitmap(hps,
                             (HMODULE)0L,
                             IDB_LOGO,
                             (ULONG)0,
                             (ULONG)0);
         WinReleasePS (hps);

         WinQueryWindowPos(hwnd, (PSWP)&swp);
         return (MRESULT)0;

      case WM_PAINT:
         hps = WinBeginPaint (hwnd, 
                              NULLHANDLE,  /* Get a cached PS */
                              (RECTL *)0);
         GpiErase (hps);
         
         GpiCreateLogColorTable (hps, LCOL_RESET, LCOLF_RGB,
                                 0L, 0L, NULL) ;
         rcl.xLeft   = 0;
         rcl.yBottom = 0;
         rcl.xRight  = swp.cx;
         rcl.yTop    = swp.cy;

         if ( hbm )
            WinDrawBitmap(hps,hbm, NULL, (PPOINTL) &rcl,
                          CLR_NEUTRAL, CLR_BACKGROUND, DBM_STRETCH );

         WinDrawBorder(hps, &rcl,2L,2L,0L, 0L, DB_DEPRESSED);
         WinEndPaint(hps);
         return (MRESULT)0;


   }
   return( WinDefWindowProc(hwnd, msg, mp1, mp2) );
}
コード例 #7
0
ファイル: hellopm.c プロジェクト: joncampbell123/doslib
MRESULT EXPENTRY HelloWndProc(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2) {
    switch (msg) {
        case WM_PAINT: {
            static char *message = "Hello world! I'm running under OS/2!";
            POINTL pt;
            HPS hps;

            /* where to put it. NTS: OS/2 window coordinates are done Cartesian style where Y increases upward on the screen */
            pt.x = 40;
            pt.y = 40;

            hps = WinBeginPaint(hwnd,0/*NULLHANDLE*/,NULL);
            GpiErase(hps);
            GpiCharStringAt(hps,&pt,strlen(message),message);
            WinEndPaint(hps);
        } return 0;
    }

    return WinDefWindowProc(hwnd,msg,mp1,mp2);
}
コード例 #8
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static INT cxClient, cyClient ;
     HPS        hps;
     POINTL     ptl ;

     switch (msg)
	  {
          case WM_SIZE:
               cxClient = SHORT1FROMMP (mp2) ;
               cyClient = SHORT2FROMMP (mp2) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;
               GpiErase (hps) ;

               ptl.x = cxClient / 8 ;
               ptl.y = 3 * cyClient / 4 ;
               HdrPrintf (hps, &ptl, "Welcome to the %s",
                          "OS/2 2.0 Presentation Manager!") ;

               ptl.x = cxClient / 8 ;
               ptl.y = cyClient / 4 ;
               HdrPuts (hps, &ptl, "This line was displayed by a ") ;
               HdrPuts (hps, NULL, "routine in a dynamic link library.") ;

               ptl.x = 0 ;
               ptl.y = 0 ;
               GpiMove (hps, &ptl) ;

               ptl.x = cxClient - 1 ;
               ptl.y = cyClient - 1 ;
               HdrEllipse (hps, DRO_OUTLINE, &ptl) ;

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #9
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static SHORT cxClient, cyClient ;
     HPS          hps ;

     switch (msg)
	  {
          case WM_SIZE:
               cxClient = LOUSHORT (mp2) ;
               cyClient = HIUSHORT (mp2) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;

               GpiErase (hps) ;

               PaintClient (hps, cxClient, cyClient) ;

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #10
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static INT  cxClient, cyClient ;
     HPS         hps ;
     INT         x, y ;
     POINTL      ptl ;

     switch (msg)
	  {
          case WM_SIZE:
               cxClient = SHORT1FROMMP (mp2) ;
               cyClient = SHORT2FROMMP (mp2) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;

               GpiErase (hps) ;

               for (x = 0 ; x < 3 ; x++)
               for (y = 0 ; y < 2 ; y++)
                    {
                         // Create an open sub-path

                    GpiBeginPath (hps, 1) ;

                    ptl.x = (1 + 10 * x) * cxClient / 30 ;
                    ptl.y = (4 +  5 * y) * cyClient / 10 ;
                    GpiMove (hps, &ptl) ;

                    ptl.x = (5 + 10 * x) * cxClient / 30 ;
                    ptl.y = (2 +  5 * y) * cyClient / 10 ;
                    GpiLine (hps, &ptl) ;

                    ptl.x = (9 + 10 * x) * cxClient / 30 ;
                    ptl.y = (4 +  5 * y) * cyClient / 10 ;
                    GpiLine (hps, &ptl) ;

                         // Create a closed sub-path

                    ptl.x = (1 + 10 * x) * cxClient / 30 ;
                    ptl.y = (3 +  5 * y) * cyClient / 10 ;
                    GpiMove (hps, &ptl) ;

                    ptl.x = (5 + 10 * x) * cxClient / 30 ;
                    ptl.y = (1 +  5 * y) * cyClient / 10 ;
                    GpiLine (hps, &ptl) ;

                    ptl.x = (9 + 10 * x) * cxClient / 30 ;
                    ptl.y = (3 +  5 * y) * cyClient / 10 ;
                    GpiLine (hps, &ptl) ;

                    GpiCloseFigure (hps) ;
                    GpiEndPath (hps) ;

                         // Possibly modify the path

                    if (y == 0)
                         {
                         GpiSetLineWidthGeom (hps, cxClient / 30) ;
                         GpiModifyPath (hps, 1, MPATH_STROKE) ;
                         }

                         // Perform the operation

                    GpiSetLineWidth (hps, LINEWIDTH_THICK) ;
                    GpiSetLineWidthGeom (hps, cxClient / 50) ;
                    GpiSetPattern (hps, PATSYM_HALFTONE) ;

                    switch (x)
                         {
                         case 0:  GpiOutlinePath (hps, 1, 0) ;
                                  break ;

                         case 1:  GpiStrokePath (hps, 1, 0) ;
                                  break ;

                         case 2:  GpiFillPath (hps, 1, FPATH_ALTERNATE) ;
                                  break ;
                         }
                    }

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #11
0
/*
 *
 *  BrowseWndProc
 *
 *  DESCRIPTION:
 *
 *    Processes messages for the Browse-O-Matic client window.
 *
 */
MRESULT EXPENTRY BrowseWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   switch( msg){

      case WM_CREATE:
         {
            CHAR          pszTitle[ MAX_TITLE_LENGTH];
            PBROWSEDATA   pWindowData;

            pWindowData = (PBROWSEDATA)mp1;
            WinSetWindowPtr( hwnd, QWL_USER, pWindowData);

            /*******************/
            /* Load the object */
            /*******************/
            _LoadObject( pWindowData->somSelf,
                        pWindowData->pszObjectName, &pWindowData->ulFileLength,
                                   &pWindowData->pBuffer, &pWindowData->pLines,
                                             &pWindowData->usNumberOfTextLines,
                                          &pWindowData->usNumberOfTextColumns);

            _GetLinesAndColumns( pWindowData->somSelf, pWindowData->bDisplay,
                        &pWindowData->sTotalLines, &pWindowData->sTotalColumns,
                                             pWindowData->usNumberOfTextLines,
                                            pWindowData->usNumberOfTextColumns,
                                                    pWindowData->ulFileLength);

            /*********************************************/
            /* Get the window handle for the scroll bars */
            /*********************************************/
            pWindowData->hwndVscroll = WinWindowFromID( WinQueryWindow( hwnd,
                                                   QW_PARENT), FID_VERTSCROLL);
            pWindowData->hwndHscroll = WinWindowFromID( WinQueryWindow( hwnd,
                                                   QW_PARENT), FID_HORZSCROLL);

            /*************************/
            /* Save font information */
            /*************************/
            WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);

            /*****************/
            /* Get the focus */
            /*****************/
            WinSetFocus( HWND_DESKTOP, hwnd);

            /*****************************************************/
            /* Create the title for the Browse-O-Matic title bar */
            /*****************************************************/
            if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
               sprintf( pszTitle, "Object: %s    (%d Bytes)",
                        pWindowData->pszObjectName, pWindowData->ulFileLength);
            else
               sprintf( pszTitle, "Object: %s    (%hd Lines)",
                         pWindowData->pszObjectName, pWindowData->sTotalLines);

            /************************************************/
            /* Register the current open view of the object */
            /************************************************/
            _wpAddToObjUseList( pWindowData->somSelf, &(pWindowData->UseItem));
            _wpRegisterView( pWindowData->somSelf, WinQueryWindow( hwnd,
                                                         QW_PARENT), pszTitle);
         }
         break;

      case WM_CLOSE:
         {
            HWND        hwndFrame;
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);
            hwndFrame = WinQueryWindow( hwnd, QW_PARENT);

            /*****************************************************/
            /* Save the window info - size, location, and fonts. */
            /*****************************************************/
            WinStoreWindowPos( APPL_NAME, pWindowData->pszApplKey, hwndFrame);

            /**********************************************************/
            /* Free the window data and unload the file system object */
            /**********************************************************/
            if( pWindowData){
               if( pWindowData->pszObjectName)
                  _wpFreeMem( pWindowData->somSelf,
                                           ( PBYTE)pWindowData->pszObjectName);
               _wpFreeMem( pWindowData->somSelf, ( PBYTE)pWindowData);
            }

            _UnloadObject( pWindowData->somSelf, pWindowData->pBuffer,
                                                          pWindowData->pLines);

            _wpDeleteFromObjUseList( pWindowData->somSelf,
                                                        &pWindowData->UseItem);
            /*******************/
            /* Kill the window */
            /*******************/
            WinPostMsg( hwnd, WM_QUIT, 0, 0 );
            WinDestroyWindow( hwndFrame);
         }
         break;

      /*******************************************************************/
      /* The font characteristics have changed. This happens when a font */
      /* from the font palette is dropped on the client window.          */
      /*******************************************************************/
      case WM_PRESPARAMCHANGED:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            if( (ULONG)mp1 == PP_FONTNAMESIZE){

               /***********************************************/
               /* Get the new font information and redraw the */
               /* window with the new font/font size.         */
               /***********************************************/
               WinSendMsg( hwnd, IDL_SETFONTINFO, (MPARAM)0, (MPARAM)0);
               WinSendMsg( hwnd, WM_SIZE, 0, MPFROM2SHORT(
                       pWindowData->sClientWidth, pWindowData->sClientHeight));
            }
         }
         break;

      case WM_SIZE:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            /***************************************/
            /* Save client window size information */
            /***************************************/
            pWindowData->sClientWidth = SHORT1FROMMP( mp2);
            pWindowData->sClientHeight = SHORT2FROMMP( mp2);
            pWindowData->sPageHeight = pWindowData->sClientHeight/
                                                      pWindowData->sCharHeight;
            pWindowData->sPageWidth = pWindowData->sClientWidth  /
                                                       pWindowData->sCharWidth;

            /**************************************/
            /* Set the ranges for the scroll bars */
            /**************************************/
            WinPostMsg( pWindowData->hwndVscroll, SBM_SETSCROLLBAR,
                         (MPARAM)pWindowData->sCurrentLine, MPFROM2SHORT( 0,
                         pWindowData->sTotalLines - pWindowData->sPageHeight));
            WinPostMsg( pWindowData->hwndHscroll, SBM_SETSCROLLBAR,
                        (MPARAM)pWindowData->sCurrentColumn, MPFROM2SHORT( 0,
                        pWindowData->sTotalColumns - pWindowData->sPageWidth));

            /*************************************/
            /* Set scroll bar thumb control size */
            /*************************************/
            WinPostMsg( pWindowData->hwndVscroll, SBM_SETTHUMBSIZE,
                                        MPFROM2SHORT( pWindowData->sPageHeight,
                                        pWindowData->sTotalLines), (MPARAM) 0);
            WinPostMsg( pWindowData->hwndHscroll, SBM_SETTHUMBSIZE,
                                      MPFROM2SHORT( pWindowData->sPageWidth,
                                      pWindowData->sTotalColumns), (MPARAM) 0);

            /************************************************************/
            /* If the all the lines and/or columns can fit in the new   */
            /* sized window, set the sCurrentLine and/or sCurrentColumn */
            /* to the top/right side.                                   */
            /************************************************************/
            if( pWindowData->sPageHeight >= pWindowData->sTotalLines)
               pWindowData->sCurrentLine = 0;

            if( pWindowData->sPageWidth >= pWindowData->sTotalColumns)
               pWindowData->sCurrentColumn = 0;

            /********************************************/
            /* Repaint window with new size information */
            /********************************************/
            WinInvalidateRect( hwnd, NULL, FALSE);
         }
         return( 0);

      case WM_PAINT:
         {
            HPS         hps;
            CHAR        pszText[255];
            UINT        nLength = 0;
            RECTL       rect;
            POINTL      point;
            SHORT       sLine;
            SHORT       sTopLine;
            SHORT       sBottomLine;
            SHORT       sLinesFromTop;
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr( hwnd, QWL_USER);

            hps = WinBeginPaint( hwnd, NULLHANDLE, &rect);

            /*******************************************/
            /* Clear the area that needs to be redrawn */
            /*******************************************/
            GpiErase( hps);

            /********************************/
            /* Determine first clipped line */
            /********************************/
            sLinesFromTop = ( pWindowData->sClientHeight - rect.yTop) /
                                                      pWindowData->sCharHeight;
            rect.yTop = pWindowData->sClientHeight -
                                   ( pWindowData->sCharHeight * sLinesFromTop);

            /***************************************************************/
            /* Determine the first position to write at. NOTE: PM handles  */
            /* clipping for point.x < 0. Any characters written before the */
            /* the first column or after the last column are clipped.      */
            /***************************************************************/
            point.y = rect.yTop - pWindowData->sCharHeight +
                                                   pWindowData->sCharDescender;
            point.x = pWindowData->sCurrentColumn*pWindowData->sCharWidth * -1;

            /***********************************************/
            /* Determine the top and bottom lines to write */
            /***********************************************/
            sTopLine    = rect.yTop    / pWindowData->sCharHeight;
            sBottomLine = rect.yBottom / pWindowData->sCharHeight;

            /*********************************************************/
            /* Make sure that we aren't trying to display more lines */
            /* then are available.                                   */
            /*********************************************************/
            if( pWindowData->sPageHeight - sBottomLine + 1 >
                          pWindowData->sTotalLines - pWindowData->sCurrentLine)
               sBottomLine=pWindowData->sPageHeight-(pWindowData->sTotalLines -
                                                pWindowData->sCurrentLine) + 1;

            /********************************/
            /* Redraw the invalid rectangle */
            /********************************/
            for( sLine = sTopLine; sLine >= sBottomLine; sLine--){

               /*******************************************/
               /* Get the line of text or hex information */
               /* that we are going to write.             */
               /*******************************************/
               if( pWindowData->bDisplay == PMBROWSE_HEX_DISPLAY_MODE)
                  nLength = _GetHexLine( pWindowData->somSelf,
                     pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
                           +1, pWindowData->pBuffer, pWindowData->ulFileLength,
                                                                      pszText);
               else
                  nLength = _GetTextLine( pWindowData->somSelf,
                       pWindowData->sPageHeight-sLine+pWindowData->sCurrentLine
                                             +1, pWindowData->pLines, pszText);

               /******************/
               /* Write the text */
               /******************/
               if( nLength != 0)
                  GpiCharStringAt( hps, &point, nLength, pszText);

               point.y -= pWindowData->sCharHeight;
            }

            WinEndPaint( hps);
         }
         return( 0);

      /*******************************************/
      /* Keyboard support for scrolling and help */
      /*******************************************/
      case WM_CHAR:

         /****************************************/
         /* Show general help if user selects F1 */
         /****************************************/
         if( CHARMSG( &msg)->vkey == VK_F1){
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);
            _wpDisplayHelp( pWindowData->somSelf, PANEL_MAIN,
                            "browse.hlp");
            return 0;
         }

         if( (CHARMSG( &msg)->fs & KC_KEYUP))
            return 0;

         switch( CHARMSG( &msg)->vkey){

            case VK_UP:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEUP));
               return 0;

            case VK_DOWN:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_LINEDOWN));
               return 0;

            case VK_RIGHT:
               /************************************************************/
               /* Ctrl-Right scrolls one page to the right. Right scrolls  */
               /* to the right.                                            */
               /************************************************************/
               if( (CHARMSG( &msg)->fs & KC_CTRL))
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT(0, SB_PAGERIGHT));
               else
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT(0, SB_LINERIGHT));
               return 0;

            case VK_LEFT:
               /*********************************************************/
               /* Ctrl-Left scrolls one page to the left. Left scrolls  */
               /* to the Left.                                          */
               /*********************************************************/
               if( (CHARMSG( &msg)->fs & KC_CTRL))
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT( 0, SB_PAGELEFT));
               else
                  WinPostMsg( hwnd, WM_HSCROLL, 0,
                                                MPFROM2SHORT( 0, SB_LINELEFT));
               return 0;

            case VK_PAGEUP:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEUP));
               return 0;

            case VK_PAGEDOWN:
               WinPostMsg( hwnd, WM_VSCROLL, 0, MPFROM2SHORT( 0, SB_PAGEDOWN));
               return 0;

            case VK_HOME:
               {
                  PBROWSEDATA pWindowData;

                  pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

                  /*********************************************************/
                  /* Ctrl-Home positions at the first line, Home positions */
                  /* at the beginning of the current line.                 */
                  /*********************************************************/
                  if( (CHARMSG( &msg)->fs & KC_CTRL)){
                     WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0,
                                          MPFROM2SHORT( 0, SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                                           MPFROMSHORT( 0), 0);
                  }
                  else{
                     WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0,
                                          MPFROM2SHORT( 0, SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                                           MPFROMSHORT( 0), 0);
                  }
                  return 0;
               }

            case VK_END:
               {
                  PBROWSEDATA pWindowData;

                  pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

                  /*********************************************************/
                  /* Ctrl-End positions at the last line, End positions at */
                  /* the end of the current line.                          */
                  /*********************************************************/
                  if( (CHARMSG( &msg)->fs & KC_CTRL)){
                     WinPostMsg( hwnd, WM_VSCROLL, (MPARAM)0, MPFROM2SHORT(
                           pWindowData->sTotalLines - pWindowData->sPageHeight,
                                                           SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                      MPFROMSHORT( pWindowData->sTotalLines -
                                                 pWindowData->sPageHeight), 0);
                  }
                  else{
                     WinPostMsg( hwnd, WM_HSCROLL, (MPARAM)0, MPFROM2SHORT(
                          pWindowData->sTotalColumns - pWindowData->sPageWidth,
                                                           SB_SLIDERPOSITION));
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                      MPFROMSHORT( pWindowData->sTotalColumns -
                                                  pWindowData->sPageWidth), 0);
                  }
                  return 0;
               }
         }
         break;

      /******************/
      /* Scroll Up/Down */
      /******************/
      case WM_VSCROLL:
         {
            PBROWSEDATA pWindowData;

            pWindowData = (PBROWSEDATA) WinQueryWindowPtr(hwnd,QWL_USER);

            switch( SHORT2FROMMP( mp2)){

               case SB_LINEUP:
                  if( pWindowData->sCurrentLine > 0){
                     pWindowData->sCurrentLine--;

                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                         (MPARAM)pWindowData->sCurrentLine, 0);

                     WinScrollWindow( hwnd, 0, pWindowData->sCharHeight * -1,
                               NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_LINEDOWN:
                  if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
                                                     pWindowData->sPageHeight){
                     pWindowData->sCurrentLine++;

                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                         (MPARAM)pWindowData->sCurrentLine, 0);

                     WinScrollWindow( hwnd, 0, pWindowData->sCharHeight, NULL,
                                     NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_PAGEUP:
                  if( pWindowData->sCurrentLine > 0){
                     pWindowData->sCurrentLine = max( 0,
                         pWindowData->sCurrentLine - pWindowData->sPageHeight);
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                          (MPARAM)pWindowData->sCurrentLine,0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_PAGEDOWN:
                  if( pWindowData->sCurrentLine < pWindowData->sTotalLines -
                                                     pWindowData->sPageHeight){
                     pWindowData->sCurrentLine= min( pWindowData->sTotalLines -
                          pWindowData->sPageHeight, pWindowData->sCurrentLine +
                                                     pWindowData->sPageHeight);
                     WinPostMsg( pWindowData->hwndVscroll, SBM_SETPOS,
                                          (MPARAM)pWindowData->sCurrentLine,0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_SLIDERPOSITION:
                  /***********************************************************/
                  /* Can't change current line if all the text fits in the   */
                  /* window.                                                 */
                  /***********************************************************/
                  if( pWindowData->sTotalLines > pWindowData->sPageHeight){
                     pWindowData->sCurrentLine = SHORT1FROMMP( mp2);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);
            }
         }
         break;


      /*********************/
      /* Scroll Right/Left */
      /*********************/
      case WM_HSCROLL:
         {
            PBROWSEDATA pWindowData;

            pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);

            switch( SHORT2FROMMP( mp2)){

               case SB_LINELEFT:
                  if( pWindowData->sCurrentColumn > 0){
                     pWindowData->sCurrentColumn = max( 0,
                                              pWindowData->sCurrentColumn - 1);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                        (MPARAM)pWindowData->sCurrentColumn,0);
                     WinScrollWindow( hwnd, pWindowData->sCharWidth, 0, NULL,
                                     NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_LINERIGHT:
                  if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
                                                      pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns,
                                              pWindowData->sCurrentColumn + 1);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinScrollWindow( hwnd, pWindowData->sCharWidth * -1, 0,
                               NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
                  }
                  return( 0);

               case SB_PAGELEFT:
                  if( pWindowData->sCurrentColumn > 0){
                     pWindowData->sCurrentColumn = max( 0,
                        pWindowData->sCurrentColumn - pWindowData->sPageWidth);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_PAGERIGHT:
                  if(pWindowData->sCurrentColumn < pWindowData->sTotalColumns -
                                                      pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn=min(pWindowData->sTotalColumns
                       - pWindowData->sPageWidth, pWindowData->sCurrentColumn +
                                                      pWindowData->sPageWidth);
                     WinPostMsg( pWindowData->hwndHscroll, SBM_SETPOS,
                                       (MPARAM)pWindowData->sCurrentColumn, 0);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);

               case SB_SLIDERPOSITION:
                  /***********************************************************/
                  /* Can't change current column if all the text fits in the */
                  /* window.                                                 */
                  /***********************************************************/
                  if( pWindowData->sTotalColumns > pWindowData->sPageWidth){
                     pWindowData->sCurrentColumn = SHORT1FROMMP( mp2);
                     WinInvalidateRect( hwnd, NULL, FALSE);
                  }
                  return( 0);
            }
         }
         break;

      /*****************************/
      /* Get font size information */
      /*****************************/
      case IDL_SETFONTINFO:
         {
            HPS         hps;
            FONTMETRICS fm;
            PBROWSEDATA pWindowData;

            pWindowData = ( PBROWSEDATA)WinQueryWindowPtr( hwnd, QWL_USER);

            hps = WinGetPS( hwnd);
            GpiQueryFontMetrics( hps, sizeof( fm), &fm);
            WinReleasePS( hps);

            /***********************************************************/
            /* The character width is average of the average uppercase */
            /* and average lower case widths.                          */
            /***********************************************************/
            pWindowData->sCharWidth     = (SHORT)fm.lMaxCharInc;
            pWindowData->sCharHeight    = (SHORT)fm.lMaxBaselineExt;
            pWindowData->sCharDescender = (SHORT)fm.lMaxDescender;
         }
         return( 0);

      /*********************************************/
      /* Display no help available message to user */
      /*********************************************/
      case HM_HELPSUBITEM_NOT_FOUND:
         return( ( MRESULT)FALSE);

      /**************************************/
      /* Return name of help for keys panel */
      /**************************************/
      case HM_QUERY_KEYS_HELP:
         return( ( MRESULT)PANEL_HELPKEYS);
   }

   /********************************************************/
   /* Let the default window procedure process the message */
   /********************************************************/
   return( WinDefWindowProc( hwnd, msg, mp1, mp2));
}
コード例 #12
0
ファイル: ROPSWND.C プロジェクト: OS2World/DEV-SAMPLES-bmp2
static VOID CreateROPBitmap(HWND hWnd)

{
BITMAPINFOHEADER  bmp;		   /* Bitmap Information Header		*/
BITMAPINFOHEADER2 bminfo2;	   /* Bitmap Information Header		*/
HBITMAP		  hbmConstruct;	   /* Bitmap Handle			*/
HDC		  hDC;		   /* Device Context Handle		*/
HPS		  hpsBitmap;	   /* Bitmap Presentation Space	Handle	*/
LONG		  cFormats;	   /* Formats Count			*/
LONG		  lROP = 0L;	   /* ROP Value				*/
PLONG		  plFormats;	   /* Formats Array			*/
POINTL		  aptl[4];	   /* Conversion Point			*/
RECTL		  rcl;		   /* Window Rectangle			*/
SIZEL		  sizl;		   /* Sizing Structure			*/
register INT i,	n;		   /* Loop Counters			*/

if ( hbmROP )
   GpiDeleteBitmap(hbmROP);

GpiQueryBitmapParameters(hbmView, &bmp);

		       /* Get bitmap device context handle for the main	*/
		       /* Client Window					*/

if ( !(hDC = DevOpenDC(hAB, OD_MEMORY, "*", 0L,	0L, 0L)) )
   return((HBITMAP)NULL);
		       /* Create bitmap	presentation space specifying	*/
		       /* entire map Client Window for size required	*/

WinQueryWindowRect(hWnd, &rcl);
lHorzRange = (cxROP = sizl.cx =	bmp.cx * 16L + 150L) - (cxWindow = rcl.xRight -	rcl.xLeft);
lVertRange = (cyROP = sizl.cy =	bmp.cy * 16L + 150L) - (cyWindow = rcl.yTop - rcl.yBottom);

WinSendMsg(hwndVScroll,	SBM_SETSCROLLBAR, MPFROMSHORT(lVertPos),
	   MPFROM2SHORT(0, lVertRange));
WinSendMsg(hwndVScroll,	SBM_SETTHUMBSIZE, MPFROM2SHORT(cyWindow, cyROP), 0L);

WinSendMsg(hwndHScroll,	SBM_SETSCROLLBAR, MPFROMSHORT(lHorzPos),
	   MPFROM2SHORT(0, lHorzRange));
WinSendMsg(hwndHScroll,	SBM_SETTHUMBSIZE, MPFROM2SHORT(cxWindow, cxROP), 0L);

rclROP.xLeft   = 0L;
rclROP.yBottom = cyROP - cyWindow;
rclROP.xRight  = cxWindow;
rclROP.yTop    = cyROP;

cxImage	= bmp.cx + 10L;
cyImage	= bmp.cy + 10L;

if ( !(hpsBitmap = GpiCreatePS(hAB, hDC, &sizl,	PU_PELS	| GPIT_NORMAL |	GPIA_ASSOC)) )
   {
		       /* Error	occurred during	creation of		*/
		       /* presentation space, close device context	*/
   DevCloseDC(hDC);
   return((HBITMAP)NULL);
   }
		       /* Get the number of bitmap formats that	the	*/
		       /* display driver supports			*/

DevQueryCaps(hDC, CAPS_BITMAP_FORMATS, 1L, &cFormats);

		       /* Get the bitmap display formats.  The first	*/
		       /* set within the array will be the one that	*/
		       /* most closely matches the display device.	*/

GpiQueryDeviceBitmapFormats(hpsBitmap, cFormats	* 2L,
			    plFormats =	(PLONG)malloc(2UL * cFormats * sizeof(LONG)));

		       /* Create actual	bitmap storage for colour wheel	*/
		       /* having the default plane and bit count	*/

memset(&bminfo2, 0, sizeof(BITMAPINFOHEADER2));
bminfo2.cbFix	  = sizeof(BITMAPINFOHEADER2);
bminfo2.cx	  = (ULONG)sizl.cx;
bminfo2.cy	  = (ULONG)sizl.cy;
bminfo2.cPlanes	  = (USHORT)plFormats[0];
bminfo2.cBitCount = (USHORT)plFormats[1];

free(plFormats);

if ( !(hbmConstruct = GpiCreateBitmap(hpsBitmap, &bminfo2, 0L, 0L, 0L))	)
   {
		       /* Error	occurred during	creation of bitmap	*/
		       /* storage, destroy presentation	space created	*/
		       /* and close device context opened		*/

   GpiDestroyPS(hpsBitmap);
   DevCloseDC(hDC);
   return((HBITMAP)NULL);
   }
		       /* Set bitmap as	current	bitmap to use		*/

GpiSetBitmap(hpsBitmap,	hbmConstruct);

		       /* Draw the page					*/
GpiErase(hpsBitmap);

aptl[0].x = 0L;
aptl[0].y = sizl.cy - bmp.cy;
aptl[1].x = bmp.cx;
aptl[1].y = sizl.cy;

aptl[2].x = aptl[2].y =	0L;
aptl[3].x = bmp.cx;
aptl[3].y = bmp.cy;

GpiSetPattern(hpsBitmap, lPattern);

for ( i	= 0; i < 16; i++ )
   {
   for ( n = 0;	n < 16;	n++ )
       {
       rcl.xLeft   = aptl[0].x;
       rcl.xRight  = aptl[1].x + 1L;
       rcl.yBottom = aptl[0].y;
       rcl.yTop	   = aptl[1].y + 1L;
       WinFillRect(hpsBitmap, &rcl, lFillColour);
       GpiWCBitBlt(hpsBitmap, hbmView, 4L, aptl, lROP++, BBO_IGNORE);
       aptl[0].x += (bmp.cx + 10L);
       aptl[1].x += (bmp.cx + 10L);
       }
   aptl[0].y -=	(bmp.cy	+ 10L);
   aptl[1].y -=	(bmp.cy	+ 10L);
   aptl[0].x = 0L;
   aptl[1].x = bmp.cx;
   }
		       /* Set the bitmap to allow completion of	bitmap	*/
		       /* in memory					*/

GpiSetBitmap(hpsBitmap,	(HDC)NULL);

		       /* Destroy the memory device context		*/

GpiAssociate(hpsBitmap,	(HDC)NULL);

		       /* Destroy the presentation spaces used		*/
GpiDestroyPS(hpsBitmap);
DevCloseDC(hDC);
		       /* Return the bitmap handle that	will be	used in	*/
		       /* painting the image on	the window		*/
hbmROP = hbmConstruct;
}
コード例 #13
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static DATETIME   dtPrevious ;
     static HDC        hdc ;
     static LONG       xPixelsPerMeter, yPixelsPerMeter ;
     static POINTL     aptlHour   [5] = { 0,-15, 10,0, 0,60, -10,0, 0,-15 },
                       aptlMinute [5] = { 0,-20,  5,0, 0,80,  -5,0, 0,-20 },
                       aptlSecond [2] = { 0,  0,  0,80 } ;
     static WINDOWINFO wi ;
     DATETIME          dt ;
     HPS               hps ;
     INT               iDiamMM, iAngle ;
     POINTL            aptl [3] ;

     switch (msg)
          {
          case WM_CREATE:
               hdc = WinOpenWindowDC (hwnd) ;

               DevQueryCaps (hdc, CAPS_VERTICAL_RESOLUTION,
                                  1L, &yPixelsPerMeter) ;
               DevQueryCaps (hdc, CAPS_HORIZONTAL_RESOLUTION,
                                  1L, &xPixelsPerMeter) ;

               DosGetDateTime (&dtPrevious) ;
               dtPrevious.hours = (dtPrevious.hours * 5) % 60 +
                                   dtPrevious.minutes / 12 ;
               return 0 ;

          case WM_SIZE:
               wi.cxClient = SHORT1FROMMP (mp2) ;
               wi.cyClient = SHORT2FROMMP (mp2) ;

               iDiamMM = min (wi.cxClient * 1000L / xPixelsPerMeter,
                              wi.cyClient * 1000L / yPixelsPerMeter) ;

               wi.cxPixelDiam = xPixelsPerMeter * iDiamMM / 1000 ;
               wi.cyPixelDiam = yPixelsPerMeter * iDiamMM / 1000 ;
               return 0 ;

          case WM_TIMER:
               DosGetDateTime (&dt) ;
               dt.hours = (dt.hours * 5) % 60 + dt.minutes / 12 ;

               hps = WinGetPS (hwnd) ;
               GpiSetColor (hps, CLR_BACKGROUND) ;

               DrawHand (hps, aptlSecond, 2, dtPrevious.seconds, &wi) ;

               if (dt.hours   != dtPrevious.hours ||
                   dt.minutes != dtPrevious.minutes)
                    {
                    DrawHand (hps, aptlHour,   5, dtPrevious.hours,   &wi) ;
                    DrawHand (hps, aptlMinute, 5, dtPrevious.minutes, &wi) ;
                    }

               GpiSetColor (hps, CLR_NEUTRAL) ;

               DrawHand (hps, aptlHour,   5, dt.hours,   &wi) ;
               DrawHand (hps, aptlMinute, 5, dt.minutes, &wi) ;
               DrawHand (hps, aptlSecond, 2, dt.seconds, &wi) ;

               WinReleasePS (hps) ;
               dtPrevious = dt ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;
               GpiErase (hps) ;

               for (iAngle = 0 ; iAngle < 60 ; iAngle++)
                    {
                    aptl[0].x = 0 ;
                    aptl[0].y = 90 ;

                    RotatePoint    (aptl, 1, iAngle) ;
                    ScalePoint     (aptl, 1, &wi) ;
                    TranslatePoint (aptl, 1, &wi) ;

                    aptl[2].x = aptl[2].y = iAngle % 5 ? 2 : 10 ;

                    ScalePoint (aptl + 2, 1, &wi) ;

                    aptl[0].x -= aptl[2].x / 2 ;
                    aptl[0].y -= aptl[2].y / 2 ;

                    aptl[1].x = aptl[0].x + aptl[2].x ;
                    aptl[1].y = aptl[0].y + aptl[2].y ;

                    GpiMove (hps, aptl) ;
                    GpiBox (hps, DRO_OUTLINEFILL, aptl + 1,
                                 aptl[2].x, aptl[2].y) ;
                    }
               DrawHand (hps, aptlHour,   5, dtPrevious.hours,   &wi) ;
               DrawHand (hps, aptlMinute, 5, dtPrevious.minutes, &wi) ;
               DrawHand (hps, aptlSecond, 2, dtPrevious.seconds, &wi) ;

               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
コード例 #14
0
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static CHAR szErrorMsg [] = "File not found or could not be opened" ;
     static INT  cxClient, cyClient, cxChar, cyChar, cyDesc ;
     CHAR        *pcReadBuffer ;
     FILE        *fileInput ;
     FONTMETRICS fm ;
     HPS         hps ;
     INT         iLength ;
     POINTL      ptl ;

     switch (msg)
          {
          case WM_CREATE:
               hps = WinGetPS (hwnd) ;
               EzfQueryFonts (hps) ;

               if (!EzfCreateLogFont (hps, LCID_FIXEDFONT, FONTFACE_MONO,
                                                           FONTSIZE_10, 0))
                    {
                    WinReleasePS (hps) ;

                    WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
                         "Cannot find a fixed-pitch font.  Load the Courier "
                         "fonts from the Control Panel and try again.",
                         szClientClass, 0, MB_OK | MB_WARNING) ;

                    return MRFROMSHORT (1) ;
                    }

               GpiQueryFontMetrics (hps, (LONG) sizeof fm, &fm) ;
               cxChar = fm.lAveCharWidth ;
               cyChar = fm.lMaxBaselineExt ;
               cyDesc = fm.lMaxDescender ;

               GpiSetCharSet (hps, LCID_DEFAULT) ;
               GpiDeleteSetId (hps, LCID_FIXEDFONT) ;
               WinReleasePS (hps) ;
               return 0 ;
          
          case WM_SIZE:
               cxClient = SHORT1FROMMP (mp2) ;
               cyClient = SHORT2FROMMP (mp2) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case IDM_OPEN:
                         if (WinDlgBox (HWND_DESKTOP, hwnd, OpenDlgProc,
                                        NULLHANDLE, IDD_OPEN, NULL))
                              WinInvalidateRect (hwnd, NULL, FALSE) ;
                         return 0 ;

                    case IDM_ABOUT:
                         WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc,
                                    NULLHANDLE, IDD_ABOUT, NULL) ;
                         return 0 ;
                    }
               break ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ;
               GpiErase (hps) ;

               if (szFileName [0] != '\0')
                    {
                    EzfCreateLogFont (hps, LCID_FIXEDFONT, FONTFACE_MONO,
                                           FONTSIZE_10,    0) ;
                    EzfCreateLogFont (hps, LCID_BOLDFONT,  FONTFACE_MONO,
                                           FONTSIZE_10,    FATTR_SEL_BOLD) ;

                    GpiSetCharSet (hps, LCID_BOLDFONT) ;
                    ptl.x = cxChar ;
                    ptl.y = cyClient - cyChar + cyDesc ;
                    GpiCharStringAt (hps, &ptl, strlen (szFileName),
                                     szFileName) ;
                    ptl.y -= cyChar ;
                                
                    if ((fileInput = fopen (szFileName, "r")) != NULL)
                         {
                         GpiSetCharSet (hps, LCID_FIXEDFONT) ;
                         pcReadBuffer = (PCHAR) malloc (cxClient / cxChar) ;

                         while ((ptl.y -= cyChar) > 0 &&
                                fgets (pcReadBuffer, cxClient / cxChar - 2,
                                       fileInput) != NULL)
                              {
                              iLength = strlen (pcReadBuffer) ;

                              if (pcReadBuffer [iLength - 1] == '\n')
                                   iLength-- ;

                              if (iLength > 0)
                                   GpiCharStringAt (hps, &ptl, iLength,
                                                    pcReadBuffer) ;
                              }
                         free (pcReadBuffer) ;
                         fclose (fileInput) ;
                         }
                    else           // file cannot be opened
                         {
                         ptl.y -= cyChar ;
                         GpiCharStringAt (hps, &ptl, strlen (szErrorMsg),
                                          szErrorMsg) ;
                         }
                    GpiSetCharSet (hps, LCID_DEFAULT) ;
                    GpiDeleteSetId (hps, LCID_FIXEDFONT) ;
                    GpiDeleteSetId (hps, LCID_BOLDFONT) ;
                    }
               WinEndPaint (hps) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
// -------------------------------------------------------------------------
MRESULT EXPENTRY ClientWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  #define DB_RAISED    0x0400
  #define DB_DEPRESSED 0x0800

  switch (msg) {
    case WM_CREATE:
      break;
    case WM_CONTROL:
      if ( SHORT1FROMMP(mp1) == FID_MENU ){
        if ( SHORT2FROMMP(mp1) == UCN_ITEMSELECTED ){
          PUCMITEM pucmi = (PUCMITEM)mp2;
          if (pucmi) {
            HWND hwndOwner = OWNERWND(hwnd);
            WinSendMsg( hwndOwner, WM_COMMAND,
                        MPFROMSHORT(pucmi->usId), MPFROMSHORT(CMDSRC_MENU) );
          }
        }
      }
      break;

    case WM_PAINT:
      {
      RECTL rcl;
      HPS hPS = WinBeginPaint( hwnd, (HPS)NULL, (PRECTL)0 );
      WinQueryWindowRect( hwnd, &rcl );
      rcl.yBottom = rcl.yTop - 8;
      GpiErase( hPS );
      WinDrawBorder( hPS, &rcl, 2, 2, CLR_DARKGRAY, CLR_PALEGRAY, DB_RAISED );
      WinEndPaint( hPS );
      }
      break;

    case WM_BUTTON1DOWN :
    case WM_BUTTON2DOWN :
      {
      TRACKINFO track;
      SWP       swp;
      RECTL     rclOld;
      HWND      hwndMenu = WinWindowFromID(hwnd, ID_TOOLS);

      WinSetWindowPos( hwndMenu, HWND_TOP, 0, 0, 0, 0, SWP_MOVE );
      RECTL rcl;
      WinQueryWindowRect( hwnd, &rcl );
      rcl.yBottom = rcl.yTop - 8;
      HPS hps = WinGetPS( hwnd );
      WinDrawBorder( hps, &rcl, 2, 2, CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED );
      WinReleasePS( hps );

      #define BORDER 2
      track.cxBorder = track.cyBorder = BORDER;
      track.cxGrid = track.cyGrid = 1;
      track.cxKeyboard = track.cyKeyboard = 4;

      WinQueryWindowPos( hwnd, &swp );
      rclOld.xLeft = swp.x - BORDER;
      rclOld.yBottom = swp.y - BORDER;
      rclOld.xRight = swp.x + swp.cx + BORDER;
      rclOld.yTop = swp.y + swp.cy + BORDER;
      track.rclTrack = rclOld;

      WinQueryWindowRect( PARENTWND(hwnd), &track.rclBoundary );

      track.ptlMinTrackSize.x = track.ptlMinTrackSize.y = 1;  //2*BOXLET_SIZE;
      track.ptlMaxTrackSize   = *(PPOINTL)&track.rclBoundary.xRight;
      track.fs = TF_MOVE;

      if (  WinTrackRect( PARENTWND(hwnd), NULLHANDLE, &track) )
        WinSetWindowPos( hwnd, HWND_TOP,
                         track.rclTrack.xLeft+BORDER, track.rclTrack.yBottom+BORDER,
                         0, 0, SWP_MOVE );
      WinInvalidateRect(hwnd, &rcl, TRUE);
      }
      break;

    default:
      return(WinDefWindowProc(hwnd, msg, mp1, mp2));
  }
  return 0;
}
コード例 #16
0
ファイル: dbgthrd.c プロジェクト: Azarien/open-watcom-v2
unsigned int CallDosDebug( dos_debug __far *buff )
{
    QMSG        qmsg;
    int         num_paints;
    int         i;
    struct {
        RECTL   rcl;
        HWND    hwnd;
    }           paints[MAX_PAINTS];
    HPS         ps;
    char        class_name[80];
    TID         tid;

    if( !IsPMDebugger() ) {
        return( Call32BitDosDebug( buff ) );
    }

    switch( buff->Cmd ) {
    case DBG_C_ClearWatch:
    case DBG_C_Freeze:
    case DBG_C_LinToSel:
    case DBG_C_NumToAddr:
    case DBG_C_ReadCoRegs:
    case DBG_C_ReadMemBuf:
    case DBG_C_ReadMem_D:
    case DBG_C_ReadReg:
    case DBG_C_SelToLin:
    case DBG_C_SetWatch:
    case DBG_C_ThrdStat:
    case DBG_C_WriteCoRegs:
    case DBG_C_WriteMemBuf:
    case DBG_C_WriteMem_D:
    case DBG_C_WriteReg:
        return( Call32BitDosDebug( buff ) );
    }
    switch( buff->Cmd ) {
    case DBG_C_Go:
    case DBG_C_SStep:
    case DBG_C_Term:
        ReleaseQueue( buff->Pid, buff->Tid );
    }
    DebugReqBuff = buff;
    StopBuff = *buff;
    DosSemSet( &DebugDoneSem );
    DosSemClear( &DebugReqSem );
    num_paints = 0;
    if( IsPMDebugger() ) {
        while( WinGetMsg( HabDebugger, &qmsg, 0L, 0, 0 ) || InDosDebug ) {
            WinQueryClassName( qmsg.hwnd, MAX_CLASS_NAME, class_name );
            switch( qmsg.msg ) {
            case WM_CHAR:
                if( ( SHORT1FROMMP( qmsg.mp1 ) & KC_VIRTUALKEY ) &&
                    ( SHORT2FROMMP( qmsg.mp2 ) == VK_BREAK ) ) {
                    SetBrkPending();
                    DosCreateThread( StopApplication, &tid, stack2 + STACK_SIZE );
                    DosSetPrty( PRTYS_THREAD, PRTYC_TIMECRITICAL, 10, tid );
                    WakeThreads( StopBuff.Pid );
                    DosSemWait( &StopDoneSem, SEM_INDEFINITE_WAIT );
                    DosSemSet( &StopDoneSem );
                }
                break;
            case WM_COMMAND:
                CantDoIt();
                break;
            default:
                if( strcmp( class_name, "GUIClass" ) == 0 ||
                    strcmp( class_name, "WTool" ) == 0 ) {
                    switch( qmsg.msg ) {
                    case WM_PAINT:
                        if( num_paints >= MAX_PAINTS ) --num_paints;
                        paints[num_paints].hwnd = qmsg.hwnd;
                        ps = WinBeginPaint( qmsg.hwnd, 0, &paints[ num_paints ].rcl );
                        GpiErase( ps );
                        WinEndPaint( ps );
                        num_paints++;
                        break;
                    case WM_BUTTON1DOWN:
                    case WM_BUTTON2DOWN:
                    case WM_BUTTON3DOWN:
                        CantDoIt();
                        break;
                    case WM_MOUSEMOVE:
                    {
                        HPOINTER hourglass = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE );
                        if( WinQueryPointer( HWND_DESKTOP ) != hourglass ) {
                            WinSetPointer( HWND_DESKTOP, hourglass );
                        }
                        break;
                    }
                    default:
                        WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 );
                    }
                } else {
                    WinDispatchMsg( HabDebugger, &qmsg );
                }
            }
        }
    } else {
        DosSemWait( &DebugDoneSem, SEM_INDEFINITE_WAIT );
    }
    switch( buff->Cmd ) {
    case DBG_N_Exception:
    case DBG_N_AsyncStop:
    case DBG_N_Watchpoint:
        AssumeQueue( buff->Pid, buff->Tid );
        break;
    }
    for( i = 0; i < num_paints; ++i ) {
        WinInvalidateRect( paints[i].hwnd, &paints[i].rcl, FALSE );
    }
    return( DebugReqResult );
}