Example #1
0
void OS2Popup::show( int xPos, int yPos )
{
    POINTL ptl = { xPos, yPos };
    // Invert Y
    ptl.y = ( WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ) - 1 ) - ptl.y;
    WinMapWindowPoints( HWND_DESKTOP, m_hWnd, &ptl, 1 );

    WinPopupMenu( m_hWnd, m_hWnd, m_hMenu, ptl.x, ptl.y, 0,
                  PU_HCONSTRAIN | PU_VCONSTRAIN | PU_NONE |
                  PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 );
}
void        PopupMenu( HWND hwnd, PMINIRECORDCORE pRec)

{
    HWND        hMenu;
    POINTL      ptl;

do
{
    // only show the menu if we're over an item
    if (pRec == 0)
        break;

    // if 0 or 1 item is selected, show the single object menu;
    // if more than 1 is selected, show the multiple object menu
    if ((pRec->flRecordAttr & CRA_SELECTED) == 0)
    {
        hMenu = hmnuSingle;
        WinSendMsg( hCnr, CM_SETRECORDEMPHASIS, (MP)pRec,
                    MPFROM2SHORT( TRUE, CRA_SOURCE));
    }
    else
    {
        if (WinSendMsg( hCnr, CM_QUERYRECORDEMPHASIS, (MP)CMA_FIRST,
                        (MP)CRA_SELECTED) != (MP)pRec)
            hMenu = hmnuMultiple;
        else
        if (WinSendMsg( hCnr, CM_QUERYRECORDEMPHASIS, (MP)pRec,
                        (MP)CRA_SELECTED) != 0)
            hMenu = hmnuMultiple;
        else
            hMenu = hmnuSingle;
    }

    // if we're using the single object menu, save the item it refers to 
    // and set the appropriate menu text;  otherwise, set this to zero
    if (hMenu == hmnuMultiple)
        precMenu = 0;
    else
    {
        precMenu = pRec;
        WinSendMsg( hMenu, MM_SETITEMTEXT, (MP)IDM_DELETE,
        (MP)((((PULONG)&pRec[1])[eDEL] == hDelIco) ? "~Undelete" : "~Delete"));
    }

    // popup the menu at the mouse pointer
    WinQueryPointerPos( HWND_DESKTOP, &ptl);
    WinPopupMenu( HWND_DESKTOP, hwnd, hMenu, ptl.x, ptl.y, 0,
                  PU_HCONSTRAIN | PU_VCONSTRAIN |
                  PU_MOUSEBUTTON1 | PU_KEYBOARD);

} while (fFalse);

    return;
}
Example #3
0
MRESULT mainwmButton2Up( HWND hwnd, MPARAM mp1, MPARAM mp2 )
{
    POINTS  pts;
    ULONG   fs = PU_POSITIONONITEM | PU_NONE | PU_SELECTITEM | PU_KEYBOARD | PU_MOUSEBUTTON1;

    WinEnableMenuItem( hwndPopupMenu, IDM_COPY, markingState );
    WinEnableMenuItem( hwndPopupMenu, IDM_CUT, markingState );
    WinEnableMenuItem( hwndPopupMenu, IDM_CLEAR, markingState );

    pts.x = SHORT1FROMMP( mp1 );
    pts.y = SHORT2FROMMP( mp1 );

    WinPopupMenu( hwnd, hwnd, hwndPopupMenu, pts.x, pts.y, IDM_PASTE, fs );

    return 0L;
}
static  void    kstMenu(HWND hwnd, KSTPTR p)
{
    POINTL  pt   ;
    ULONG   opts ;

    if (p->hwndMn == NULLHANDLE) {
        p->hwndMn = WinLoadMenu(hwnd, NULLHANDLE, IDM_KEYST) ;
    }
    if (p->hwndMn == NULLHANDLE) {
        return ;
    }

    WinQueryPointerPos(HWND_DESKTOP, &pt) ;

    opts = PU_HCONSTRAIN | PU_VCONSTRAIN |
             PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 ;

    WinPopupMenu(HWND_DESKTOP, hwnd, p->hwndMn,
                                     pt.x, pt.y, IDM_KEYTGL, opts) ;
}
/*-------------------------------------------------------------------------
                            ActMsgContextMenu
--------------------------------------------------------------------------*/
MRESULT ActMsgContextMenu( WNDATTR *wndattr, USHORT x, USHORT y )
{
 BOOL state;

   if (Popup == NULLHANDLE)
      return MRFROMSHORT( TRUE );

   if (MateScrollWnd != NULLHANDLE) {
      if (WinIsWindow( wndattr->hab, MateScrollWnd ) == FALSE)
         MateScrollWnd = NULLHANDLE;
   }

   state = (LPListMarkedLines( wndattr->list ) == 0);
   SetAttr( CMD_COPY, MIA_DISABLED, state );
   SetAttr( CMD_UNMARK, MIA_DISABLED, state );
   SetAttr( CMD_REARRANGE, MIA_DISABLED, state );

   WinOpenClipbrd( wndattr->hab );
   state = (WinQueryClipbrdData( wndattr->hab, CF_TEXT ) == 0);
   WinCloseClipbrd( wndattr->hab );
   SetAttr( CMD_PASTE, MIA_DISABLED, state );

   state = (WinQueryClipbrdViewer( wndattr->hab ) == wndattr->Client);
   SetAttr( CMD_ACCUM, MIA_CHECKED, state );

   state = (MateScrollWnd != NULLHANDLE);
   SetAttr( CMD_MATE, MIA_CHECKED, state );

   WinPopupMenu( wndattr->Frame,
                 wndattr->Frame,
                 Popup,
                 x, y, CMD_ABOUT,
                 PU_HCONSTRAIN | PU_VCONSTRAIN | PU_POSITIONONITEM |
                 PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 );

   return MRFROMSHORT( FALSE );
}
BOOL NextBar::OCommand(ULONG msg, MPARAM mp1, MPARAM mp2)
{
 switch(msg)
  {
    case WM_CREATE:
      if (setup.floating)
        floatTimer.setNotify(hwnd).start();
      break;

    case WM_TOOLBAR_RESET:
      resetToolBar();
      break;

    case WM_CFG_CANCELED: {
      pNextBarEvent actual = (pNextBarEvent) PVOIDFROMMP(mp1);
      if (actual)
         events.del(actual);
      break; }
 
    case WM_SAVE_BUTTONS:
      saveProfile();
      resetToolBar();
      break;

    case WM_CONTROL:
      switch(SHORT1FROMMP(mp1))
       {
        case OBUTTONBAR_MOVEOVER:
          selectedButton = SHORT2FROMMP(mp1);
          break;

        case OBUTTONBAR_BUTTON2DOWN:
          selectedButton = SHORT2FROMMP(mp1);
          WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(NHX_DEL_BUTTON, FALSE),
                     MPFROM2SHORT(MIA_DISABLED, (selectedButton == NHX_MAIN) ? MIA_DISABLED : ~MIA_DISABLED));
          WinSendMsg(menu, MM_SETITEMATTR, MPFROM2SHORT(NHX_CFG_BUTTON, FALSE),
                     MPFROM2SHORT(MIA_DISABLED, (selectedButton == NHX_MAIN) ? MIA_DISABLED : ~MIA_DISABLED));
          WinPopupMenu(frame, frame, menu, SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), NHX_CFG_BUTTON,
                     PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1 |
                     PU_POSITIONONITEM | PU_HCONSTRAIN | PU_VCONSTRAIN);
          break;
       }
      break;

    case WM_TIMER:
      if (setup.floating)
        WinSetWindowPos(WinQueryWindow(hwnd,QW_PARENT), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
      break;

    case WM_COMMAND: {
       ULONG command = SHORT1FROMMP(mp1);
       pNextBarEvent actual = events.getItem(selectedButton - NHX_FIRST_BUTTON);

       switch(command)
        {
         case NHX_MAIN:
            closeFolders(TRUE);
            break;
 
         case NHX_INFOMNU: {
            pNextBarInfoDlg  dlg = new NextBarInfoDlg;
            dlg->createDlg();
            break; }

         case NHX_FLOAT:
            if (setup.floating) {
               setup.floating = FALSE;
               floatTimer.stop(); }
            else {
               setup.floating = TRUE;
               floatTimer.setNotify(hwnd).start(); }
            WinCheckMenuItem(menu, NHX_FLOAT, setup.floating);
            break;

         case NHX_QUIT:
            WinPostMsg(hwnd, WM_CLOSE, NULL, NULL);
            break;

         case NHX_MOVE:
            trackButtons();
            break;

         case NHX_SENKRECHT:
            setNewStyle(OButtonBar::up2down);
            break;

         case NHX_WAAGERECHT:
            setNewStyle(OButtonBar::left2right);
            break;

         case NHX_NORMICONS:
            setup.large = FALSE;
            setNewStyle(setup.style);
            break;

         case NHX_LARGEICONS:
            setup.large = TRUE;
            setNewStyle(setup.style);
            break;

         case NHX_ADD_BUTTON: {
            pNextBarEvent aNew = new NextBarEvent;
            pNextBarDlg   dlg = new NextBarDlg(aNew, NULL, TRUE);

            events.addAfter(actual, aNew);
            dlg->createDlg();
            break; }

         case NHX_DEL_BUTTON:
            events.del(actual);
            resetToolBar();
            break;

         case NHX_CFG_BUTTON: {
            pOGraphicsButton button = nxButtons->buttons.getItem(selectedButton - NHX_FIRST_BUTTON + 1);
            pNextBarDlg dlg = new NextBarDlg(actual, button, FALSE);
            dlg->createDlg();
            break; }

         case NHX_HELP:
            helpRequest(PANEL_MAIN);
            break;

         default:
            if (actual)  
              actual->startEvent();
            break;
         }
       break; }

    case WM_SIZE:
      if (nxButtons)
        WinSetWindowPos(nxButtons->frame, HWND_TOP, 0, 0,
            (setup.style == OButtonBar::left2right) ?  SHORT1FROMMP(mp2) : buttonSize,
            (setup.style == OButtonBar::left2right) ?  buttonSize : SHORT2FROMMP(mp2),
             SWP_MOVE | SWP_SIZE);
      break;

    case WM_CLOSE:
      WinQueryWindowPos(frame, &setup.position);
      strcpy(setup.bubbleFont, nxButtons->bubbleHelpWin.pparms.Font); 
      ini->write("NextHand", "NextInfo 1.5", &setup, sizeof(NextInfo));
      ini->close();
      hideFrame();
      OApp::currentOApp->forceQuit();
      break;

    default:
       return(FALSE);
   }
 return(TRUE);
}
MRESULT EXPENTRY
fnwpWxTaskWidget( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  MRESULT mrc = 0;
  // get widget data from QWL_USER (stored there by WM_CREATE)
  PXCENTERWIDGET pWidget = (PXCENTERWIDGET)WinQueryWindowPtr( hwnd, QWL_USER );
  // this ptr is valid after WM_CREATE

  switch( msg )
  {
    /*
     * WM_CREATE:
     *      as with all widgets, we receive a pointer to the
     *      XCENTERWIDGET in mp1, which was created for us.
     *
     *      The first thing the widget MUST do on WM_CREATE
     *      is to store the XCENTERWIDGET pointer (from mp1)
     *      in the QWL_USER window word by calling:
     *
     *          WinSetWindowPtr(hwnd, QWL_USER, mp1);
     *
     *      We could use XCENTERWIDGET.pUser for allocating
     *      another private memory block for our own stuff,
     *      for example to be able to store fonts and colors.
     *      We ain't doing this in the minimal sample.
     */

    case WM_CREATE:
      WinSetWindowPtr(hwnd, QWL_USER, mp1);
      pWidget = (PXCENTERWIDGET)mp1;
      if(( !pWidget ) || ( !pWidget->pfnwpDefWidgetProc )) {
        // shouldn't happen... stop window creation!!
        mrc = (MPARAM)TRUE;
      }

      hwndMenu = WinCreateWindow( hwnd, WC_MENU, 0, 0, 0, 0, 0, 0,
                                  hwnd, HWND_TOP, ID_MENU_TASKS, 0, 0 );

      ico_tasks  = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_TASKS  );
      ico_detach = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_DETACH );
      ico_dos    = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_DOS    );
      ico_os2fs  = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_OS2FS  );
      ico_os2vio = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_OS2VIO );
      ico_pm     = WinLoadPointer( HWND_DESKTOP, hmodMe, ID_ICON_PM     );
      break;

    /*
     * WM_BUTTON1CLICK:
     *      clicked on the window
     */

    case WM_BUTTON1CLICK:
    {
      mrc = (MPARAM)WgtControl( pWidget, mp1, mp2 );

      RECTL  rcl;
      POINTL ptl;
      SWP    swp;

      // Check if Ctrl is pressed
      if( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 ) {
        bType = TRUE;
      } else {
        bType = FALSE;
      }

      // Fill it with items
      FillMenu( hwndMenu );

      // Place popup according to xCenter position
      if( pWidget->pGlobals->ulPosition == XCENTER_BOTTOM )
      {
        WinQueryWindowRect( hwnd, &rcl );
        ptl.y = rcl.yTop + 1;
        ptl.x = rcl.xLeft;
        WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 0 );
      }
      else
      {
        WinQueryWindowRect( hwnd, &rcl );
        ptl.y = rcl.yBottom;
        ptl.x = rcl.xLeft;
        WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 0 );
        memset( &swp, 0, sizeof(SWP));
        swp.fl = SWP_SIZE;
        WinSendMsg( hwndMenu, WM_ADJUSTWINDOWPOS, MPFROMP(&swp), 0 );
        ptl.y -= swp.cy;
      }

      // Show menu
      WinPopupMenu( hwnd, hwnd, hwndMenu, ptl.x, ptl.y, 0,
                    PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_HCONSTRAIN | PU_VCONSTRAIN );
      break;
    }

    case WM_COMMAND:
    {
      char      szPid[1024];
      MENUITEM  mi;
      SHORT     id;
      TASKDATA* data;

      // Get menu id and data
      id = SHORT1FROMMP(mp1);
      WinSendMsg( hwndMenu, MM_QUERYITEM, MPFROM2SHORT( id, FALSE ), MPFROMP( &mi ));
      data = (TASKDATA*)mi.hItem;

      // Is it "our" item ??
      if( id >= ID_ITEM_FIRST && id < 10000 )
      {
        if( bType )
        {
          // Ctrl was pressed on icon, kill pid
          if( WinGetKeyState( HWND_DESKTOP, VK_CTRL ) & 0x8000 )
          {
            // Ctrl was pressed on menu item, use external kill
            sprintf( szPid, "Kill this process (%d) using fastio$ ?", data->pid );

            if( WinMessageBox( HWND_DESKTOP, hwnd, szPid, "xCenter", 0,
                               MB_ICONQUESTION | MB_YESNO    |
                               MB_APPLMODAL    | MB_MOVEABLE | MB_DEFBUTTON2 ) == MBID_YES )
            {
              DosKillFastIo( data->pid );
            }
          } else {
            sprintf( szPid, "Are you sure that you want to kill this process (%d)?", data->pid );

            if( WinMessageBox( HWND_DESKTOP, hwnd, szPid, "xCenter", 0,
                               MB_ICONQUESTION | MB_YESNO    |
                               MB_APPLMODAL    | MB_MOVEABLE | MB_DEFBUTTON2) == MBID_YES )
            {
              DosKillProcess( DKP_PROCESS, data->pid );
            }
          }
        } else {
          // No Ctrl, its a switch to task
          SwitchTo( data );
        }
      } else {
        // Its Ulrichs menu, forward
        mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
      }

      break;
    }

    /*
     * WM_CONTROL:
     *      process notifications/queries from the XCenter.
     */

    case WM_CONTROL:
      mrc = (MPARAM)WgtControl( pWidget, mp1, mp2 );
      break;

    /*
     * WM_PAINT:
     *      well, paint the widget.
     */

    case WM_PAINT:
      WgtPaint( hwnd, pWidget );
      break;

    /*
     * WM_PRESPARAMCHANGED:
     *      A well-behaved widget would intercept
     *      this and store fonts and colors.
     */

    case WM_PRESPARAMCHANGED:
      break;

    case WM_MEASUREITEM:
      return MeasureMenuItem((POWNERITEM)mp2 );

    case WM_DRAWITEM:
      return DrawMenuItem((POWNERITEM)mp2 );

    /*
     * WM_DESTROY:
     *      clean up. This _must_ be passed on to
     *      ctrDefWidgetProc.
     */

    case WM_DESTROY:
      // If we had any user data allocated in WM_CREATE
      // or elsewhere, we'd clean this up here.
      // We _MUST_ pass this on, or the default widget proc
      // cannot clean up.
      WinDestroyWindow ( hwndMenu   );
      WinDestroyPointer( ico_tasks  );
      WinDestroyPointer( ico_detach );
      WinDestroyPointer( ico_dos    );
      WinDestroyPointer( ico_os2fs  );
      WinDestroyPointer( ico_os2vio );
      WinDestroyPointer( ico_pm     );

      mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
      break;

    default:
      mrc = pWidget->pfnwpDefWidgetProc( hwnd, msg, mp1, mp2 );
  }

  return (mrc);
}
Example #8
0
/*----------------------------------------------------------------------------*/                   
MRESULT EXPENTRY DLG_MAIN_Proc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)                    
/*----------------------------------------------------------------------------*/                   
/* This dialog proc initializes and handles all messages for the main         */
/* dialog.                                                                    */
/*----------------------------------------------------------------------------*/                   
{                                                                                                  
static HWND  ContextHwnd;  /* Handle of context menu                     */
static SHORT ContextIndx;  /* Index of item context menu was selected on */
                                                                                                   
  switch (msg) {                                                                                   
                                                                                                   
    case WM_INITDLG:                                                                               
      INSERTITEM(LIST, "Listbox item 0");
      INSERTITEM(LIST, "Listbox item 1");
      INSERTITEM(LIST, "Listbox item 2");
      INSERTITEM(LIST, "Listbox item 3");
      INSERTITEM(LIST, "Listbox item 4");
      INSERTITEM(LIST, "Listbox item 5");
      INSERTITEM(LIST, "Listbox item 6");
      INSERTITEM(LIST, "Listbox item 7");
      INSERTITEM(LIST, "Listbox item 8");
      INSERTITEM(LIST, "Listbox item 9");
      INSERTITEM(LIST, "Listbox item 10");
      INSERTITEM(LIST, "Listbox item 11");
      INSERTITEM(LIST, "Listbox item 12");
      INSERTITEM(LIST, "Listbox item 13");
      INSERTITEM(LIST, "Listbox item 14");
      INSERTITEM(LIST, "Listbox item 15");

      /* Add direct-manipulation capability to the listbox */
      DMLBInitialize(CONTROLHWND(LIST), NULLHANDLE);

      /* Load context menu for later use */
      ContextHwnd = WinLoadMenu(hwnd, NULLHANDLE, ID_MENU);

      return FALSE;                                           

    case WM_DESTROY:
      /* Free resources */
      WinDestroyWindow(ContextHwnd);
      break;
                                                              
    case WM_COMMAND:                                          
      switch (SHORT1FROMMP(mp1)) {                            

        /*******************************************************************/
        /* We get WM_COMMAND messages from the context menu.  The variable */
        /* ContextIndx already has the index of the item on which the      */
        /* context menu was requested (or LIT_NONE).                       */
        /*******************************************************************/

        case ID_MENU_EDIT: {  //------- Context menu "Edit" selected -----------
          char Buff[MAX_LEN];
          /* Run edit menu, update list if user selects OK button */
          QUERYITEMTEXT(LIST, ContextIndx, Buff, sizeof(Buff));
          if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff)
              == DID_OK)
            SETITEMTEXT(LIST, ContextIndx, Buff);
          return 0;
          }

        case ID_MENU_DELETE:  //------- Context menu "Delete" selected -----------
          WinSendMsg(CONTROLHWND(LIST), LM_DELETEITEM, MPFROMSHORT(ContextIndx), MPVOID);
          return 0;

        case ID_MENU_INSERT: {//------- Context menu "Insert" selected ----------
          char Buff[MAX_LEN];
          /* Run edit menu, insert into list if user selects OK button */
          Buff[0] = '\0';
          if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)DLG_EDIT_Proc, NULLHANDLE, DLG_EDIT, Buff)
              == DID_OK) {
            if (ContextIndx == LIT_NONE)  // Insert at end of list
              ContextIndx = LIT_END;
            else
              ContextIndx++;              // Insert AFTER selected item
            INSERTITEMAT(LIST, ContextIndx, Buff);
          }
          return 0;
          }

        case DID_OK: /*----------~OK (PUSHBUTTON)----------*/ 
          // Let default dialog proc terminate us
          break;                                              
      }                                                       
      break;                                                  
                                                              
    case WM_CONTROL:                                          
      switch SHORT1FROMMP(mp1) {                              
        case LIST: /*----------LIST (LISTBOX)----------*/     
 
          /*******************************************************************/
          /* Notification messages from the listbox come here.  These are    */
          /* the usual PM listbox messages, plus some new ones for DMLB.     */
          /*******************************************************************/
 
          switch (SHORT2FROMMP(mp1)) {
            case LN_SELECT:           
            case LN_ENTER:            
              /* User dbl-clicked an entry or pressed ENTER.  For this sample       */
              /* we do nothing.                                                     */
              return 0;

            case LN_DMLB_QRYDROP:
              /* A listbox item is about to be dropped on this listbox.  We must    */
              /* return a Ok-to-drop  indicator, and tell what to do with the       */
              /* original item (copy or move).  Since we have just one listbox in   */
              /* this sample, MOVE is the only thing that makes sense.              */
              return MRFROM2SHORT(TRUE, DROPMODE_MOVE);

            case LN_DMLB_CONTEXT: {
              /* The user has requested a context menu.  Short 1 of mp2 is the      */
              /* index of the listbox item under the pointer.                       */
              POINTL Point;
              ContextIndx = SHORT1FROMMP(mp2);
              if (ContextIndx == LIT_NONE) {
                // Disable Edit & Delete if pointer was not over a listbox item
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE),   MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
              } else {
                // Otherwise, enable Edit & Delete
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_EDIT,FALSE),   MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED));
                WinSendMsg(ContextHwnd, MM_SETITEMATTR, MPFROM2SHORT(ID_MENU_DELETE,FALSE), MPFROM2SHORT(MIA_DISABLED, ~MIA_DISABLED));
              }
              // It is not technically necessary to select the item on which the context
              // menu was selected, but it provides good visual feedback to the user to
              // show which item the context menu applies to.
              SETSELECTION(LIST, ContextIndx);

              // Popup the context menu at the pointer position.  The menu will
              // send us WM_COMMAND messages if a menu item is selected.
              WinQueryMsgPos((HAB)0, &Point);
              WinPopupMenu(HWND_DESKTOP, hwnd, ContextHwnd, Point.x, Point.y, 0, PU_HCONSTRAIN| PU_VCONSTRAIN
                                                            | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_MOUSEBUTTON3 
                                                            | PU_KEYBOARD );
              return (MRESULT)TRUE;
              }
          }                           
          break;                      
      }                               
      break; /* End of WM_CONTROL */          
                                              
  } /* End of (msg) switch */                 
                                              
  return WinDefDlgProc(hwnd, msg, mp1, mp2);  
                                              
} /* End dialog procedure */                  
Example #9
0
MRESULT EXPENTRY stlrTitleBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   PSTLRFRAME p;
   /* -------------------------------------------------------------------
    window creation :
    store the handle of the owner window, the initial titlebar size,
    convert the title substituting \r\n with 1 space, update the titlebar
    font
   ------------------------------------------------------------------- */
   if (msg == WM_CREATE) {
      // if this is a global exception window, if the window ID is not
      // FID_TITLEBAR or if the owner window is not a frame, go to the
      // default system titlebar procedure
      if (!pd.ppib
          || (((PCREATESTRUCT)mp2)->id != FID_TITLEBAR)
          || !_isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner))
         goto defaultTitlebarProcedure;
      // get the frame data
      p = (PSTLRFRAME)WinQueryWindowPtr(((PCREATESTRUCT)mp2)->hwndOwner,
                                        g.cd.frame.cbData);
