LRESULT CMainWindow::Splitter_OnMouseMove(HWND hwnd, UINT /*iMsg*/, WPARAM wParam, LPARAM lParam) { RECT rect; RECT clientrect; POINT pt; if (bDragMode == FALSE) return 0; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetClientRect(hwnd, &clientrect); GetWindowRect(hwnd, &rect); POINT zero = {0,0}; ClientToScreen(hwnd, &zero); OffsetRect(&clientrect, zero.x-rect.left, zero.y-rect.top); //convert the mouse coordinates relative to the top-left of //the window ClientToScreen(hwnd, &pt); pt.x -= rect.left; pt.y -= rect.top; //same for the window coordinates - make them relative to 0,0 OffsetRect(&rect, -rect.left, -rect.top); if (pt.x < 0) pt.x = 0; if (pt.x > rect.right-4) pt.x = rect.right-4; if (pt.y < 0) pt.y = 0; if (pt.y > rect.bottom-4) pt.y = rect.bottom-4; if ((wParam & MK_LBUTTON) && ((bVertical && (pt.y != oldy)) || (!bVertical && (pt.x != oldx)))) { HDC hdc = GetWindowDC(hwnd); if (bVertical) { DrawXorBar(hdc, clientrect.left, oldy+2, clientrect.right-clientrect.left-2, 4); DrawXorBar(hdc, clientrect.left, pt.y+2, clientrect.right-clientrect.left-2, 4); } else { DrawXorBar(hdc, oldx+2, clientrect.top, 4, clientrect.bottom-clientrect.top-2); DrawXorBar(hdc, pt.x+2, clientrect.top, 4, clientrect.bottom-clientrect.top-2); } ReleaseDC(hwnd, hdc); oldx = pt.x; oldy = pt.y; } return 0; }
LRESULT CULSplitter::OnMouseMove(WPARAM wParam,LPARAM lParam) { if(!m_fResize) return FALSE; if(m_fDragMode==FALSE) return 0; POINT pt={(short)LOWORD(lParam),(short)HIWORD(lParam)}; RECT rect; GetWindowRect(&rect); ClientToScreen(&pt); pt.x-=rect.left; pt.y-=rect.top; OffsetRect(&rect,-rect.left,-rect.top); if(m_SplitterOrientation==soHorz) { if(pt.y<0) pt.y=0; if(pt.y>rect.bottom-4) pt.y=rect.bottom-4; } else if(m_SplitterOrientation==soVert) { if(pt.x<0) pt.x=0; if(pt.x>rect.right-4) pt.x=rect.right-4; } if(pt.y!=m_oldPos&&wParam&MK_LBUTTON) { HDC hDC=GetWindowDC(*this); if(m_SplitterOrientation==soHorz) { DrawXorBar(hDC,1,m_oldPos-2,rect.right-2,4); DrawXorBar(hDC,1,pt.y-2,rect.right-2,4); } else if(m_SplitterOrientation==soVert) { DrawXorBar(hDC,m_oldPos-2,1,4,rect.bottom-2); DrawXorBar(hDC,pt.x-2,1,4,rect.bottom-2); } ReleaseDC(*this,hDC); m_oldPos=(m_SplitterOrientation==soHorz)?pt.y:pt.x; } return FALSE; }
LRESULT CULSplitter::OnLButtonUp(WPARAM,LPARAM lParam) { if(!m_fResize) return FALSE; POINT pt={(short)LOWORD(lParam),(short)HIWORD(lParam)}; if(m_fDragMode == FALSE) return 0; RECT rect; GetWindowRect(&rect); ClientToScreen(&pt); pt.x-=rect.left; pt.y-=rect.top; OffsetRect(&rect,-rect.left,-rect.top); if(m_SplitterOrientation==soHorz) { if(pt.y<0) pt.y=0; if(pt.y>rect.bottom-4) pt.y=rect.bottom-4; } else if(m_SplitterOrientation==soVert) { if(pt.x<0) pt.x=0; if(pt.x>rect.right-4) pt.x=rect.right-4; } HDC hDC=GetWindowDC(*this); if(m_SplitterOrientation==soHorz) DrawXorBar(hDC,1,pt.y-2,rect.right-2,4); else if(m_SplitterOrientation==soVert) DrawXorBar(hDC,pt.x-2,1,4,rect.bottom-2); ReleaseDC(*this,hDC); m_oldPos=(m_SplitterOrientation==soHorz)?pt.y:pt.x; m_fDragMode=FALSE; GetWindowRect(&rect); pt.x+=rect.left; pt.y+=rect.top; ScreenToClient(&pt); GetClientRect(&rect); m_nSplitterPos=(m_SplitterOrientation==soHorz)?pt.y:pt.x; SizeWindowContents(rect.right,rect.bottom); ReleaseCapture(); return FALSE; }
void CRepositoryBrowser::OnMouseMove(UINT nFlags, CPoint point) { if (bDragMode == FALSE) return; RECT rect, tree, list, treelist, treelistclient; // create an union of the tree and list control rectangle GetDlgItem(IDC_REPOLIST)->GetWindowRect(&list); GetDlgItem(IDC_REPOTREE)->GetWindowRect(&tree); UnionRect(&treelist, &tree, &list); treelistclient = treelist; ScreenToClient(&treelistclient); //convert the mouse coordinates relative to the top-left of //the window ClientToScreen(&point); GetClientRect(&rect); ClientToScreen(&rect); point.x -= rect.left; point.y -= treelist.top; //same for the window coordinates - make them relative to 0,0 OffsetRect(&treelist, -treelist.left, -treelist.top); if (point.x < treelist.left + REPOBROWSER_CTRL_MIN_WIDTH) point.x = treelist.left + REPOBROWSER_CTRL_MIN_WIDTH; if (point.x > treelist.right - REPOBROWSER_CTRL_MIN_WIDTH) point.x = treelist.right - REPOBROWSER_CTRL_MIN_WIDTH; if ((nFlags & MK_LBUTTON) && (point.x != oldx)) { CDC * pDC = GetDC(); if (pDC) { DrawXorBar(pDC, oldx + 2, treelistclient.top, 4, treelistclient.bottom - treelistclient.top - 2); DrawXorBar(pDC, point.x + 2, treelistclient.top, 4, treelistclient.bottom - treelistclient.top - 2); ReleaseDC(pDC); } oldx = point.x; oldy = point.y; } CStandAloneDialogTmpl<CResizableDialog>::OnMouseMove(nFlags, point); }
void CRepositoryBrowser::HandleDividerMove(CPoint point, bool bDraw) { RECT rect, tree, list, treelist, treelistclient; // create an union of the tree and list control rectangle GetDlgItem(IDC_REPOLIST)->GetWindowRect(&list); GetDlgItem(IDC_REPOTREE)->GetWindowRect(&tree); UnionRect(&treelist, &tree, &list); treelistclient = treelist; ScreenToClient(&treelistclient); ClientToScreen(&point); GetClientRect(&rect); ClientToScreen(&rect); CPoint point2 = point; if (point2.x < treelist.left + REPOBROWSER_CTRL_MIN_WIDTH) point2.x = treelist.left + REPOBROWSER_CTRL_MIN_WIDTH; if (point2.x > treelist.right - REPOBROWSER_CTRL_MIN_WIDTH) point2.x = treelist.right - REPOBROWSER_CTRL_MIN_WIDTH; point.x -= rect.left; point.y -= treelist.top; OffsetRect(&treelist, -treelist.left, -treelist.top); if (point.x < treelist.left+REPOBROWSER_CTRL_MIN_WIDTH) point.x = treelist.left+REPOBROWSER_CTRL_MIN_WIDTH; if (point.x > treelist.right-REPOBROWSER_CTRL_MIN_WIDTH) point.x = treelist.right-REPOBROWSER_CTRL_MIN_WIDTH; if (bDraw) { CDC * pDC = GetDC(); DrawXorBar(pDC, oldx + 2, treelistclient.top, 4, treelistclient.bottom - treelistclient.top - 2); ReleaseDC(pDC); } oldx = point.x; oldy = point.y; //position the child controls GetDlgItem(IDC_REPOTREE)->GetWindowRect(&treelist); treelist.right = point2.x - 2; ScreenToClient(&treelist); RemoveAnchor(IDC_REPOTREE); GetDlgItem(IDC_REPOTREE)->MoveWindow(&treelist); GetDlgItem(IDC_REPOLIST)->GetWindowRect(&treelist); treelist.left = point2.x + 2; ScreenToClient(&treelist); RemoveAnchor(IDC_REPOLIST); GetDlgItem(IDC_REPOLIST)->MoveWindow(&treelist); AddAnchor(IDC_REPOTREE, TOP_LEFT, BOTTOM_LEFT); AddAnchor(IDC_REPOLIST, TOP_LEFT, BOTTOM_RIGHT); }
LRESULT FileListDialog::Splitter_OnMouseMove(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; RECT rect; POINT pt; if(fDragMode == FALSE) return 0; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetWindowRect(hwnd, &rect); ClientToScreen(hwnd, &pt); pt.x -= rect.left; pt.y -= rect.top; OffsetRect(&rect, -rect.left, -rect.top); if(pt.x < 0) pt.x = 0; if(pt.x > rect.right-4) { pt.x = rect.right-4; } if(pt.x != oldx && wParam & MK_LBUTTON) { hdc = GetWindowDC(hwnd); DrawXorBar(hdc, oldx - 2,1, 4,rect.right-2); DrawXorBar(hdc, pt.x - 2,1, 4,rect.right-2); ReleaseDC(hwnd, hdc); oldx = pt.x; } return 0; }
LRESULT FileListDialog::Splitter_OnLButtonUp(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; RECT rect; POINT pt; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); if(fDragMode == FALSE) return 0; GetWindowRect(hwnd, &rect); ClientToScreen(hwnd, &pt); pt.x -= rect.left; pt.y -= rect.top; OffsetRect(&rect, -rect.left, -rect.top); if(pt.x < 0) pt.x = 0; if(pt.x > rect.right-4) { pt.x = rect.right-4; } hdc = GetWindowDC(hwnd); DrawXorBar(hdc,oldx - 2, 1,4, rect.right-2); ReleaseDC(hwnd, hdc); oldx = pt.x; fDragMode = FALSE; //convert the splitter position back to screen coords. GetWindowRect(hwnd, &rect); pt.x += rect.left; pt.y += rect.top; //now convert into CLIENT coordinates ScreenToClient(hwnd, &pt); GetClientRect(hwnd, &rect); WindowRatio=(float)pt.x/(float)rect.right; //position the child controls ResizeListBoxes(); ReleaseCapture(); return 0; }
LRESULT FileListDialog::Splitter_OnLButtonDown(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { POINT pt; HDC hdc; RECT rect; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetWindowRect(hwnd, &rect); //convert the mouse coordinates relative to the top-left of //the window ClientToScreen(hwnd, &pt); pt.x -= rect.left; pt.y -= rect.top; //same for the window coordinates - make them relative to 0,0 OffsetRect(&rect, -rect.left, -rect.top); if(pt.x < 0) pt.x = 0; if(pt.x > rect.right-4) { pt.x = rect.right-4; } fDragMode = TRUE; SetCapture(hwnd); hdc = GetWindowDC(hwnd); DrawXorBar(hdc,pt.x - 2, 1,4, rect.right-2); ReleaseDC(hwnd, hdc); oldx = pt.x; return 0; }
LRESULT CMainWindow::Splitter_OnLButtonUp(HWND hwnd, UINT /*iMsg*/, WPARAM /*wParam*/, LPARAM lParam) { HDC hdc; RECT rect; RECT clientrect; POINT pt; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); if (bDragMode == FALSE) return 0; GetClientRect(hwnd, &clientrect); GetWindowRect(hwnd, &rect); POINT zero = {0,0}; ClientToScreen(hwnd, &zero); OffsetRect(&clientrect, zero.x-rect.left, zero.y-rect.top); ClientToScreen(hwnd, &pt); pt.x -= rect.left; pt.y -= rect.top; OffsetRect(&rect, -rect.left, -rect.top); if (pt.x < 0) pt.x = 0; if (pt.x > rect.right-4) pt.x = rect.right-4; if (pt.y < 0) pt.y = 0; if (pt.y > rect.bottom-4) pt.y = rect.bottom-4; hdc = GetWindowDC(hwnd); if (bVertical) DrawXorBar(hdc, clientrect.left, oldy+2, clientrect.right-clientrect.left-2, 4); else DrawXorBar(hdc, oldx+2, clientrect.top, 4, clientrect.bottom-clientrect.top-2); ReleaseDC(hwnd, hdc); oldx = pt.x; oldy = pt.y; bDragMode = false; //convert the splitter position back to screen coords. GetWindowRect(hwnd, &rect); pt.x += rect.left; pt.y += rect.top; //now convert into CLIENT coordinates ScreenToClient(hwnd, &pt); GetClientRect(hwnd, &rect); #define MINWINSIZE 10 if (bVertical) { if (bDrag2) { if (pt.y < (nSplitterPos+MINWINSIZE)) pt.y = nSplitterPos+MINWINSIZE; nSplitterPos2 = pt.y; } else { if (pt.y > (nSplitterPos2-MINWINSIZE)) pt.y = nSplitterPos2-MINWINSIZE; nSplitterPos = pt.y; } } else { if (bDrag2) { if (pt.x < (nSplitterPos+MINWINSIZE)) pt.x = nSplitterPos+MINWINSIZE; nSplitterPos2 = pt.x; } else { if (pt.x > (nSplitterPos2-MINWINSIZE)) pt.x = nSplitterPos2-MINWINSIZE; nSplitterPos = pt.x; } } ReleaseCapture(); //position the child controls PositionChildren(&rect); return 0; }
LRESULT CMainWindow::Splitter_OnLButtonDown(HWND hwnd, UINT /*iMsg*/, WPARAM /*wParam*/, LPARAM lParam) { POINT pt; HDC hdc; RECT rect; RECT clientrect; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetClientRect(hwnd, &clientrect); GetWindowRect(hwnd, &rect); POINT zero = {0,0}; ClientToScreen(hwnd, &zero); OffsetRect(&clientrect, zero.x-rect.left, zero.y-rect.top); ClientToScreen(hwnd, &pt); // find out which drag bar is used bDrag2 = false; if (!selectionPaths.empty()) { RECT pic2Rect; GetWindowRect(picWindow2, &pic2Rect); if (bVertical) { if (pic2Rect.bottom <= pt.y) bDrag2 = true; } else { if (pic2Rect.right <= pt.x) bDrag2 = true; } } //convert the mouse coordinates relative to the top-left of //the window pt.x -= rect.left; pt.y -= rect.top; //same for the window coordinates - make them relative to 0,0 OffsetRect(&rect, -rect.left, -rect.top); if (pt.x < 0) pt.x = 0; if (pt.x > rect.right-4) pt.x = rect.right-4; if (pt.y < 0) pt.y = 0; if (pt.y > rect.bottom-4) pt.y = rect.bottom-4; bDragMode = true; SetCapture(hwnd); hdc = GetWindowDC(hwnd); if (bVertical) DrawXorBar(hdc, clientrect.left, pt.y+2, clientrect.right-clientrect.left-2, 4); else DrawXorBar(hdc, pt.x+2, clientrect.top, 4, clientrect.bottom-clientrect.top-2); ReleaseDC(hwnd, hdc); oldx = pt.x; oldy = pt.y; return 0; }
static void DrawResizeLineH(SplitterWnd *w, int y) { RectI rc; HDC hdc = InitDraw(w, rc); DrawXorBar(hdc, rc.x, y, rc.dx, 4); ReleaseDC(GetParent(w->hwnd), hdc); }
static void DrawResizeLineV(SplitterWnd *w, int x) { RectI rc; HDC hdc = InitDraw(w, rc); DrawXorBar(hdc, x, rc.y, 4, rc.dy); ReleaseDC(GetParent(w->hwnd), hdc); }
LRESULT CALLBACK SpltWe_WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int oldx; static int y; static int line_height; static int min_left; static int max_right; POINT pt; HDC hdc; RECT rect; HWND hp = GetParent(hwnd); switch (message) { case WM_CREATE: return 0 ; case WM_LBUTTONDOWN: SetCapture(hwnd); we_sizing = 1; line_height = win_height(hwnd); y = win_top(hwnd);; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetWindowRect(hp,&rect); min_left = rect.left + MIN_SPLT_SPACE; max_right = rect.right - MIN_SPLT_SPACE; //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; ClientToScreen(hwnd,&pt); //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.x < min_left) pt.x = min_left; if(pt.x > max_right) { pt.x = max_right; } hdc = GetDC(NULL); DrawXorBar(hdc, pt.x-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); ReleaseDC(NULL, hdc); oldx = pt.x; break; case WM_LBUTTONUP: ReleaseCapture(); pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetClientRect(hp,&rect); //GetClientRect(hwnd,&splt_rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; hdc = GetDC(NULL); DrawXorBar(hdc, oldx-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); ReleaseDC(NULL, hdc); we_sizing = 0; pt.x = oldx; ScreenToClient(hp,&pt); send_splitter_x(hp, pt.x); break; case WM_MOUSEMOVE: if(0==we_sizing) break; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); //GetClientRect(hwnd_frame,&rect); //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); ClientToScreen(hwnd,&pt); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.x < min_left) pt.x = min_left; if(pt.x > max_right) { pt.x = max_right; } if(pt.x != oldx && wParam & MK_LBUTTON) { hdc = GetDC(NULL); DrawXorBar(hdc, oldx-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); DrawXorBar(hdc, pt.x-SPLT_WIDTH/2, y, SPLT_WIDTH, line_height); ReleaseDC(NULL, hdc); oldx = pt.x; } break; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
LRESULT CALLBACK SpltNs_WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int oldy; static int x; static int line_width; static int min_top; static int max_bottom; POINT pt; HDC hdc; RECT rect; HWND hp = GetParent(hwnd); switch (message) { case WM_CREATE: return 0 ; case WM_LBUTTONDOWN: SetCapture(hwnd); ns_sizing = 1; line_width = win_width(hwnd); x = win_left(hwnd);; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetWindowRect(hp,&rect); min_top= win_top(hp)+ MIN_SPLT_SPACE; max_bottom = win_bottom(hp) - MIN_SPLT_SPACE; //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; ClientToScreen(hwnd,&pt); //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.y < min_top) pt.y = min_top; if(pt.y > max_bottom) { pt.y = max_bottom; } hdc = GetDC(NULL); DrawXorBar(hdc, x, pt.y-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); oldy = pt.y; break; case WM_LBUTTONUP: ReleaseCapture(); pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetClientRect(hp,&rect); //GetClientRect(hwnd,&splt_rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; hdc = GetDC(NULL); DrawXorBar(hdc, x, oldy-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); ns_sizing = 0; pt.y = oldy; ScreenToClient(hp,&pt); send_splitter_y(hp, pt.y); break; case WM_MOUSEMOVE: if(0==ns_sizing) break; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); //GetClientRect(hwnd_frame,&rect); //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); ClientToScreen(hwnd,&pt); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.y < min_top) pt.y = min_top; if(pt.y > max_bottom) { pt.y = max_bottom; } if(pt.y != oldy && wParam & MK_LBUTTON) { hdc = GetDC(NULL); DrawXorBar(hdc, x, oldy-SPLT_WIDTH/2, line_width, SPLT_WIDTH); DrawXorBar(hdc, x, pt.y-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); oldy = pt.y; } break; } return DefWindowProc (hwnd, message, wParam, lParam) ; }