LOCAL void ListBox_DoDrag(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { // Let the listbox control handle the mouse down so a selection can happen FORWARD_WM_LBUTTONDOWN(hWindow, fDoubleClick, x, y, keyFlags, ListBox_CallWindowProc); // see if it's cool for us to try to drag LPLISTBOXDATA lpData = DragOK(hWindow); if (!lpData) return; // make the listbox think it got a mouse up so we can take over FORWARD_WM_LBUTTONUP(hWindow, x, y, keyFlags, ListBox_CallWindowProc); // initialize the dragging DragBegin(hWindow, x, y); // dragging loop while (lpData->fCapture) { MSG msg; // Look for mouse, keyboard, and timer messages. // keystroke messages are retrieved to avoid the message // queue from getting full while ( !PeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) && !PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) && !PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE)) WaitMessage(); switch(msg.message) { case WM_MOUSEMOVE: HANDLE_WM_MOUSEMOVE(msg.hwnd, msg.wParam, msg.lParam, Drag_OnMouseMove); break; case WM_TIMER: HANDLE_WM_TIMER(msg.hwnd, msg.wParam, msg.lParam, Drag_OnTimer); break; case WM_LBUTTONUP: HANDLE_WM_LBUTTONUP(msg.hwnd, msg.wParam, msg.lParam, Drag_OnLButtonUp); break; default: // Process messages we don't handle TranslateMessage(&msg); DispatchMessage(&msg); break; } } // process the drag and cleanup DragEnd(hWindow); }
void COlelistBox::OnLButtonDown(UINT nFlags, CPoint point) { FNAME *lpResult; CDataItem *pDataItem; LPIMAGE lpImage = GetActiveImage(); CServerDoc *pDoc = PictPubApp.GetDocument(lpImage); int num; CRect r,rr; BOOL bCreateDoc = (pDoc == NULL); CPoint p; CListBox::OnLButtonDown(nFlags, point); FORWARD_WM_LBUTTONUP(GetSafeHwnd(), point.x, point.y, nFlags, ::SendMessage); lpResult = ExtBsr_GetSelection(GetParent()->GetSafeHwnd(), &num); if (!lpResult || num != 1) return; lstrcpy(Names.Clipboard, lpResult[0]); if (LookupExtFileN(Names.Clipboard, Names.PasteImageFile, IDN_CLIPBOARD, NO)) { if (bCreateDoc) { LPFRAME lpFrame = FrameOpen(FDT_GRAYSCALE, 1, 1, 72); if (lpFrame) { POSITION Pos; lpImage = CreateImage(NULL,lpFrame,NULL,NULL, IDN_PP,IDC_SAVECT,IMG_DOCUMENT,NULL); if (!lpImage) { FrameClose(lpFrame); return; } pDoc = (CServerDoc*)PictPubApp.OpenDocumentFile( lpImage->CurFile, lpImage, FALSE); if (!pDoc) { DestroyImage(lpImage); return; } } else return; } if (pDoc) { pDataItem = new CDataItem(pDoc, Names.Clipboard, YES); GetParent()->GetWindowRect(&r); ClientToScreen(&point); GetItemRect(GetCurSel(), &rr); ClientToScreen(&rr); p.x = rr.Width() / 2; p.y = rr.Height() / 2; // NOTE!!the pDataItem will be internally destroyed once the drag/drop // operation is completed therefore we do not need to delete the pDataItem pDataItem->DoDragDrop(&rr, p, FALSE, DROPEFFECT_COPY, &r); if (bCreateDoc) pDoc->OnCloseDocument(); } } else if(Names.Clipboard[0]) { // deleted the file...notify the browser UpdatePasteFromFile(NULL); } }