//      /*-*/ dbgPrintf5("*** pd.ppib:%08x, id: %04x, isOwnerFrame: %d, p: %08x\n",
//                       pd.ppib, ((PCREATESTRUCT)mp2)->id,
//                       _isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner), p);
      // if the frame window is a win32frame initialize the frame data now
      if (!p
          || ((p == FL_WIN32FRAME)
              && (NULL
                  == (p = _initWin32Frame(((PCREATESTRUCT)mp2)->hwndOwner)))))
         goto defaultTitlebarProcedure;
      // memorizza handle frame window
      WinSetWindowPtr(hwnd, g.cd.tbar.cbData, p);
      p->hTBar = hwnd;
      if (((PCREATESTRUCT)mp2)->pszText)
         p->cchTxt = psznconvcpy(p->achTxt, ((PCREATESTRUCT)mp2)->pszText, 260);
      p->wrclTitle.x = ((PCREATESTRUCT)mp2)->x;
      p->wrclTitle.y = ((PCREATESTRUCT)mp2)->y;
      p->wrclTitle.cx = ((PCREATESTRUCT)mp2)->cx;
      p->wrclTitle.cy = ((PCREATESTRUCT)mp2)->cy;
      // cambia font secondo preferenze
      if (o.tb.on && !(o.gen.disabled || pd.we.tbar))
         _setPPFont(hwnd, o.tb.achFont);

   /* -------------------------------------------------------------------
    hiliting/unhiliting of the titlebar :
    store the handle of the owner window, the initial titlebar size,
    convert the title substituting \r\n with 1 space, update the titlebar
    font
   ------------------------------------------------------------------- */
   } else if (msg == TBM_SETHILITE) {
      if (_getFrameData(hwnd, p)) {
         p->is.tbhilited = (BOOL)mp1;
         if (!o.gen.disabled && o.tb.on && !pd.we.tbar) {
            if (o.tb.ovrPP
                || (p->is.tbhilited && !p->is.tbactpp)
                || !(p->is.tbhilited || p->is.tbictpp)) {
               if (WinIsWindowShowing(hwnd)) {
                  p->hps = WinGetPS(hwnd);
                  DrawTitlebar(p);
                  WinReleasePS(p->hps);
               } /* endif */
               return (MRESULT)TRUE;
            // Š solo apparentemente ridondante, in realt… Š necessario quando
            // non Å  ovrPP ed Å  presente solo PP att. o inatt.
            } else if (!(p->is.tbactpp && p->is.tbictpp)) {
               repaintWindow(hwnd);
            } /* endif */
         } /* endif */
      } /* endif */

   /* -------------------------------------------------------------------
    titlebar font/color changed
    - if the font changed repaint the window
    - if any color changed reset the presparm presence flag
   ------------------------------------------------------------------- */
   } else if (msg == WM_PRESPARAMCHANGED) {
      if (!pd.we.tbar && _getFrameData(hwnd, p)) {
         ULONG ul;
         switch ((LONG)mp1) {
            case PP_FONTNAMESIZE:
               p->cyfont = 0;
               if (o.gen.disabled) break;
               if (WinIsWindowShowing(hwnd)) repaintWindow(hwnd);
               return (MRESULT)FALSE;
            case PP_ACTIVETEXTBGNDCOLOR:
            case PP_ACTIVETEXTBGNDCOLORINDEX:
            case PP_ACTIVECOLOR:
            case PP_ACTIVECOLORINDEX:
               p->is.tbactpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0;
               break;
            case PP_INACTIVETEXTBGNDCOLOR:
            case PP_INACTIVETEXTBGNDCOLORINDEX:
            case PP_INACTIVECOLOR:
            case PP_INACTIVECOLORINDEX:
               p->is.tbictpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0;
               break;
         } /* endswitch */
      } /* endif */

   /* -------------------------------------------------------------------
    the titlebar text changed. If this is a Win-OS/2 window set the
    window words to 0 so that the enhancements are skipped, otherwise
    store the new text.
   ------------------------------------------------------------------- */
   } else if (msg == WM_SETWINDOWPARAMS) {
      if (!pd.we.tbar && _getFrameData(hwnd, p)) {
         // unsubclass winOS2 windows titlebars
         if (p->is.winos2) {
            _resetDefaultProc(hwnd);
//            WinSetWindowULong(hwnd, g.cd.tbar.cbData, 0);
         } else {
            if ((PWNDPARAMS)mp1 &&
                (((PWNDPARAMS)mp1)->fsStatus & WPM_TEXT) &&
                ((PWNDPARAMS)mp1)->pszText) {
               p->cchTxt = psznconvcpy(p->achTxt, ((PWNDPARAMS)mp1)->pszText, 260);
               p->cyfont = 0;
            } /* endif */
         } /* endif */
      } /* endif */

   /* -------------------------------------------------------------------
    titlebar size/position changed : store new size and position
   ------------------------------------------------------------------- */
   } else if (msg == WM_WINDOWPOSCHANGED) {
      if ((((PSWP)mp1)->fl & (SWP_SIZE | SWP_MOVE))
          && _getFrameData(hwnd, p)) {
         p->wrclTitle.x = ((PSWP)mp1)->x;
         p->wrclTitle.y = ((PSWP)mp1)->y;
         p->wrclTitle.cx = ((PSWP)mp1)->cx;
         p->wrclTitle.cy = ((PSWP)mp1)->cy;
      } /* endif */

// **************************************************************************
// these messages are processed only if Styler/2 is not disabled:

   } else if (!o.gen.disabled) {

   /* -------------------------------------------------------------------
    check if this is the roll-the-window mouse event :
   ------------------------------------------------------------------- */
      if ((msg == o.roll.moumsg) && (SHORT2FROMMP(mp2) == o.roll.moukbd)) {
         if (!pd.we.wroll
             && o.roll.mou
             && _getFrameData(hwnd, p)
             && !p->is.win32
             && (o.roll.on || p->is.RLon)) {
            toggleRollCmd(p->hwnd, p);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    check if this is the hide-titlebar mouse event :
   ------------------------------------------------------------------- */
      } else if ((msg == o.tbh.moumsg) && (SHORT2FROMMP(mp2) == o.tbh.moukbd)) {
         if (!pd.we.tbarhide
             && o.tbh.mou
             && _getFrameData(hwnd, p)
             && !p->is.win32
      // opzione titlehide attiva e non dialogo o disattivazione titlehide
             && ((o.tbh.on && !(p->is.dialog && o.tbh.noDlg)) || p->is.titleHide)) {
            toggleTitleBarHidingCmd(p->hwnd, p);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    check if this is the change-Zorder mouse event :
   ------------------------------------------------------------------- */
      } else if ((msg == o.sizpos.ZordMoumsg)
                 && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd)) {
         if (!pd.we.sizemove
             && o.sizpos.Zmove
             && _getFrameData(hwnd, p)) {
            _stlrMsgPost(p->hwnd, STLR_ZORDACTIV, SW2_SFMOVETOBOTTOM);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    check if this is the snap-to-screen-edge mouse event :
   ------------------------------------------------------------------- */
      } else if ((msg == o.sizpos.snapMoumsg)
                 && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd)) {
         if (!pd.we.sizemove
             && o.sizpos.snap
             && _getFrameData(hwnd, p)) {
            // get the rectangle of the window and of its parent
            RECTL r, rParent;
            WinQueryWindowRect(p->hwnd, &r);
            WinQueryWindowRect(_winParent(p->hwnd), &rParent);
            // click on the left side of the titlebar
            if (MOUSEX(mp1) < (p->wrclTitle.cx / 3)) {
               r.xLeft = -p->ptBrd.x;
            // click on the right side of the titlebar
            } else if (MOUSEX(mp1) > (p->wrclTitle.cx * 2 / 3)) {
               r.xLeft = rParent.xRight - r.xRight + p->ptBrd.x;
            // click on the (horizontal) middle of the titlebar
            } else {
               r.xLeft = (rParent.xRight - r.xRight) / 2;
            } /* endif */
            // click on the bottom of the titlebar
            if (MOUSEY(mp1) < (g.sys.cyTbar / 3)) {
               r.yBottom = -p->ptBrd.y;
            // click on the top of the titlebar
            } else if (MOUSEY(mp1) > (g.sys.cyTbar * 2 / 3)) {
               r.yBottom = rParent.yTop - r.yTop + p->ptBrd.y;
            // click on the (vertical) middle of the titlebar
            } else {
               r.yBottom = (rParent.yTop - r.yTop) / 2;
            } /* endif */
            WinSetWindowPos(p->hwnd, 0, r.xLeft, r.yBottom, 0, 0,
                            SWP_MOVE | SWP_NOADJUST);
         } /* endif */

   /* -------------------------------------------------------------------
    enhanced window painting
   ------------------------------------------------------------------- */
      } else if (msg == WM_PAINT) {
         if (!pd.we.tbar
             && o.tb.on
             && _getFrameData(hwnd, p)
             && (o.tb.ovrPP || (p->is.tbhilited && !p->is.tbactpp)
                 || !(p->is.tbhilited || p->is.tbictpp))) {
            p->hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
            DrawTitlebar(p);
            WinEndPaint(p->hps);
            return (MRESULT)FALSE;
         } /* endif */

   /* -------------------------------------------------------------------
    override the default window tracking :
   ------------------------------------------------------------------- */
      } else if ((msg == WM_BUTTON1DOWN) || (msg == WM_BUTTON2DOWN)) {
         if (_getFrameData(hwnd, p)) {
            // override window motion by titlebar drag :
            // store the current mouse position (mp1)
            // the window motion will start only when the mouse will move
            g.tbdrag.mpPos = mp1;
            // if the window is not already moving store which mouse button
            // has to be released to stop the titlebar drag
            if (!g.tbdrag.hwnd) g.tbdrag.msg = ++msg;
            // store the handle of the titlebar (mouse motion events are not
            // processed when this is NULLHANDLE)
            g.tbdrag.hwnd = hwnd;
            // cattura i msg successivi del mouse
            WinSetCapture(HWND_DESKTOP, hwnd);
            return (MRESULT)TRUE;
         } /* endif */

   /* -------------------------------------------------------------------
    terminate window motion through titlebar drag events :
   ------------------------------------------------------------------- */
      } else if ((msg == WM_BUTTON1UP) || (msg == WM_BUTTON2UP)) {
         if ((g.tbdrag.hwnd == hwnd)
              && (g.tbdrag.msg == msg)
              && _getFrameData(hwnd, p)) {
            HWND hwndParent;
            WinSetCapture(HWND_DESKTOP, NULLHANDLE);
            g.tbdrag.msg = 0;
            g.tbdrag.hwnd = NULLHANDLE;
            // if the Ctrl key is not pressed and the window is not yet active
            // end the window is a size-move feature exception or the event
            // is not related to the Z-order motion feature or the snap-to-
            // parent-edge feature activate the window bringing it to the top
            if (!(SHORT2FROMMP(mp2) & KC_CTRL)
                && (g.hwnd.active != p->hwnd)
                && (pd.we.sizemove
                    || (!(o.sizpos.Zmove
                          && (msg == (o.sizpos.ZordMoumsg - 0x3a1))
                          && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd))
                        && (!(o.sizpos.snap
                          && (msg == (o.sizpos.snapMoumsg - 0x3a1))
                          && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd))))))
               WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0,
                               SWP_ACTIVATE | SWP_ZORDER);
         } /* endif */

   /* -------------------------------------------------------------------
    open the system menu on the titlebar :
   ------------------------------------------------------------------- */
      } else if (msg == WM_CONTEXTMENU) {
         if (!pd.we.tbar
             && o.tb.menu
             && _getFrameData(hwnd, p)) {
            // if this is the titlebar of a WPS folder simulate a context
            // menu event on the client window
            if (p->is.folder) {
               p->hClient = WinWindowFromID(p->hwnd, FID_CLIENT);
               WinPostMsg(p->hClient, WM_CONTEXTMENU,
                          (MPARAM)0x7fff7fff, MPVOID);
            // otherwise get the handle of the system menu and bring it to
            // the top via WinPopupMenu()
            } else if (p->hSMenu) {
               POINTL ptl;
               WinQueryPointerPos(g.hwnd.desktop, &ptl);
               g.cd.menu.pfnwp(p->hSMenu, MM_QUERYITEM,
                               (MPARAM)SC_SYSMENU, MPFROMP(&p->mi));
               g.hwnd.sysMenu = p->mi.hwndSubMenu;
               WinPopupMenu(g.hwnd.desktop, p->hSMenu, g.hwnd.sysMenu,
                            ptl.x, ptl.y, 0, PU_HCONSTRAIN | PU_VCONSTRAIN |
                            PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1);
            } /* endif */
         } /* endif */
         return (MRESULT)TRUE;

   /* -------------------------------------------------------------------
    trap WM_MOUSEMOVE to implement various features :
    - do not move maximized windows
   ------------------------------------------------------------------- */
      } else if (msg == WM_MOUSEMOVE) {
         // if mouse button 1 or 2 were pressed and then the mouse position
         // changed
         if ((g.tbdrag.hwnd == hwnd)
             && (g.tbdrag.mpPos != mp1)
             && _getFrameData(hwnd, p)) {
            WinSetCapture(HWND_DESKTOP, NULLHANDLE);
            g.tbdrag.hwnd = NULLHANDLE;
            g.tbdrag.msg = 0;
            // if this is a maximized window and the don't-move-max-window
            // feature is set ignore the event
            if (o.maxwin.nomove
                && p->is.max
                && !(pd.we.maxwin || p->is.shield || p->is.ovrdnomovemax))
               return (MRESULT)TRUE;
            WinSendMsg(p->hwnd, WM_TRACKFRAME, (MPARAM)TF_MOVE, g.tbdrag.mpPos);
            // ???????????????????????????????
            // this is needed because the next WM_BUTTONxUP is captured by
            // the WM_TRACKFRAME processing
//            if (!(SHORT2FROMMP(mp2) & KC_CTRL))
//               WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
            return (MRESULT)TRUE;
         } else if (g.is.onctrl != OCTLTBAR) {
            g.is.onctrl = OCTLTBAR;
            // ??????????????? this should be redundant
//            _resetHideMouTimer();
         } /* endif */
      } /* endif */
   // -------------------------------------------------------------------
   } /* endif */

