void CHexEditor::OnLButtonDown(UINT nFlags, CPoint point) { SetFocus(); if(!m_pData) return; if(nFlags & MK_SHIFT) { m_selStart = m_currentAddress; } CPoint pt = CalcPos(point.x, point.y); if(pt.x > -1) { m_editPos = pt; pt.x *= m_nullWidth; pt.y *= m_lineHeight; if(pt.x == 0 && m_bShowAddress) CreateAddressCaret(); else CreateEditCaret(); SetCaretPos(pt); if(nFlags & MK_SHIFT) { m_selEnd = m_currentAddress; if(m_currentMode == EDIT_HIGH || m_currentMode == EDIT_LOW) m_selEnd++; RedrawWindow(); } } if(!(nFlags & MK_SHIFT)) { #ifdef _VS6_USED if(DragDetect(this->m_hWnd, point)) #else if(DragDetect(point)) #endif { m_selStart = m_currentAddress; m_selEnd = m_selStart; SetCapture(); } else { BOOL bsel = m_selStart != 0xffffffff; m_selStart = 0xffffffff; m_selEnd = 0xffffffff; if(bsel) RedrawWindow(); } } if(!IsSelected()) { ShowCaret(); } }
void CHexEdit::OnLButtonDown(UINT nFlags, CPoint point) { SetFocus(); if(!m_pData) return; CPoint pt = CalcPos(point.x, point.y); if(pt.x > -1)//点合法 { m_editPos = pt; pt.x *= m_nullWidth; pt.y *= m_lineHeight; if(pt.x == 0 && m_bShowAddress) CreateAddressCaret(); else CreateEditCaret(); if(nFlags & MK_SHIFT)//按下SHIFT m_selEnd = m_currentAddress; else { m_selStart= m_currentAddress; m_selEnd = m_selStart; //if(DragDetect(m_hWnd,point))//按下左键时拖动 if(DragDetect(point))//按下左键时拖动 SetCapture(); } SetCaretPos(pt); ShowCaret(); Invalidate(FALSE); } }
void CTutorialWindow::OnLButtonDown(UINT nFlags, CPoint point) { // Get currently playing track. static_api_ptr_t<play_control> pc; metadb_handle_ptr handle; // If some track is playing... if (pc->get_now_playing(handle)) { POINT pt; GetCursorPos(&pt); // ...detect a drag operation. if (DragDetect(m_hWnd, pt)) { metadb_handle_list items; items.add_item(handle); // Create an IDataObject that contains the dragged track. static_api_ptr_t<playlist_incoming_item_filter> piif; // create_dataobject_ex() returns a smart pointer unlike create_dataobject() // which returns a raw COM pointer. The less chance we have to accidentally // get the reference counting wrong, the better. pfc::com_ptr_t<IDataObject> pDataObject = piif->create_dataobject_ex(items); // Create an IDropSource. // The constructor of IDropSource_tutorial1 is hidden by design; we use the // provided factory method which returns a smart pointer. pfc::com_ptr_t<IDropSource> pDropSource = IDropSource_tutorial1::g_create(m_hWnd); DWORD effect; // Perform drag&drop operation. DoDragDrop(pDataObject.get_ptr(), pDropSource.get_ptr(), DROPEFFECT_COPY, &effect); } } }
void GraphicsWindow::OnLButtonDown(int pixelX, int pixelY, DWORD flags) { const float dipX = DPIScale::PixelsToDipsX(pixelX); const float dipY = DPIScale::PixelsToDipsY(pixelY); if (mode == DrawMode) { POINT pt = { pixelX, pixelY }; if (DragDetect(m_hwnd, pt)) { SetCapture(m_hwnd); // Start a new ellipse - OnMove will continually readjust it InsertEllipse(dipX, dipY); } } else { ClearSelection(); if (HitTest(dipX, dipY)) { // If we selected and item start capturing drag SetCapture(m_hwnd); // Set a local mouse point to the delta of ellipse and actual click location ptMouse = Selection()->ellipse.point; ptMouse.x -= dipX; ptMouse.y -= dipY; SetMode(DragMode); } } // Force a repaint InvalidateRect(m_hwnd, NULL, FALSE); }
LRESULT VirtualDimension::OnLeftButtonDown(HWND hWnd, UINT /*message*/, WPARAM /*wParam*/, LPARAM lParam) { POINT pt; BOOL screenPos = FALSE; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); if (m_shrinked) { if (!IsPreviewWindowLocked() && //for performance reasons only (ClientToScreen(hWnd, &pt)) && (DragDetect(hWnd, pt))) { //trick windows into thinking we are dragging the title bar, to let the user move the window m_draggedWindow = NULL; m_dragCursor = NULL; ReleaseCapture(); ::SendMessage(hWnd,WM_NCLBUTTONDOWN,HTCAPTION,(LPARAM)&pt); } else UnShrink(); } else { //Stop the hide timer, to ensure the window does not get hidden KillTimer(m_autoHideTimerId); //Find the item under the mouse, and check if it's being dragged Desktop * desk = deskMan->GetDesktopFromPoint(pt.x, pt.y); if ( (desk) && ((m_draggedWindow = desk->GetWindowFromPoint(pt.x, pt.y)) != NULL) && (!m_draggedWindow->IsOnDesk(NULL)) && ((screenPos = ClientToScreen(hWnd, &pt)) != FALSE) && (DragDetect(hWnd, pt)) ) { ICONINFO icon; //Dragging a window's icon SetCapture(hWnd); GetIconInfo(m_draggedWindow->GetIcon(), &icon); icon.fIcon = FALSE; m_dragCursor = (HCURSOR)CreateIconIndirect(&icon); SetCursor(m_dragCursor); } else if (!IsPreviewWindowLocked() && //for performance reasons only (screenPos || ClientToScreen(hWnd, &pt)) && (DragDetect(hWnd, pt))) { //trick windows into thinking we are dragging the title bar, to let the user move the window m_draggedWindow = NULL; m_dragCursor = NULL; ReleaseCapture(); ::SendMessage(hWnd,WM_NCLBUTTONDOWN,HTCAPTION,(LPARAM)&pt); } else { //switch to the desktop that was clicked m_draggedWindow = NULL; deskMan->SwitchToDesktop(desk); } } return 0; }
bool _HYSequencePane::_ProcessOSEvent (Ptr vEvent) { static bool amScrolling = false, vertical; static POINT localPt; static long originalStart, originalSpan, lastClick, firstClick; if (_HYPlatformComponent::_ProcessOSEvent (vEvent)) { return true; } if (!active) { return false; } short lastH, lastV; POINT globalPt; _HYWindowsUIMessage* theEvent = (_HYWindowsUIMessage*)vEvent; switch (theEvent->iMsg) { case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: { lastH = (short)LOWORD (theEvent->lParam), lastV = (short)HIWORD (theEvent->lParam); globalPt = (POINT) { lastH, lastV }; localPt = (POINT) { lastH - rel.left , lastV - rel.top }; vertical = (localPt.x<headerWidth)&&(localPt.y>=(GetSlotHeight()+1)); if ((theEvent->iMsg == WM_LBUTTONDOWN)||(theEvent->iMsg == WM_LBUTTONDBLCLK)) { forceUpdateForScrolling = true; if (vertical) ProcessVSelectionChange (localPt.x,localPt.y,GetAsyncKeyState (VK_SHIFT) & 0x8000, GetAsyncKeyState (VK_CONTROL) & 0x8000, false, theEvent->iMsg == WM_LBUTTONDBLCLK); else ProcessSelectionChange (localPt.x,localPt.y,GetAsyncKeyState (VK_SHIFT) & 0x8000, GetAsyncKeyState (VK_CONTROL) & 0x8000); forceUpdateForScrolling = false; ClientToScreen (parentWindow, &globalPt); if (DragDetect (parentWindow, globalPt)) { if (messageRecipient) { SetCapture (parentWindow); ((_HYTWindow*)messageRecipient)->trackMouseComponent = this; } amScrolling = true; if (vertical) { originalStart = startRow, originalSpan = endRow-startRow; lastClick = -2; firstClick = (localPt.y-(GetSlotHeight()+1))/GetSlotHeight(); } } return true; } if ((theEvent->iMsg == WM_RBUTTONDOWN)&&(vertical&&vselection.lLength)||((!vertical)&&selection.lLength)) { ClientToScreen (parentWindow, &globalPt); ProcessContextualPopUp (globalPt.x, globalPt.y); return true; } } break; case WM_LBUTTONUP: if (amScrolling) { amScrolling = false; if (messageRecipient) { ReleaseCapture (); ((_HYTWindow*)messageRecipient)->trackMouseComponent = nil; } if (vertical) { RECT invalRect = {rel.left,rel.top+(GetSlotHeight()+1)+1,rel.left+headerWidth,rel.bottom-HY_SCROLLER_WIDTH}; InvalidateRect (parentWindow,&invalRect,false); if ((localPt.x<headerWidth)&&(localPt.x>0)&&(lastClick>-2)) { MoveSpecies (firstClick+originalStart,lastClick+startRow); } } } return true; break; case WM_MOUSEMOVE: if ((theEvent->wParam & MK_LBUTTON)&&(amScrolling)) { POINT mousePt = {((short)LOWORD (theEvent->lParam))-rel.left, ((short)HIWORD (theEvent->lParam))-rel.top }; if (vertical) { long wHeight = rel.bottom-rel.top-HY_SCROLLER_WIDTH, slotHeight = GetSlotHeight(); forceUpdateForScrolling = true; if ((mousePt.y<(GetSlotHeight()+1))||(localPt.y!=mousePt.y)||(mousePt.y>wHeight)) { localPt = mousePt; if (mousePt.y>wHeight) { // scroll down if ((endRow<=speciesIndex.lLength)&&(vselection.lData[0]!=speciesIndex.lLength-1)) { if (endRow-startRow<originalSpan) { break; } startRow++; endRow++; _SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/ (speciesIndex.lLength-endRow+startRow+1)); BuildPane(); _MarkForUpdate(); lastClick = -2; } break; } else { mousePt.y-=(GetSlotHeight()+1); if (mousePt.y<=slotHeight) { if (mousePt.y>=0) { if (mousePt.y<slotHeight/2) { mousePt.y = -1; } else { mousePt.y = 0; } } else { // scroll up if (startRow>0) { startRow--; endRow--; _SetVScrollerPos(((double)MAX_CONTROL_VALUE*startRow)/(speciesIndex.lLength-endRow+startRow+1)); BuildPane(); _MarkForUpdate(); lastClick = -2; } break; } } else { mousePt.y=(mousePt.y-(GetSlotHeight()+1))/slotHeight; } } if ((mousePt.y<-1)||(mousePt.y>=(endRow-startRow))) { break; } if (mousePt.y!=lastClick) { HDC winDC = GetDC (parentWindow); int saveROP2 = GetROP2 (winDC); SetROP2 (winDC,R2_NOT); if (lastClick>=-1) { lastClick = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1; MoveToEx(winDC,rel.left+1,lastClick,nil); LineTo (winDC,rel.left+headerWidth-1,lastClick); } lastClick = mousePt.y; if (lastClick+startRow!=firstClick+originalStart) { mousePt.y = (GetSlotHeight()+1)+slotHeight*(lastClick+1)+rel.top+1; MoveToEx (winDC,rel.left+1,mousePt.y,nil); LineTo (winDC,rel.left+headerWidth-1,mousePt.y); } SetROP2 (winDC,saveROP2); ReleaseDC (parentWindow,winDC); } } forceUpdateForScrolling = false; return true; } else { if (((mousePt.x<headerWidth)&&(startColumn>0))||(localPt.x!=mousePt.x)||(mousePt.x>_HYCanvas::GetMaxW()-5)) { forceUpdateForScrolling = true; ProcessSelectionChange (mousePt.x,mousePt.y,true,true,true); forceUpdateForScrolling = false; localPt = mousePt; } return true; } } break; } return false; }
DWORD ZDragDetect( HWND hwnd, POINT pt ) { return DragDetect( hwnd, pt ); }