/*-------------------------------------------------------------------------*/ void onMouseMove(HWND hWnd, WPARAM wParam, LPARAM lParam) { PNHCmdWindow data; POINT mpt; int newActiveCell; /* get mouse coordinates */ mpt.x = LOWORD(lParam); mpt.y = HIWORD(lParam); /* map mouse coordinates to the display cell */ data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA); newActiveCell = CellFromPoint(data, mpt); if( data->active_cell == -1 ) return; /* if mouse is within orginal display cell - select the cell otherwise clear the selection */ switch( nhcmdlayout_cell_direct(data->layout_current, data->active_cell)->type ) { case NH_CELL_REG: HighlightCell(hWnd, data->active_cell, (newActiveCell==data->active_cell) ); break; case NH_CELL_CTRL: HighlightCell(hWnd, data->active_cell, ((newActiveCell==data->active_cell)? !data->is_ctrl : data->is_ctrl) ); break; case NH_CELL_CAP: HighlightCell(hWnd, data->active_cell, ((newActiveCell==data->active_cell)? !data->is_caps : data->is_caps) ); break; } }
/*-------------------------------------------------------------------------*/ void onMouseDown(HWND hWnd, WPARAM wParam, LPARAM lParam) { PNHCmdWindow data; POINT mpt; /* get mouse coordinates */ mpt.x = LOWORD(lParam); mpt.y = HIWORD(lParam); /* map mouse coordinates to the display cell */ data = (PNHCmdWindow)GetWindowLong(hWnd, GWL_USERDATA); data->active_cell = CellFromPoint(data, mpt); if( data->active_cell==-1 ) return; /* set mouse focus to the current window */ SetCapture(hWnd); /* invert the selection */ HighlightCell(hWnd, data->active_cell, (data->cells[data->active_cell].state!=NH_CST_CHECKED) ); }
void RWinColorPalette::OnLButtonDown( UINT nFlags, CPoint pt ) { if (GetFocus() != this) SetFocus(); RIntPoint ptHit = CellFromPoint( pt ); if (ptHit.m_x >= 0 && ptHit.m_y >= 0) { CRect rect( -1, -1, kCellSize.m_dx + 1, kCellSize.m_dy + 1 ); rect.OffsetRect( m_ptSelected.m_x, m_ptSelected.m_y ); InvalidateRect( rect, FALSE ); RIntPoint ptTest( ptHit.m_x + 1, ptHit.m_y + 1 ); m_crSelected = ColorFromPoint( ptTest ); m_ptSelected = ptHit; GetParent()->SendMessage( UM_COLOR_CHANGED, GetDlgCtrlID(), (LPARAM) m_crSelected ) ; CStatic::OnLButtonDown( nFlags, pt ); } }
void RWinColorPalette::OnMouseMove( UINT, CPoint pt ) { if (!m_fFlyoversEnabled) return; CRect rcClient; GetClientRect( rcClient ); COLORREF crColor = (COLORREF) -1L; if (rcClient.PtInRect( pt )) { if (GetCapture() != this) SetCapture(); RIntPoint ptHit = CellFromPoint( pt ); if (ptHit.m_x >= 0 && ptHit.m_y >= 0) { RIntPoint pt( ptHit.m_x + 1, ptHit.m_y + 1 ); crColor = ColorFromPoint( pt ); m_ptHilited = ptHit; } } else { ReleaseCapture(); } if (crColor != m_crHilited) { m_crHilited = crColor; if (m_rcColorChip.Width() && m_rcColorChip.Height()) { CRect rcInvalid = m_rcColorChip; InvalidateRect( rcInvalid, FALSE ); } } }