defaultTitlebarProcedure:
   return g.cd.tbar.pfnwp(hwnd, msg, mp1, mp2);
}
MRESULT EXPENTRY AirTrafficControlDlg (HWND hwnd, ULONG msg,
    MPARAM mp1, MPARAM mp2)
{
    PINST   pinst;

    pinst = (PINST) WinQueryWindowPtr(hwnd,QWL_USER);

    switch (msg)
    {
        case WM_INITDLG:
        {
            /*
             *  INITIALIZE APPLICATION
             */

            CNRINFO     ccinfo;         // Container info structure

            // Initialize instance data
            pinst = (PINST) calloc (1, sizeof *pinst);
            WinSetWindowPtr(hwnd,QWL_USER,pinst);
            pinst->hwndCnr = WinWindowFromID (hwnd, IDCNR_SAMPLE);
            pinst->hab     = WinQueryAnchorBlock (hwnd);
            pinst->hwndAircraftMenu =               // Load aircraft menu
                WinLoadMenu( HWND_OBJECT, 0, IDMENU_AIRCRAFT);
            pinst->hwndContainerMenu =              // Load container menu
                WinLoadMenu( HWND_OBJECT, 0, IDMENU_CONTAINER);
            pinst->CurrentView = IDMVIEW_RADAR;

            // Set container info to request owner background painting
            memset (&ccinfo, 0, sizeof ccinfo);
            ccinfo.cb = sizeof ccinfo;
            ccinfo.flWindowAttr = CA_OWNERPAINTBACKGROUND;
            WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo,
                MPFROMLONG(CMA_FLWINDOWATTR));

            // Subclass container window to provide background painting
            pfnwpCnr = WinSubclassWindow (pinst->hwndCnr,
                CnrSubclassWndProc);
            assert (pfnwpCnr);

            // Insert the columns into the container
            InsertContainerColumns (pinst);

            // Insert the initial records into the container
            InsertContainerRecords (pinst);

            // Start a timer to control aircraft
            WinStartTimer (pinst->hab, hwnd,
                IDTIMER_ADJUSTAIRCRAFT, AIRCRAFT_ADJUST_FREQUENCY);

            // The container is ready for viewing
            WinShowWindow (pinst->hwndCnr, TRUE);

            SetUpControllerHandoffValueSet (hwnd);

            return 0;
        }

        case WM_TIMER:

            /*
             *  DO TIME-RELATED AIRCRAFT HANDLING
             */

            if (SHORT1FROMMP (mp1) == IDTIMER_ADJUSTAIRCRAFT)
            {
                PAPPCNRREC      pacrTraverse;

                // Loop through all container records
                for (pacrTraverse = FIRST_CNR_ITEM (pinst->hwndCnr);
                    pacrTraverse;
                    pacrTraverse = NEXT_CNR_ITEM(pinst->hwndCnr,pacrTraverse))
                {
                    BOOL        fInvalid = FALSE;

                    if (pinst->CurrentView == IDMVIEW_RADAR)
                    {
                        /* Erase the record from previous location. */
                        WinSendMsg (pinst->hwndCnr, CM_ERASERECORD,
                            MPFROMP(pacrTraverse), NULL);
                    }

                    // Maneuver the aircraft
                    if (ManeuverAircraft (pacrTraverse))
                    {
                        // Update aircraft text if necessary
                        SetRecordText (pacrTraverse);
                        fInvalid = TRUE;
                    }

                    if (fInvalid || pinst->CurrentView == IDMVIEW_RADAR)
                        /* Paint the record in its new position */
                        WinSendMsg (pinst->hwndCnr, CM_INVALIDATERECORD,
                            MPFROMP(&pacrTraverse),
                            MPFROMSHORT(1));
                }
            }
            else
                if (SHORT1FROMMP (mp1) == IDTIMER_DISPLAYTIMEDMSG)
                {
                    WinStopTimer (pinst->hab, hwnd,
                        IDTIMER_DISPLAYTIMEDMSG);
                    WinSetDlgItemText (hwnd, IDST_STATUSMESSAGES, "");
                }


            return 0;


        case WM_CONTROL:
            if (SHORT1FROMMP (mp1) == IDCNR_SAMPLE)
                switch (SHORT2FROMMP (mp1))
                {
                    case CN_CONTEXTMENU:
                    {
                        /*
                         *  MENU HANDLING
                         */

                        POINTL  ptlMouse;
                        HWND    hwndMenu;

                        WinQueryMsgPos (pinst->hab, &ptlMouse);

                        // Save pointer to record mouse is over, if any
                        pinst->pacrSelected = (PAPPCNRREC) mp2;

                        hwndMenu = pinst->pacrSelected ?
                            pinst->hwndAircraftMenu :
                            pinst->hwndContainerMenu;

                        // Display menu
                        WinPopupMenu (HWND_DESKTOP, hwnd, hwndMenu,
                            ptlMouse.x, ptlMouse.y, 0,
                            PU_HCONSTRAIN | PU_VCONSTRAIN |
                            PU_KEYBOARD | PU_MOUSEBUTTON1 |
                            PU_MOUSEBUTTON2 |
                            PU_MOUSEBUTTON3);
                        return 0;
                    }

                    case CN_INITDRAG:
                        ProcessInitDrag (
                            WinWindowFromID (hwnd, SHORT1FROMMP (mp1)),
                            ((PCNRDRAGINIT) (PVOIDFROMMP(mp2))));
                        return 0;

                    case CN_SCROLL:
                        WinInvalidateRect (pinst->hwndCnr, 0, 0);
                        return 0;
                }
            else

/*
 *  HANDLE WM_CONTROL MESSAGES FROM VALUE SET CONTROL
 */

                if (SHORT1FROMMP (mp1) == IDVS_CONTROLLERS)
                    switch (SHORT2FROMMP (mp1))
                    {
                        case VN_SELECT:
                            DisplayTimedMsg (pinst->hab, hwnd,
                                "Drag an airplane to one "
                                "of the controller icons to hand off to "
                                "another controller.", 8);

                            return 0;

                        case VN_DROP:
                        {
                            PVSDRAGINFO pvsdinfo = (PVSDRAGINFO)
                               PVOIDFROMMP (mp2);
                            PDRAGINFO   pdinfo = pvsdinfo->pDragInfo;
                            PDRAGITEM   pditem;
                            INT         iItem;
                            INT         cHandedOffAircraft = 0;
                            CHAR        szHandedOffAircraft [100];

                            *szHandedOffAircraft = 0;

                            assert (DrgAccessDraginfo(pdinfo));

                            for (iItem = 0; iItem < pdinfo->cditem; ++iItem)
                            {
                                PAPPCNRREC      pacr;

                                pditem =  DrgQueryDragitemPtr (pdinfo, iItem);

                                pacr = (PAPPCNRREC) pditem->ulItemID;

                                if (pdinfo->usOperation == DO_MOVE)
                                {
                                    WinSendMsg (pdinfo->hwndSource,
                                        CM_REMOVERECORD,
                                        MPFROMP(&pacr),
                                        MPFROM2SHORT (1, CMA_INVALIDATE));

                                    if (cHandedOffAircraft++)
                                        strcat (szHandedOffAircraft, ", ");

                                    strcat (szHandedOffAircraft,
                                        pacr->pszCallsign);
                                }
                            }

                            if (cHandedOffAircraft)
                            {
                                CHAR    szMsg [200];

                                sprintf (szMsg,
                                    "Aircraft %s %s been handed off "
                                    "to %s Sector controller.",
                                    szHandedOffAircraft,
                                    cHandedOffAircraft > 1 ?
                                        "have" : "has",
                                    pvsdinfo->usColumn == 1 ?
                                        "West" : "East");

                                DisplayTimedMsg (pinst->hab, hwnd,
                                    szMsg, 8);
                            }

                            DrgFreeDraginfo (pdinfo);
                            WinAlarm (HWND_DESKTOP, WA_NOTE);
                            return 0;
                        }
                    }

            return 0;


        case WM_COMMAND:

            /*
             *  COMMAND HANDLING
             */

            switch (SHORT1FROMMP (mp1))
            {
                case IDMAIRCRAFT_CONTROLINSTRUCT:   // Issue instruction
                {
                    // Present "Control Aircraft" dialog
                    WinDlgBox (HWND_DESKTOP, hwnd,
                        ControlInstructionDlg, 0,
                        IDDLG_CONTROLAIRCRAFT, pinst);
                    return 0;
                }

                case IDMVIEW_RADAR:
                case IDMVIEW_NAME:
                case IDMVIEW_TREE:
                case IDMVIEW_DETAILS:
                case IDMVIEW_TEXT:
                {
                    static const ULONG  aViews [] =
                        { CV_ICON, CV_NAME, CV_TREE, CV_DETAIL, CV_TEXT };

                    CNRINFO ccinfo;
                    memset (&ccinfo, 0, sizeof ccinfo);
                    ccinfo.cb = sizeof ccinfo;
                    ccinfo.flWindowAttr = CA_DETAILSVIEWTITLES |
                        CA_TITLESEPARATOR | CA_TREELINE |
                        CA_OWNERPAINTBACKGROUND |
                        aViews [SHORT1FROMMP (mp1) - IDMVIEW_BASE];
                    WinSendMsg (pinst->hwndCnr, CM_SETCNRINFO, &ccinfo,
                        MPFROMLONG(CMA_FLWINDOWATTR));
                    pinst->CurrentView = SHORT1FROMMP (mp1);

                    WinInvalidateRect (pinst->hwndCnr, 0, 0);
                    return 0;
                }
            }

            return WinDefDlgProc (hwnd, msg, mp1, mp2);

        default:
            return WinDefDlgProc (hwnd, msg, mp1, mp2);
    }
}
Example #11
0
MRESULT EXPENTRY XLogoWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  HPS hps;
  HWND hwndMenu;                                        /* Menu resource */
  RECTL rcl;                    /* For finding current window dimensions */
  BOOL fSuccess;

  switch(msg)
  {
   case WM_ERASEBACKGROUND:
      /*
       * Return TRUE to request PM to paint the window background
       * in SYSCLR_WINDOW.
       */
      return (MRESULT)( TRUE );

    case WM_PAINT:
      /*
       * Window contents are drawn here in WM_PAINT processing.
       */
      {                                
      HPS    hps;                        /* Presentation Space handle    */
      RECTL  rc;                         /* Rectangle coordinates        */
      POINTL pt;                         /* String screen coordinates    */
      LONG   Lx, Ly;
                                    /* Starting points for paths A and B */
      POINTL PathAStart,
             PathBStart;

      POINTL PathAPolygon[5], PathBPolygon[5]; /* Paths A, B definitions */

                                         /* Create a presentation space  */
      hps = WinBeginPaint( hwnd, 0L, &rc );

      GpiSetColor(hps, CLR_BLACK);              /* colour of the text,   */
      GpiSetBackColor(hps, CLR_BACKGROUND);     /* its background and    */
      GpiSetBackMix(hps, BM_OVERPAINT);         /* how it mixes,         */
                                                /* and draw the string...*/

      WinFillRect( hps, &rc, SYSCLR_WINDOW);
      WinQueryWindowRect(hwnd, &rcl);

      Lx = rcl.xRight - rcl.xLeft;       /* Calculate window dimensions! */
      Ly = rcl.yTop   - rcl.yBottom;

            /* Find starting points of the two paths which make up the X */

      PathAStart.x = 0.061 * Lx;
      PathAStart.y = Ly;
      PathBStart.x = 0.864 * Lx;
      PathBStart.y = Ly;

                  /* Find the points for path A, the left half of the X */

      PathAPolygon[0].x = 0.404 * Lx;
      PathAPolygon[0].y = 0.483 * Ly;

      PathAPolygon[1].x = 0.06  * Lx;
      PathAPolygon[1].y = 0;

      PathAPolygon[2].x = 0.141 * Lx;
      PathAPolygon[2].y = 0;

      PathAPolygon[3].x = 0.556 * Lx;
      PathAPolygon[3].y = 0.589 * Ly;

      PathAPolygon[4].x = 0.288 * Lx;
      PathAPolygon[4].y = Ly;

                  /* Find the points for path B, the right half of the X */

      PathBPolygon[0].x = 0.455 * Lx;
      PathBPolygon[0].y = 0.417 * Ly;

      PathBPolygon[1].x = 0.722 * Lx;
      PathBPolygon[1].y = 0;

      PathBPolygon[2].x = 0.939 * Lx;
      PathBPolygon[2].y = 0;

      PathBPolygon[3].x = 0.6   * Lx;
      PathBPolygon[3].y = 0.517 * Ly;

      PathBPolygon[4].x = 0.939 * Lx;
      PathBPolygon[4].y = Ly;
                                               /* Define and draw path A */
      GpiBeginPath(hps, 1L);
      GpiMove(hps, &PathAStart);
      GpiPolyLine(hps, 5L, PathAPolygon);
      GpiCloseFigure(hps);
      GpiEndPath(hps);
      GpiFillPath(hps, 1L, FPATH_ALTERNATE);

                      /* Define and draw path B. Path number must be 1L */
      GpiBeginPath(hps, 1L);
      GpiMove(hps, &PathBStart);
      GpiPolyLine(hps, 5L, PathBPolygon);
      GpiCloseFigure(hps);
      GpiEndPath(hps);
      GpiFillPath(hps, 1L, FPATH_ALTERNATE);

      WinEndPaint(hps);
      break;
      }

   case WM_BUTTON2DOWN:
      {           /* Opens the popup menu at current mouse co-ordinates */

      hwndMenu = WinLoadMenu(hwnd, (HMODULE)NULL, ID_X);

      fSuccess = WinPopupMenu(hwnd,
                              hwndFrame,
                              hwndMenu,
                              MOUSEMSG(&msg)->x,              
                              MOUSEMSG(&msg)->y,
                              IDM_EXIT,
                              PU_POSITIONONITEM   |
                              PU_HCONSTRAIN       |
                              PU_VCONSTRAIN       |
                              PU_MOUSEBUTTON2DOWN |
                              PU_MOUSEBUTTON2);

      break;
      }

    case WM_CLOSE:
      /*
       * This is the place to put your termination routines
       */
      WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );
      break;

    case WM_COMMAND:
       switch (SHORT1FROMMP (mp1))
        {
        case IDM_ABOUT:          /* Show Product information dialog box */

          WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc,
                    0, IDD_ABOUT, 0);

          return ((MRESULT)0);
        case IDM_EXIT:
          WinSendMsg (hwnd, WM_CLOSE, 0L, 0L);
          return ((MRESULT)0);
        }
      break;

    default:
      /*
       * Everything else comes here.  This call MUST exist
       * in your window procedure.
       */

      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }

  return (MRESULT)FALSE;
} /* End of XLogoWndProc */
MRESULT EXPENTRY PC2_SpoolerWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    static CNRINFO      CnrInfo;            /* Container info structure */
    static PFIELDINFO   pFieldInfo;
    static PFIELDINFO   pFieldInfoFirst;

    switch(msg)
    {
    case WM_CREATE:
        /*                                                                                      *\
         * During spooler window creation, create a container class window as the child of the  *
         * client area. Initialize the columns for the details view, the spooler container      *
         * window will use. Then set the container info structure to details view with a        *
         * splitbar.
        \*                                                                                      */
    {
        ULONG           ulColumn;
        PFIELDINFO      pFieldInfoSplitbar; /* Pointer to a the FIELDINFO structure of the 4th column
                                       to set splitbar afterwards */
        FIELDINFOINSERT FieldInfoInsert;    /* Control structure for column insertation */

        /* Create the container to fill in spooler queue
           and job data in details view. */
        pHP->hwndSpoolerContainer=WinCreateWindow(hwnd, WC_CONTAINER, "",
                                  WS_VISIBLE | CCS_READONLY | CCS_MINIRECORDCORE | CCS_MULTIPLESEL,
                                  0, 0, 0, 0, hwnd, HWND_TOP, ID_PC2SPOOLERCONTAINER, NULL, NULL);
        /* Set presentation parameters saved */
        WinSetPresParam(pHP->hwndSpoolerContainer, PP_FONTNAMESIZE,
                        sizeof(pHP->ucPC2SpoolerFont), pHP->ucPC2SpoolerFont);
        /* Subclass container window to get hold of presentation
           parameter changes */
        pfnContainerWindowProc=WinSubclassWindow(pHP->hwndSpoolerContainer, SubclassedContainerWindowProc);
        /* Create fieldinfos for the columns in details view */
        pFieldInfo=(PFIELDINFO)WinSendMsg(pHP->hwndSpoolerContainer, CM_ALLOCDETAILFIELDINFO,
                                          MPFROMSHORT(sizeof(ContainerFieldInfo)/sizeof(ContainerFieldInfo[0])), NULL);
        /* Fill the columns avaiable into container */
        pFieldInfoFirst=pFieldInfo;
        pFieldInfoSplitbar=NULL;
        for(ulColumn=0; ulColumn<(sizeof(ContainerFieldInfo)/sizeof(ContainerFieldInfo[0])); ulColumn++)
        {
            /* Save 4th column to set splitbar afterwards */
            if(ulColumn==3)
                pFieldInfoSplitbar=pFieldInfo;
            pFieldInfo->flTitle=ContainerFieldInfo[ulColumn].flTitle;
            pFieldInfo->pTitleData=strdup(ContainerFieldInfo[ulColumn].pTitleData);
            pFieldInfo->flData=ContainerFieldInfo[ulColumn].flData;
            pFieldInfo->offStruct=ContainerFieldInfo[ulColumn].offStruct;
            pFieldInfo=pFieldInfo->pNextFieldInfo;
        }
        /* Fill column insertation control */
        FieldInfoInsert.cb=sizeof(FieldInfoInsert);
        /* Insert from first column */
        FieldInfoInsert.pFieldInfoOrder=(PFIELDINFO)CMA_FIRST;
        /* Update container display now */
        FieldInfoInsert.fInvalidateFieldInfo=(ULONG)TRUE;
        /* Number of columns to insert */
        FieldInfoInsert.cFieldInfoInsert=sizeof(ContainerFieldInfo)/sizeof(ContainerFieldInfo[0]);
        /* Insert column field info into container */
        WinSendMsg(pHP->hwndSpoolerContainer, CM_INSERTDETAILFIELDINFO,
                   MPFROMP(pFieldInfoFirst), MPFROMP(&FieldInfoInsert));
        /* Select details view */
        CnrInfo.flWindowAttr=CV_DETAIL | CA_DETAILSVIEWTITLES;
        /* Splitbar is set to last saved position */
        CnrInfo.xVertSplitbar=pHP->lSplitbarPosition;
        /* Splitbar occurs after the 4th column */
        CnrInfo.pFieldInfoLast=pFieldInfoSplitbar;
        /* Setup CNRINFO into container */
        WinSendMsg(pHP->hwndSpoolerContainer, CM_SETCNRINFO,
                   MPFROMP(&CnrInfo), MPFROMLONG(CMA_FLWINDOWATTR|CMA_XVERTSPLITBAR|CMA_PFIELDINFOLAST));
        RefreshSpooler();                   /* Fill spooler container from queue data */
        WinSetFocus(HWND_DESKTOP, pHP->hwndSpoolerContainer);
    }
    break;

    case WM_PAINT:
    {
        HPS     hpsClient;

        /* Get a cached presentation space */
        hpsClient=WinBeginPaint(hwnd, NULLHANDLE, NULL);
        WinEndPaint(hpsClient);
    }
    break;

    case WM_SIZE:
    case WM_MOVE:
        /*                                                                                      *\
         * During sizing (and moving) of the spooler window, ensure that the container always   *
         * fills the complete client area.                                                      *
        \*                                                                                      */
    {
        LONG    lXBorder=WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER);
        LONG    lYBorder=WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
        SWP     swpPC2Spooler;
        RECTL   rectlClient;
        SWP     swp;

        /* Get the frame area size */
        WinQueryWindowPos(pHP->hwndSpoolerFrame, &swpPC2Spooler);
        if((swpPC2Spooler.cx>pHP->DesktopSize.x) || (pHP->swpPC2Spooler.cx<0))
            pHP->swpPC2Spooler.cx=pHP->DesktopSize.x/2;
        else
            pHP->swpPC2Spooler.cx=swpPC2Spooler.cx;
        if((swpPC2Spooler.cy>pHP->DesktopSize.y) || (pHP->swpPC2Spooler.cy<0))
            pHP->swpPC2Spooler.cy=pHP->DesktopSize.y/5;
        else
            pHP->swpPC2Spooler.cy=swpPC2Spooler.cy;
        if((swpPC2Spooler.x<(0-lXBorder)) ||
                ((swpPC2Spooler.x+pHP->swpPC2Spooler.cx)>(pHP->DesktopSize.x+lXBorder)))
            pHP->swpPC2Spooler.x=0;
        else
            pHP->swpPC2Spooler.x=swpPC2Spooler.x;
        if((swpPC2Spooler.y<(0-lYBorder)) ||
                ((swpPC2Spooler.y+pHP->swpPC2Spooler.cy)>(pHP->DesktopSize.y+lYBorder)))
            pHP->swpPC2Spooler.y=0;
        else
            pHP->swpPC2Spooler.y=swpPC2Spooler.y;
        WinSetWindowPos(pHP->hwndSpoolerFrame, NULLHANDLE, pHP->swpPC2Spooler.x, pHP->swpPC2Spooler.y,
                        pHP->swpPC2Spooler.cx, pHP->swpPC2Spooler.cy, SWP_SIZE | SWP_MOVE);
        /* Size container to client area */
        WinQueryWindowRect(hwnd, &rectlClient);
        swp.fl=SWP_MOVE|SWP_SIZE|SWP_SHOW|SWP_ZORDER;
        swp.x=swp.y=0;
        swp.cx=rectlClient.xRight;
        swp.cy=rectlClient.yTop;
        swp.hwndInsertBehind=HWND_TOP;
        swp.hwnd=pHP->hwndSpoolerContainer;
        WinSetMultWindowPos(pHP->habPc2, &swp, 1);
    }
    break;

    /*                                                                                      *\
     * Syntax: WM_SHOWSPOOLER, NULL, NULL                                                   *
    \*                                                                                      */
    case WM_SHOWSPOOLER:
        /*                                                                                      *\
         * The spooler window is initially created invisible. When the user selects the         *
         * menuentry PC2 Spooler, this message is posted to set the spooler window visible.     *
        \*                                                                                      */
    {
        SWP     swp;

        swp.fl=SWP_SHOW|SWP_ACTIVATE|SWP_ZORDER;
        swp.x=pHP->swpPC2Spooler.x;
        swp.y=pHP->swpPC2Spooler.y;
        swp.cx=pHP->swpPC2Spooler.cx;
        swp.cy=pHP->swpPC2Spooler.cy;
        swp.hwndInsertBehind=HWND_TOP;
        swp.hwnd=pHP->hwndSpoolerFrame;
        WinSetMultWindowPos(pHP->habPc2, &swp, 1);
    }
    break;

    /*                                                                                      *\
     * Syntax: WM_REFRESHSPOOLER, NULL, NULL                                                *
    \*                                                                                      */
    case WM_REFRESHSPOOLER:
        /*                                                                                      *\
         * The spooler container regularily gets this message from a timer to update the        *
         * container with the current printer queue data, to have a real-time status of the     *
         * printer queue.                                                                       *
        \*                                                                                      */
        RefreshSpooler();
        break;

    case WM_CONTROL:
        /*                                                                                      *\
         * The child window of the client area sends its notification messages to its parent,   *
         * so the client window procedure can expext container notification messages.           *
        \*                                                                                      */
        switch(SHORT2FROMMP(mp1))
        {
        case CN_CONTEXTMENU:
        {
            SPOOLERRECORD   *pListSpoolerRecord;
            POINTL          ptlMouse;       /* Mouse position during creation of notification */
            USHORT          fsOptions=PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1 |
                                      PU_HCONSTRAIN | PU_VCONSTRAIN;

            /* Query selected records in container and return them,
               or return the one below the mouse pointer if none is
               selected. */
            pListSpoolerRecord=QuerySelectedRecords((SPOOLERRECORD *)mp2);
            if(pListSpoolerRecord==NULL)
                pHP->pSpoolerObject=NULL;
            else
                pHP->pSpoolerObject=pListSpoolerRecord->pSpoolerObject;
            /* Get the mouse position */
            WinQueryMsgPos(pHP->habPc2, &ptlMouse);
            WinPopupMenu(HWND_DESKTOP, hwnd, hwndSpoolerPopupMenu,
                         ptlMouse.x, ptlMouse.y, 0, fsOptions);
        }
        break;
        }
        break;

    case WM_HELP:                           /* Help pressed */
        WinSendMsg(pHP->hwndHelp, HM_DISPLAY_HELP,
                   MPFROMSHORT(ID_PC2SPOOLERWINDOW), HM_RESOURCEID);
        break;

    case WM_COMMAND:
        /*                                                                                      *\
         * Process the messages generated by the menuentries of the spooler container popup     *
         * menu.                                                                                *
        \*                                                                                      */
        switch(SHORT1FROMMP(mp1))
        {
        case ID_SPOOLERREFRESH:             /* User requested to refresh the spooler container window
                                           with the status of the actual spooler queue */
            RefreshSpooler();
            break;

        case ID_SPOOLERHOLDJOB:             /* The user selected to hold a job */
        case ID_SPOOLERRELEASEJOB:          /* The user selected to release a job */
        case ID_SPOOLERDELETEJOB:           /* The user selected to delete a job */
        case ID_SPOOLERHOLDQUEUE:           /* The user selected to hold a queue */
        case ID_SPOOLERRELEASEQUEUE:        /* The user selected to release a queue */
            /* Perform the action on linked list of selected records */
            NotifySelectedRecords((ULONG)SHORT1FROMMP(mp1));
            break;

        case ID_SPOOLERHELP:                /* The user requested some help */
            WinPostMsg(hwnd, WM_HELP, MPFROMLONG(ID_PC2SPOOLERWINDOW), MPFROM2SHORT(CMDSRC_MENU, TRUE));
            break;
        }
        break;

    case WM_DESTROY:
        /*                                                                                      *\
         * Clear container structures and free control structures used by PC/2.                 *
        \*                                                                                      */
    {
        SPOOLERRECORD   *pSpoolerRecord;

        /* Query the actual container info structure */
        WinSendMsg(pHP->hwndSpoolerContainer, CM_QUERYCNRINFO,
                   MPFROMP(&CnrInfo), MPFROMSHORT(sizeof(CnrInfo)));
        pHP->lSplitbarPosition=CnrInfo.xVertSplitbar;
        /* Prevent unnecessary container drawing */
        WinEnableWindowUpdate(pHP->hwndSpoolerContainer, FALSE);
        /* Get first container record to delete them sequentially */
        pSpoolerRecord=(SPOOLERRECORD *)WinSendMsg(pHP->hwndSpoolerContainer, CM_QUERYRECORD,
                       NULL, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
        while(pSpoolerRecord)
        {   /* Delete and free records */
            free(pSpoolerRecord->pszQueue);
            free(pSpoolerRecord->pszQueueStatus);
            free(pSpoolerRecord->pszQueueComment);
            free(pSpoolerRecord->pszQueueDriver);
            free(pSpoolerRecord->pszJob);
            free(pSpoolerRecord->pszJobNumber);
            free(pSpoolerRecord->pszJobStatus);
            free(pSpoolerRecord->pszJobComment);
            free(pSpoolerRecord->pSpoolerObject);
            /* Delete record in container. Warning! as this function
               expects an array, but we only delete one record, we
               have to get the address of the pointer to the record. */
            WinSendMsg(pHP->hwndSpoolerContainer, CM_REMOVERECORD,
                       MPFROMP(&pSpoolerRecord), MPFROM2SHORT(1, CMA_FREE|CMA_INVALIDATE));
            /* Get next container record to delete them sequentially */
            pSpoolerRecord=(SPOOLERRECORD *)WinSendMsg(pHP->hwndSpoolerContainer, CM_QUERYRECORD,
                           NULL, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
        }
    }
    break;

    default:                                /* Default window procedure must be called */
        return((MRESULT)WinDefWindowProc(hwnd, msg, mp1, mp2));
    }
    return((MRESULT)FALSE);                 /* We have handled the message */
}
Example #13
0
MRESULT EXPENTRY fnwpReadColumnClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2)
  {
  static HDC hdcPs;
  RECTL   rclRect;
  POINTL ptl;
  LONG lSaveEdge;
  SWP swp;
  HWND hwndMenu;
  static USHORT usMenuStyle;
  static CLRDLG stColor;
  static USHORT usLastPopupItem;

  switch(msg)
    {
    case WM_CHAR:
      if (bSendNextKeystroke)
        if (ProcessKeystroke(&stCFG,mp1,mp2))
          return((MRESULT)TRUE);
      return( WinDefWindowProc(hwnd,msg,mp1,mp2));
    case WM_CREATE:
      hdcPs = WinOpenWindowDC(hwnd);
      usLastPopupItem = IDMPU_SYNC;
      stRead.lBackgrndColor = stCFG.lReadColBackgrndColor;
      stRead.bActive = FALSE;
      stRead.lScrollIndex = 0;
      stRead.hwndScroll = (HWND)NULL;
      stRead.wDirection = CS_READ;
      stColor.cbSize = sizeof(CLRDLG);
      usMenuStyle = (PU_POSITIONONITEM | PU_MOUSEBUTTON2 | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1);
      WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L);
      break;
    case WM_ACTIVATE:
      if(SHORT1FROMMP(mp1))
        {
        if (!bFrameActivated)
          {
          WinSetFocus(HWND_DESKTOP,hwndFrame);
          WinSendMsg(WinQueryHelpInstance(hwndClient),HM_SET_ACTIVE_WINDOW,0L,0L);
          bFrameActivated = TRUE;
          }
        }
      else
        bFrameActivated = FALSE;
      break;
    case WM_VSCROLL:
      switch(HIUSHORT(mp2))
        {
        case SB_LINEDOWN:
          ColScroll(&stRead,1,FALSE);
          break;
        case SB_LINEUP:
          ColScroll(&stRead,-1,FALSE);
          break;
        case SB_PAGEDOWN:
          ColScroll(&stRead,stRead.lCharHeight,FALSE);
          break;
        case SB_PAGEUP:
          ColScroll(&stRead,-stRead.lCharHeight,FALSE);
          break;
        case SB_SLIDERPOSITION:
          ColScroll(&stRead,LOUSHORT(mp2),TRUE);
          break;
        }
      break;
    case WM_COMMAND:
      switch (SHORT1FROMMP(mp1))
        {
        case IDMPU_ASCII_FONT:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_FONT;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (stCFG.wColReadFont != wASCIIfont)
            {
            stCFG.wColReadFont = wASCIIfont;
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        case IDMPU_HEX_FONT:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_FONT;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (stCFG.wColReadFont != wHEXfont)
            {
            stCFG.wColReadFont = wHEXfont;
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        case IDMPU_SYNC:
          usLastPopupItem = IDMPU_SYNC;
          if (bStopDisplayThread)
            stRead.lScrollIndex = stWrite.lScrollIndex;
          else
            stRead.lScrollIndex = 0;
          stRead.lScrollRow = GetColScrollRow(&stRead,0);
          WinSendMsg(stRead.hwndScroll,
                     SBM_SETPOS,
                     MPFROMSHORT(stRead.lScrollRow),
                     MPFROMSHORT(0));
          if (stRead.bSync)
            {
            stRow.lScrollIndex = stRead.lScrollIndex;
            stRow.lScrollRow = GetRowScrollRow(&stRow);
            }
          WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
          break;
         case IDMPU_COLORS:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_COLORS;
          else
            usLastPopupItem = IDMPU_SYNC;
          stColor.lForeground = stCFG.lReadColForegrndColor;
          stColor.lBackground = stCFG.lReadColBackgrndColor;
          sprintf(stColor.szCaption,"Lexical Receive Data Display Colors");
          if (WinDlgBox(HWND_DESKTOP,
                        hwnd,
                 (PFNWP)fnwpSetColorDlg,
                (USHORT)NULL,
                        CLR_DLG,
                MPFROMP(&stColor)))
            {
            stCFG.lReadColForegrndColor = stColor.lForeground;
            stCFG.lReadColBackgrndColor = stColor.lBackground;
            stRead.lBackgrndColor = stColor.lBackground;
            stRead.lForegrndColor = stColor.lForeground;
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        case IDMPU_LOCK_WIDTH:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_LOCK_WIDTH;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (stCFG.fLockWidth == LOCK_READ)
            stCFG.fLockWidth = LOCK_NONE;
          else
            {
            stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1);
            stCFG.fLockWidth = LOCK_READ;
            }
          break;
        case IDMPU_DISP_FILTERS:
          if (!stCFG.bStickyMenus)
            usLastPopupItem = IDMPU_DISP_FILTERS;
          else
            usLastPopupItem = IDMPU_SYNC;
          if (WinDlgBox(HWND_DESKTOP,
                        hwnd,
                 (PFNWP)fnwpDisplaySetupDlgProc,
                (USHORT)NULL,
                        DISP_FILTER_DLG,
                MPFROMP(&stRead)))
            {
            stCFG.bReadTestNewLine = stRead.bTestNewLine;
            stCFG.bSkipReadBlankLines = stRead.bSkipBlankLines;
            stCFG.byReadNewLineChar = stRead.byNewLineChar;
            stCFG.bFilterRead = stRead.bFilter;
            stCFG.fFilterReadMask = stRead.fFilterMask;
            stCFG.byReadMask = stRead.byDisplayMask;
            if (stRead.bSync)
              {
              if (!stCFG.bSyncToRead)
                {
                stWrite.bSync = FALSE;
                stCFG.bSyncToWrite = FALSE;
                stCFG.bSyncToRead = TRUE;
                if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE))
                  {
                  ClearColScrollBar(&stWrite);
                  SetupColScrolling(&stRead);
                  }
                }
              }
            else
              {
              if (stCFG.bSyncToRead)
                {
                stCFG.bSyncToRead = FALSE;
                if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE))
                  SetupColScrolling(&stWrite);
                }
              }
            WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
            }
          break;
        }
      break;
