コード例 #1
0
ファイル: column.c プロジェクト: OS2World/APP-COMM-ComScope
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);
  }
コード例 #2
0
ファイル: ws_nhdefkey.c プロジェクト: barthouse/NetHackOld
int __stdcall CheckInput(
    HANDLE hConIn,
    INPUT_RECORD *ir,
    DWORD *count,
    boolean numpad,
    int mode,
    int *mod,
    coord *cc)
{
	int ch;
	boolean valid = 0, done = 0;

    while (!done) {

        ReadConsoleInput(hConIn,ir,1,count);

		if (mode == 0) {

            if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown)
            {
			    ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0);
			    done = valid;
		    }

            if (ir->EventType == MOUSE_EVENT)
            {
                if ((ir->Event.MouseEvent.dwEventFlags == 0 || ir->Event.MouseEvent.dwEventFlags == 2) &&
                    (ir->Event.MouseEvent.dwButtonState & (LEFTBUTTON | RIGHTBUTTON)))
                {
                    if (ir->Event.MouseEvent.dwButtonState & LEFTBUTTON)
                    {
                        return ' ';
                    }
                    else
                    {
                        return 27;
                    }
                }
            }

		} else {
		    if (count > 0) {
			if (ir->EventType == KEY_EVENT && ir->Event.KeyEvent.bKeyDown) {
			    ch = ProcessKeystroke(hConIn, ir, &valid, numpad, 0);
			    if (valid) return ch;
			} else if (ir->EventType == MOUSE_EVENT) {
                
                if ((ir->Event.MouseEvent.dwEventFlags == 0 || ir->Event.MouseEvent.dwEventFlags == 2) &&
		   	        (ir->Event.MouseEvent.dwButtonState & MOUSEMASK)) {
                    static const int kMapOffsetX = 2;
                    static const int kMapOffsetY = 1;
			  	    cc->x = ir->Event.MouseEvent.dwMousePosition.X + 1 - kMapOffsetX;
			  	    cc->y = ir->Event.MouseEvent.dwMousePosition.Y - kMapOffsetY;

				    if (ir->Event.MouseEvent.dwButtonState & LEFTBUTTON)
		  	       		*mod = CLICK_1;
				    else if (ir->Event.MouseEvent.dwButtonState & RIGHTBUTTON)
					*mod = CLICK_2;
#if 0	/* middle button */
				    else if (ir->Event.MouseEvent.dwButtonState & MIDBUTTON)
			      		*mod = CLICK_3;
#endif 
			           return 0;
			    }
	        	}
		    } else 
			done = 1;
		}
	}
    
    return mode ? 0 : ch;
}