//    case WM_CHORD:
    case WM_BUTTON2DOWN:
      if(bFrameActivated)
        {
        hwndMenu = WinLoadMenu(stRead.hwnd,(HMODULE)NULL,IDMPU_COL_DISP_POPUP);
        if (mp1 != 0)
          {
          WinQueryPointerPos(HWND_DESKTOP,&ptl);
          if (!stCFG.bStickyMenus)
            usMenuStyle |= PU_MOUSEBUTTON2DOWN;
          else
            usMenuStyle &= ~PU_MOUSEBUTTON2DOWN;
          }
        else
          {
          usMenuStyle &= ~PU_MOUSEBUTTON2DOWN;
          WinQueryWindowPos(hwndFrame,&swp);
          ptl.x = (swp.x + (swp.cx - (swp.cx / 4)));
          ptl.y = (swp.y + (swp.cy / 2));
          }
        if (stCFG.wColReadFont == wASCIIfont)
          PopupMenuItemCheck(hwndMenu,IDMPU_ASCII_FONT,TRUE);
        else
          PopupMenuItemCheck(hwndMenu,IDMPU_HEX_FONT,TRUE);
        if (stCFG.fLockWidth == LOCK_READ)
          PopupMenuItemCheck(hwndMenu,IDMPU_LOCK_WIDTH,TRUE);
        if (!bStopDisplayThread)
          WinSendMsg(hwndMenu,MM_SETITEMTEXT,(MPARAM)IDMPU_SYNC,"~Reset Display");
        WinPopupMenu(HWND_DESKTOP,stRead.hwndClient,hwndMenu,ptl.x,ptl.y,usLastPopupItem,usMenuStyle);
        }
      else
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
      break;
    case WM_BUTTON1DOWN:
      if(bFrameActivated)
        {
        WinCopyRect(habAnchorBlock,&rclRect,&stRead.rcl);
        lSaveEdge = rclRect.xLeft;
        if (TrackChildWindow(habAnchorBlock,hwndClient,&rclRect,TF_LEFT))
          {
          if (rclRect.xLeft != lSaveEdge)
            {
            WinSendMsg(stWrite.hwndClient,UM_TRACKSIB,0L,(MPARAM)rclRect.xLeft);
            WinSendMsg(stRead.hwndClient,UM_TRACKSIB,(MPARAM)rclRect.xLeft,0L);
            if (stCFG.fLockWidth == LOCK_WRITE)
              stCFG.lLockWidth = ((stWrite.lWidth / stCell.cx) + 1);
            else
              stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1);
            }
          }
        }
      else
        return WinDefWindowProc(hwnd,msg,mp1,mp2);
      break;
    case WM_DESTROY:
      GpiDestroyPS(hdcPs);
      break;
    case UM_SHOWNEW:
      stRead.lScrollIndex = 0;
      stRead.lScrollRow = 0;
      ClearColScrollBar(&stRead);
    case UM_SHOWAGAIN:
      stRead.bActive = TRUE;
      if ((stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) && !stCFG.bSyncToWrite)
        SetupColScrolling(&stRead);
      WinShowWindow(stRead.hwnd,TRUE);
      WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L);
      WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE);
      WinInvalidateRect(hwndStatus,(PRECTL)NULL,FALSE);
      break;
    case UM_HIDEWIN:
      ClearColScrollBar(&stRead);
      stRead.bActive = FALSE;
      WinShowWindow(hwnd,FALSE);
      WinSetWindowPos(stRead.hwnd,HWND_BOTTOM,0L,0L,0L,0L,(SWP_MOVE | SWP_SIZE | SWP_ZORDER));
      break;
    case WM_PAINT:
#ifdef this_junk
      if (!pstCFG->bDisplayingData && (stCFG.bSyncToRead || stCFG.bSyncToWrite))
        ColumnPaint(&stRead,WinPeekMsg(habAnchorBlock,&stQmsg,stWrite.hwndClient,WM_PAINT,WM_PAINT,PM_REMOVE));
      else
#endif
        ColumnPaint(&stRead);
      break;
    case UM_TRACKSIB:
      ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,TRUE);
      break;
    case UM_TRACKFRAME:
      ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,FALSE);
      break;
    case WM_ERASEBACKGROUND:
      return (MRESULT)(TRUE);
    case WM_CLOSE:
      WinPostMsg(hwnd,WM_QUIT,0L,0L);
    default:
      return WinDefWindowProc(hwnd,msg,mp1,mp2);
    }
  return(FALSE);
  }
Example #14
0
MRESULT EXPENTRY SwapProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {

  static HWND hwndMenu = (HWND)0;

  switch(msg) {
    case WM_CREATE:
      {
        MRESULT mr = PFNWPStatic(hwnd,msg,mp1,mp2);

        WinSendMsg(hwnd,
                   UM_SETUP,
                   MPVOID,
                   MPVOID);
        return mr;
      }

    case WM_MOUSEMOVE:

      break;

    case WM_PRESPARAMCHANGED:
      {
        char *rootname = "SwapMon";

        switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
          case CLOCK_FRAME:
            rootname = "Clock";
            break;
          case HARD_FRAME:
            rootname = "Hard";
            break;
          case CPU_FRAME:
            rootname = "CPU";
            break;
          case CLP_FRAME:
            rootname = "ClipMon";
            break;
          case MEM_FRAME:
            rootname = "Mem";
            break;
          case TSK_FRAME:
            rootname = "Task";
            break;
        }
        PresParamChanged(hwnd,
                         rootname,
                         mp1,
                         mp2);
        PostMsg(hwnd,
                UM_TIMER,
                MPVOID,
                MPVOID);
        PostMsg(hwnd,
                UM_REFRESH,
                MPVOID,
                MPFROMSHORT(TRUE));
      }
      break;

    case WM_APPTERMINATENOTIFY:
      if(WinQueryWindowUShort(hwnd,QWS_ID) == CPU_FRAME) {
        if(!StartCPUThreads())
          WinDestroyWindow(hwnd);
      }
      break;

    case WM_BUTTON1MOTIONSTART:
      {
        POINTL ptl;

        ptl.x = SHORT1FROMMP(mp1);
        ptl.y = SHORT2FROMMP(mp1);
        WinMapWindowPoints(hwnd,
                           HWND_DESKTOP,
                           &ptl,
                           1L);
        PostMsg(hwndConfig,
                UM_SHOWME,
                MPFROM2SHORT((USHORT)ptl.x,(USHORT)ptl.y),
                mp2);
      }
      return MRFROMSHORT(TRUE);

    case WM_BUTTON2MOTIONSTART:
      {
        TRACKINFO TrackInfo;
        SWP       Position;

        memset(&TrackInfo,0,sizeof(TrackInfo));
        TrackInfo.cxBorder   = 1 ;
        TrackInfo.cyBorder   = 1 ;
        TrackInfo.cxGrid     = 1 ;
        TrackInfo.cyGrid     = 1 ;
        TrackInfo.cxKeyboard = 8 ;
        TrackInfo.cyKeyboard = 8 ;
        WinQueryWindowPos(hwnd,&Position);
        TrackInfo.rclTrack.xLeft   = Position.x ;
        TrackInfo.rclTrack.xRight  = Position.x + Position.cx ;
        TrackInfo.rclTrack.yBottom = Position.y ;
        TrackInfo.rclTrack.yTop    = Position.y + Position.cy ;
        WinQueryWindowPos(HWND_DESKTOP,&Position);
        TrackInfo.rclBoundary.xLeft   = Position.x ;
        TrackInfo.rclBoundary.xRight  = Position.x + Position.cx ;
        TrackInfo.rclBoundary.yBottom = Position.y ;
        TrackInfo.rclBoundary.yTop    = Position.y + Position.cy ;
        TrackInfo.ptlMinTrackSize.x = 0 ;
        TrackInfo.ptlMinTrackSize.y = 0 ;
        TrackInfo.ptlMaxTrackSize.x = Position.cx ;
        TrackInfo.ptlMaxTrackSize.y = Position.cy ;
        TrackInfo.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY ;
        if(WinTrackRect(HWND_DESKTOP,
                        (HPS)0,
                        &TrackInfo)) {
          WinSetWindowPos(hwnd,
                          HWND_TOP,
                          TrackInfo.rclTrack.xLeft,
                          TrackInfo.rclTrack.yBottom,
                          0,
                          0,
                          SWP_MOVE);
          switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
            case SWAP_FRAME:
              WinQueryWindowPos(hwnd,&swpSwap);
              SavePrf("SwapSwp",
                      &swpSwap,
                      sizeof(SWP));
              break;
            case CLOCK_FRAME:
              WinQueryWindowPos(hwnd,&swpClock);
              SavePrf("ClockSwp",
                      &swpClock,
                      sizeof(SWP));
              break;
            case HARD_FRAME:
              WinQueryWindowPos(hwnd,&swpHard);
              SavePrf("HardSwp",
                      &swpHard,
                      sizeof(SWP));
              break;
            case CPU_FRAME:
              WinQueryWindowPos(hwnd,&swpCPU);
              SavePrf("CPUSwp",
                      &swpCPU,
                      sizeof(SWP));
              break;
            case CLP_FRAME:
              WinQueryWindowPos(hwnd,&swpClip);
              SavePrf("ClipSwp",
                      &swpClip,
                      sizeof(SWP));
              break;
            case MEM_FRAME:
              WinQueryWindowPos(hwnd,&swpMem);
              SavePrf("MemSwp",
                      &swpMem,
                      sizeof(SWP));
              break;
            case TSK_FRAME:
              WinQueryWindowPos(hwnd,&swpTask);
              SavePrf("TaskSwp",
                      &swpTask,
                      sizeof(SWP));
              break;
          }
        }
      }
      return MRFROMSHORT(TRUE);

    case WM_BUTTON1DOWN:
      WinSetWindowPos(hwnd,
                      HWND_TOP,
                      0,
                      0,
                      0,
                      0,
                      SWP_ZORDER | SWP_DEACTIVATE);
      return MRFROMSHORT(TRUE);

    case WM_BUTTON1DBLCLK:
    case WM_BUTTON1CLICK:
      if((!fNoMonClick &&
          msg == WM_BUTTON1CLICK) ||
         (fNoMonClick &&
          msg == WM_BUTTON1DBLCLK)) {
        switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
          case HARD_FRAME:
            {
              ULONG ulDriveNum,ulDriveMap,x;

              ulDriveMon = min(ulDriveMon,26);
              if(!DosQCurDisk(&ulDriveNum,
                              &ulDriveMap)) {
                for(x = ulDriveMon + 1;x < 26;x++) {
                  if(ulDriveMap & (1 << x)) {
                    ulDriveMon = x;
                    break;
                  }
                }
                if(x >= 26) {
                  for(x = 3;x < ulDriveMon - 1;x++) {
                    if(ulDriveMap & (1 << x)) {
                      ulDriveMon = x;
                      break;
                    }
                  }
                }
                SavePrf("MonDrive",
                        &ulDriveMon,
                        sizeof(ULONG));
              }
              PostMsg(hwnd,
                      UM_TIMER,
                      MPVOID,
                      MPVOID);
            }
            break;

          case CLP_FRAME:
          case MEM_FRAME:
          case TSK_FRAME:
          case SWAP_FRAME:
          case CLOCK_FRAME:
          case CPU_FRAME:
            {
              USHORT cmd = CPU_PULSE;

              switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
                case MEM_FRAME:
                  cmd = CLOCK_CMDLINE;
                  break;
                case TSK_FRAME:
                  cmd = CPU_KILLPROC;
                  break;
                case CLP_FRAME:
                  cmd = CLOCK_CLIPBOARD;
                  break;
                case SWAP_FRAME:
                  cmd = SWAP_LAUNCHPAD;
                  break;
                case CLOCK_FRAME:
                  cmd = CLOCK_SETTINGS;
                  if((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0)
                    cmd = CLOCK_CLOCK;
                  break;
              }
              PostMsg(hwnd,
                      WM_COMMAND,
                      MPFROM2SHORT(cmd,0),
                      MPVOID);
            }
            break;
        }
        return MRFROMSHORT(TRUE);
      }
      else
        PostMsg(hwnd,
                UM_TIMER,
                MPVOID,
                MPVOID);
      break;

    case WM_CONTEXTMENU:
      WinInvalidateRect(hwnd,
                        NULL,
                        FALSE);
      WinSendMsg(hwnd,
                 UM_TIMER,
                 MPVOID,
                 MPVOID);
      WinSetWindowPos(hwnd,
                      HWND_TOP,
                      0,
                      0,
                      0,
                      0,
                      SWP_ZORDER | SWP_DEACTIVATE);
      {
        USHORT id;

        id = WinQueryWindowUShort(hwnd,QWS_ID);
        hwndMenu = WinLoadMenu(HWND_DESKTOP,
                               0,
                               id);
        if(hwndMenu) {

          POINTL   ptl;
          SWP      swp;
          ULONG    ulDriveNum,ulDriveMap,x;
          MENUITEM mi;
          char     s[80];

          SetPresParams(hwndMenu,
                        -1,
                        -1,
                        -1,
                        helvtext);
          switch(id) {
            case CLP_FRAME:
              WinSendMsg(hwndMenu,
                         MM_SETITEMATTR,
                         MPFROM2SHORT(CLP_APPEND,FALSE),
                         MPFROM2SHORT(MIA_CHECKED,
                                      ((fClipAppend) ? MIA_CHECKED : 0)));
              break;

            case HARD_FRAME:
              if(!DosQCurDisk(&ulDriveNum,
                              &ulDriveMap)) {
                mi.iPosition = 0;
                mi.hwndSubMenu = (HWND)0;
                mi.hItem = 0L;
                mi.afStyle = MIS_TEXT | MIS_STATIC;
                mi.afAttribute = MIA_FRAMED;
                mi.id = -1;
                sprintf(s,
                        "Current drive is %c:",
                        (char)(ulDriveMon + '@'));
                WinSendMsg(hwndMenu,
                           MM_INSERTITEM,
                           MPFROMP(&mi),
                           MPFROMP(s));
                mi.iPosition = MIT_END;
                for(x = 2;x < 26;x++) {
                  if(ulDriveMap & (1 << x)) {
                    if(x != ulDriveMon - 1) {
                      mi.afStyle = MIS_TEXT;
                      mi.afAttribute = 0;
                      mi.id = HARD_C + (x - 2);
                      if(fShowFreeInMenus)
                        SetDriveText(x + 1,
                                     s);
                      else
                        sprintf(s,
                                "%c:",
                                (char)(x + 'A'));
                      WinSendMsg(hwndMenu,
                                 MM_INSERTITEM,
                                 MPFROMP(&mi),
                                 MPFROMP(s));
                    }
                  }
                }
              }
              break;

            case CLOCK_FRAME:
              WinEnableMenuItem(hwndMenu,
                                CLOCK_VIRTUAL,
                                fDesktops);
              WinEnableMenuItem(hwndMenu,
                                CLOCK_CLIPBOARD,
                                (ClipHwnd != (HWND)0));
              break;

            default:
              break;
          }
          WinQueryWindowPos(hwnd,
                            &swp);
          ptl.x = SHORT1FROMMP(mp1);
          ptl.y = SHORT2FROMMP(mp1);
          WinMapWindowPoints(hwnd,
                             HWND_DESKTOP,
                             &ptl,
                             1L);
          ptl.y = max(ptl.y,swp.y + swp.cy + 4);
          if(!WinPopupMenu(HWND_DESKTOP,
                           hwnd,
                           hwndMenu,
                           ptl.x - 4,
                           ptl.y - 4,
                           0,
                           PU_HCONSTRAIN | PU_VCONSTRAIN |
                           PU_KEYBOARD   | PU_MOUSEBUTTON1)) {
            WinDestroyWindow(hwndMenu);
            hwndMenu = (HWND)0;
          }
        }
      }
      return MRFROMSHORT(TRUE);

    case WM_MENUEND:
      WinSetFocus(HWND_DESKTOP,
                  HWND_DESKTOP);
      WinDestroyWindow((HWND)mp2);
      if(hwndMenu == (HWND)mp2)
        hwndMenu = (HWND)0;
      return 0;

    case UM_SETUP:
      {
        char *rootname = "SwapMon";

        switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
          case SWAP_FRAME:
            SwapHwnd = hwnd;
            swaptick = 0;
            break;
          case CLOCK_FRAME:
            ClockHwnd = hwnd;
            rootname = "Clock";
            break;
          case TSK_FRAME:
            TaskHwnd = hwnd;
            rootname = "Task";
            break;
          case MEM_FRAME:
            MemHwnd = hwnd;
            rootname = "Mem";
            break;
          case HARD_FRAME:
            HardHwnd = hwnd;
            rootname = "Hard";
            break;
          case CPU_FRAME:
            CPUHwnd = hwnd;
            rootname = "CPU";
            PostMsg(hwnd,
                    UM_REFRESH,
                    MPVOID,
                    MPFROMSHORT(TRUE));
            break;
          case CLP_FRAME:
            ClipMonHwnd = hwnd;
            rootname = "ClipMon";
            PostMsg(hwnd,
                    UM_REFRESH,
                    MPVOID,
                    MPFROMSHORT(TRUE));
            break;
        }
        if(!RestorePresParams(hwnd,rootname))
          SetPresParams(hwnd,
                        RGB_WHITE,
                        RGB_BLACK,
                        RGB_BLACK,
                        helvtext);
      }
      PostMsg(hwnd,
              UM_TIMER,
              MPVOID,
              MPVOID);
      return 0;

    case UM_REFRESH:
      switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
        case CLP_FRAME:
          {
            char  s[] = " Clip: [TtBbMmP] + ",*p;
            ULONG fmt[] = {CF_TEXT,CF_DSPTEXT,
                           CF_BITMAP,CF_DSPBITMAP,
                           CF_METAFILE,CF_DSPMETAFILE,
                           CF_PALETTE,0};
            ULONG x,ret;

            if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) {
              p = s + 8;
              for(x = 0;fmt[x];x++) {
                ret = WinQueryClipbrdData(WinQueryAnchorBlock(hwnd),
                                          fmt[x]);
                if(!ret)
                  *p = '-';
                p++;
              }
              p += 2;
              if(!fClipAppend)
                *p = 0;
              WinCloseClipbrd(WinQueryAnchorBlock(hwnd));
            }
            else
              strcpy(s + 7,
                     "Can't open. ");
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpClip,
                           s);
          }
          break;

        case CPU_FRAME:
          {
            char        s[32];
            ULONG       percent,lastaverage;
            static BOOL lastavgset = 0;

            *s = 0;
            if(mp2) {
              strcpy(s," CPU: -% ");
              if(fAverage)
                strcat(s,"Avg: -%) ");
            }
            else {
              percent = ((MaxCount - (ULONG)mp1) * 100) / MaxCount;
              lastaverage = AveCPU;
              AveCPU = (((AveCPU * NumAveCPU) + percent) /
                        ((ULONG)NumAveCPU + 1));
              NumAveCPU++;
              if(!NumAveCPU)
                NumAveCPU = 65535;
              if(percent != LastPercent ||
                 (AveCPU != lastaverage &&
                  fAverage) ||
                 NumAveCPU == 1 ||
                 lastavgset != fAverage) {
                lastavgset = fAverage;
                LastPercent = percent;
                sprintf(s,
                        " CPU: %lu%% ",
                        percent);
                if(fAverage)
                  sprintf(s + strlen(s),
                          "(Avg: %lu%%) ",
                          AveCPU);
              }
            }
            if(*s)
              SetMonitorSize(hwnd,
                             hwndMenu,
                             &swpCPU,
                             s);
          }
          break;
      }
      return 0;

    case WM_TIMER:
      if(fSwapFloat &&
         !hwndMenu)
        WinSetWindowPos(hwnd,
                        HWND_TOP,
                        0,
                        0,
                        0,
                        0,
                        SWP_ZORDER | SWP_SHOW);
      if(WinQueryWindowUShort(hwnd,QWS_ID) == CLP_FRAME) {
        if(!ClipHwnd)
          WinDestroyWindow(hwnd);
        else
          TakeClipboard();
      }
      return 0;

    case UM_TIMER:
      switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
        case CLP_FRAME:
          ClipMonHwnd = hwnd;
          WinSendMsg(hwnd,
                     WM_TIMER,
                     MPVOID,
                     MPVOID);
          break;

        case CPU_FRAME:
          CPUHwnd = hwnd;
          WinSendMsg(hwnd,
                     WM_TIMER,
                     MPVOID,
                     MPVOID);
          break;

        case HARD_FRAME:
          {
            char s[80];

            HardHwnd = hwnd;
            SetDriveText(ulDriveMon,
                         s);
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpHard,
                           s);
          }
          break;

        case SWAP_FRAME:
          {
            FILEFINDBUF3 ffb;
            ULONG        nm = 1,fl = SWP_SIZE | SWP_SHOW | SWP_MOVE,
                         sh,sl,nh;
            HDIR         hdir = HDIR_CREATE;
            FSALLOCATE   fsa;
            char         s[128],ss[8],sss[8],mb,smb;
            static ULONG lastcbFile = 0;
            static BOOL  warned = FALSE;
            static char  SwapperDat[CCHMAXPATH] = "";

            strcpy(s,
                   " Unable to locate SWAPPER.DAT. ");
            SwapHwnd = hwnd;
            if(!*SwapperDat)
              FindSwapperDat(SwapperDat);
            if(*SwapperDat) {
              DosError(FERR_DISABLEHARDERR);
              if(!DosFindFirst(SwapperDat,
                               &hdir,
                               FILE_NORMAL | FILE_HIDDEN |
                               FILE_SYSTEM | FILE_ARCHIVED | FILE_READONLY,
                               &ffb,
                               sizeof(ffb),
                               &nm,
                               FIL_STANDARD)) {
                DosFindClose(hdir);
                if(ffb.cbFile != lastcbFile && lastcbFile)
                  swaptick = 9;
                lastcbFile = ffb.cbFile;
                DosError(FERR_DISABLEHARDERR);
                if(!DosQueryFSInfo(toupper(*SwapperDat) - '@',
                                   FSIL_ALLOC,
                                   &fsa,
                                   sizeof(FSALLOCATE)))
                  nm = fsa.cUnitAvail * (fsa.cSectorUnit * fsa.cbSector);
                else
                  nm = 0;
                if(nm <= 32768 * 1024) {
                  swaptick = 10;
                  if(!warned) {
                    SetPresParams(hwnd,
                                  RGB_RED,
                                  -1,
                                  -1,
                                  NULL);
                    warned = TRUE;
                    DosBeep(250,15);
                  }
                }
                else if(warned) {
                  PostMsg(hwnd,
                          UM_SETUP,
                          MPVOID,
                          MPVOID);
                  warned = FALSE;
                }
                mb = MakeNumber(nm,
                                &nh,
                                &sl);
                *sss = 0;
                if(sl)
                  sprintf(sss,
                          ".%02lu",
                          sl);
                smb = MakeNumber(ffb.cbFile,
                                 &sh,
                                 &sl);
                *ss = 0;
                if(sl)
                  sprintf(ss,
                          ".%02lu",
                          sl);
                sprintf(s,
                        " Swap: %lu%s%cb ",
                        sh,
                        ss,
                        smb);
                if(fShowSwapFree)
                  sprintf(s + strlen(s),
                          "(%lu%s%cb free) ",
                          nh,
                          sss,
                          mb);
              }
            }
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpSwap,
                           s);
          }
          break;

        case TSK_FRAME:
          {
            PROCESSINFO  *ppi;
            BUFFHEADER   *pbh = NULL;
            MODINFO      *pmi;
            long          numprocs = -1,numthreads = -1;
            char          s[80];

            if(!DosAllocMem((PVOID)&pbh,
                            USHRT_MAX + 4096,
                            PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) {
              if(!DosQProcStatus(pbh,
                                 USHRT_MAX)) {
                numprocs = numthreads = 0;
                ppi = pbh->ppi;
                while(ppi->ulEndIndicator != PROCESS_END_INDICATOR ) {
                  pmi = pbh->pmi;
                  while(pmi &&
                        ppi->hModRef != pmi->hMod)
                    pmi = pmi->pNext;
                  if(pmi) {
                    numprocs++;
                    numthreads += ppi->usThreadCount;
                  }
                  ppi = (PPROCESSINFO)(ppi->ptiFirst + ppi->usThreadCount);
                }
              }
              DosFreeMem(pbh);
              sprintf(s,
                      " Procs: %ld  Thrds: %ld ",
                      numprocs,
                      numthreads);
              SetMonitorSize(hwnd,
                             hwndMenu,
                             &swpTask,
                             s);
            }
          }
          break;

        case MEM_FRAME:
          {
            ULONG sh,sl,nh,amem;
            char  s[128],ss[8],sss[8],mb,smb;

            strcpy(s,
                   "Can't check virtual memory.");
            MemHwnd = hwnd;
            if(!DosQuerySysInfo(QSV_TOTAVAILMEM,
                                QSV_TOTAVAILMEM,
                                &amem,
                                sizeof(amem))) {
              mb = MakeNumber(amem,
                              &nh,
                              &sl);
              *ss = 0;
              if(sl)
                sprintf(ss,
                        ".%02lu",
                        sl);
              sprintf(s,
                      " VMem: %lu%s%cb ",
                      nh,
                      ss,
                      mb);
            }
            if(fShowPMem) {
              if(!Dos16MemAvail(&amem)) {
                mb = MakeNumber(amem,
                                &nh,
                                &sl);
                *ss = 0;
                if(sl)
                  sprintf(ss,
                          ".%02lu",
                          sl);
                sprintf(s + strlen(s),
                        " PMem: %lu%s%cb ",
                        nh,
                        ss,
                        mb);
              }
            }
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpMem,
                           s);
          }
          break;

        case CLOCK_FRAME:
          {
            char      s[80];
            DATETIME  dt;

            ClockHwnd = hwnd;
            if(!DosGetDateTime(&dt)) {
              sprintf(s,
                      " %0*u:%02u%s ",
                      ((ampm) ? 0 : 2),
                      (dt.hours % ((ampm) ? 12 : 24)) +
                       ((ampm && !(dt.hours % 12)) ? 12 : 0),
                      dt.minutes,
                      ((ampm) ? (dt.hours > 11) ? "pm" : "am" : ""));
              if(showdate)
                sprintf(s + strlen(s),
                        "%02u/%02u ",
                        dt.month,
                        dt.day);
            }
            else
              strcpy(s,"Unknown time");
            SetMonitorSize(hwnd,
                           hwndMenu,
                           &swpClock,
                           s);
          }
          break;
      }
      return 0;

    case WM_COMMAND:
      {
        BOOL ctrl,shift;

        ctrl = ((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0);
        shift = ((WinGetKeyState(HWND_DESKTOP,VK_SHIFT) & 0x8000) != 0);

        switch(SHORT1FROMMP(mp1)) {
          case CLP_CLEAR:
            if(WinOpenClipbrd(WinQueryAnchorBlock(hwnd))) {
              WinEmptyClipbrd(WinQueryAnchorBlock(hwnd));
              WinCloseClipbrd(WinQueryAnchorBlock(hwnd));
              PostMsg(hwnd,
                      UM_REFRESH,
                      MPVOID,
                      MPVOID);
            }
            break;

          case CLP_APPEND:
            fClipAppend = (fClipAppend) ? FALSE : TRUE;
            SavePrf("ClipAppend",
                    &fClipAppend,
                    sizeof(BOOL));
            PostMsg(hwnd,
                    UM_REFRESH,
                    MPVOID,
                    MPVOID);
            if(ClipSetHwnd)
              PostMsg(ClipSetHwnd,
                      UM_REFRESH,
                      MPVOID,
                      MPVOID);
            break;

          case MSE_HELP:
            ViewHelp(hwnd,
                     "Monitors page");
            break;

          case CPU_PULSE:
            {
              PROGDETAILS pgd;

              WinSetWindowPos(hwnd,
                              HWND_TOP,
                              0,
                              0,
                              0,
                              0,
                              SWP_ACTIVATE | SWP_FOCUSACTIVATE);
              memset(&pgd,
                     0,
                     sizeof(pgd));
              pgd.Length = sizeof(pgd);
              pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER;
              pgd.swpInitial.hwndInsertBehind = HWND_TOP;
              pgd.progt.fbVisible = SHE_VISIBLE;
              pgd.progt.progc = PROG_DEFAULT;
              pgd.pszExecutable = "PULSE.EXE";
              if(WinStartApp(CPUHwnd,
                             &pgd,
                             NULL,
                             NULL,
                             0)) {
                if(CPUHwnd) {
                  closethreads = 1;
                  DosSleep(1);
                  PostMsg(CPUHwnd,
                          UM_REFRESH,
                          MPVOID,
                          MPFROMSHORT(TRUE));
                }
              }
            }
            break;

          case CPU_RESET:
            AveCPU = 0;
            NumAveCPU = 0;
            break;

          case CLOCK_VIRTUAL:
          case CLOCK_SWITCHLIST:
          case CLOCK_CMDLINE:
          case CLOCK_CLIPBOARD:
          case CLOCK_CALCULATOR:
          case HARD_FM2:
          case MSE_FRAME:
            {
              ULONG msg2 = UM_SHOWME;
              MPARAM mp12 = 0,mp22 = 0;
              HWND   hwndP = hwndConfig;

              switch(SHORT1FROMMP(mp1)) {
                case CLOCK_CMDLINE:
                  mp12 = MPFROMLONG(((WinGetKeyState(HWND_DESKTOP,VK_CTRL) & 0x8000) != 0));
                  msg2 = UM_CMDLINE;
                  break;
                case CLOCK_CLIPBOARD:
                  msg2 = UM_CLIPMGR;
                  hwndP = ObjectHwnd3;
                  break;
                case CLOCK_SWITCHLIST:
                  msg2 = UM_SWITCHLIST;
                  break;
                case CLOCK_VIRTUAL:
                  msg2 = UM_VIRTUAL;
                  break;
                case CLOCK_CALCULATOR:
                  msg2 = UM_CALC;
                  break;
                case HARD_FM2:
                  msg2 = UM_STARTWIN;
                  mp12 = MPFROM2SHORT(C_STARTFM2,0);
                  break;
              }
              PostMsg(hwndP,
                      msg2,
                      mp12,
                      mp22);
            }
            break;

          case CLOCK_SETTINGS:
          case CLOCK_CLOCK:
          case SWAP_LAUNCHPAD:
          case SWAP_WARPCENTER:
          case SWAP_CONNECTIONS:
          case SWAP_INFO:
          case SWAP_SETTINGS:
          case SWAP_SYSTEM:
          case SWAP_TEMPS:
          case SWAP_FM2:
          case HARD_OPEN:
          case CVR_COLORPALETTE:
          case CVR_HICOLORPALETTE:
          case CVR_FONTPALETTE:
          case CPU_KILLPROC:
          case CPU_HARDWARE:
            {
              char *p = "<WP_CLOCK>",*pp = defopen;
              char s[8];

              switch(SHORT1FROMMP(mp1)) {
                case HARD_OPEN:
                  sprintf(s,
                          "%c:\\",
                          (char)(ulDriveMon + '@'));
                  p = s;
                  break;
                case SWAP_FM2:
                  p = "<FM3_Folder>";
                  break;
                case SWAP_TEMPS:
                  p = "<WP_TEMPS>";
                  break;
                case SWAP_SYSTEM:
                  p = "<WP_OS2SYS>";
                  break;
                case SWAP_SETTINGS:
                  p = "<WP_CONFIG>";
                  break;
                case SWAP_INFO:
                  p = "<WP_INFO>";
                  break;
                case SWAP_CONNECTIONS:
                  p = "<WP_CONNECTIONSFOLDER>";
                  break;
                case SWAP_WARPCENTER:
                  p = "<WP_WARPCENTER>";
                  break;
                case SWAP_LAUNCHPAD:
                  p = "<WP_LAUNCHPAD>";
                  break;
                case CLOCK_SETTINGS:
                  pp = setopen;
                  break;
                case CVR_COLORPALETTE:
                  p = "<WP_LORESCLRPAL>";
                  break;
                case CVR_HICOLORPALETTE:
                  p = "<WP_HIRESCLRPAL>";
                  break;
                case CVR_FONTPALETTE:
                  p = "<WP_FNTPAL>";
                  break;
                case CPU_KILLPROC:
                  p = "<FM/2_KILLPROC>";
                  break;
                case CPU_HARDWARE:
                  p = "<WP_HWMGR>";
                  break;
              }
              OpenObject(p,
                         pp);
            }
            break;

          case HARD_VDIR:
            {
              PROGDETAILS pgd;
              char        s[36];

              sprintf(s,
                      "/C VDIR.CMD %c:\\",
                      (char)(ulDriveMon + '@'));
              memset(&pgd,
                     0,
                     sizeof(pgd));
              pgd.Length = sizeof(pgd);
              pgd.swpInitial.fl = SWP_MINIMIZE | SWP_ACTIVATE | SWP_ZORDER;
              pgd.swpInitial.hwndInsertBehind = HWND_TOP;
              pgd.progt.fbVisible = SHE_VISIBLE;
              pgd.progt.progc = PROG_DEFAULT;
              pgd.pszExecutable = "CMD.EXE";
              WinStartApp((HWND)0,
                          &pgd,
                          s,
                          NULL,
                          0);
            }
            break;

          case HARD_CHKDSK:
            {
              PROGDETAILS pgd;
              char        s[8];

              WinSetWindowPos(hwnd,
                              HWND_TOP,
                              0,
                              0,
                              0,
                              0,
                              SWP_ACTIVATE | SWP_FOCUSACTIVATE);
              sprintf(s,
                      "%c:",
                      (char)(ulDriveMon + '@'));
              memset(&pgd,
                     0,
                     sizeof(pgd));
              pgd.Length = sizeof(pgd);
              pgd.swpInitial.fl = SWP_ACTIVATE | SWP_ZORDER;
              pgd.swpInitial.hwndInsertBehind = HWND_TOP;
              pgd.progt.fbVisible = SHE_VISIBLE;
              pgd.progt.progc = PROG_DEFAULT;
              pgd.pszExecutable = "PMCHKDSK.EXE";
              WinStartApp((HWND)0,
                          &pgd,
                          s,
                          NULL,
                          0);
            }
            break;

          default:
            if(SHORT1FROMMP(mp1) >= HARD_C &&
               SHORT1FROMMP(mp1) <= HARD_C + 24) {
              ulDriveMon = (SHORT1FROMMP(mp1) - HARD_C) + 3;
              PostMsg(hwnd,
                      UM_TIMER,
                      MPVOID,
                      MPVOID);
              if(ctrl)
                PostMsg(hwnd,
                        WM_COMMAND,
                        MPFROM2SHORT(HARD_OPEN,0),
                        MPVOID);
              else if(shift)
                PostMsg(hwnd,
                        WM_COMMAND,
                        MPFROM2SHORT(HARD_VDIR,0),
                        MPVOID);
            }
            break;
        }
      }
      return 0;

    case WM_DESTROY:
      switch(WinQueryWindowUShort(hwnd,QWS_ID)) {
        case SWAP_FRAME:
          SwapHwnd = (HWND)0;
          break;
        case CLOCK_FRAME:
          ClockHwnd = (HWND)0;
          break;
        case HARD_FRAME:
          HardHwnd = (HWND)0;
          break;
        case CPU_FRAME:
          closethreads = 1;
          DosSleep(1);
          CPUHwnd = (HWND)0;
          break;
        case CLP_FRAME:
          ClipMonHwnd = (HWND)0;
          break;
        case MEM_FRAME:
          MemHwnd = (HWND)0;
          break;
        case TSK_FRAME:
          TaskHwnd = (HWND)0;
          break;
      }
      break;
  }
  return PFNWPStatic(hwnd,msg,mp1,mp2);
}