void Status_OnMouseMove() { POINT pt; if( fCanMove ) { GetCursorPos( &pt ); DrawUIBorder(&drc); drc.left = pt.x - ptdif.x; drc.top = pt.y - ptdif.y; drc.right = drc.left + sz.cx; drc.bottom = drc.top + sz.cy; DrawUIBorder(&drc); } }
void Status_OnLButtonUp(HWND hWnd,WPARAM wParam,LPARAM lParam) { HDC hdc; hdc = GetDC(hWnd); POINT pt; ReleaseCapture(); if( fCanMove ) { DrawUIBorder(&drc); GetCursorPos( &pt ); MoveWindow(hWnd,pt.x - ptdif.x, pt.y - ptdif.y, sz.cx, sz.cy,TRUE); } fCanMove = FALSE; }
void DragUI( HWND hWnd, HWND hWnd1,UINT message, WPARAM wParam, LPARAM lParam,BOOL fIsCompWnd) { POINT pt; static POINT ptdif,ptdif1; static RECT drc,drc1; static SIZE sz,sz1; DWORD dwT; switch (message) { case WM_SETCURSOR: if ( HIWORD(lParam) == WM_LBUTTONDOWN || HIWORD(lParam) == WM_RBUTTONDOWN ) { GetCursorPos( &pt ); SetCapture(hWnd); GetWindowRect(hWnd,&drc); ptdif.x = pt.x - drc.left; ptdif.y = pt.y - drc.top; sz.cx = drc.right - drc.left; sz.cy = drc.bottom - drc.top; if (IsWindow(hWnd1)) { GetWindowRect(hWnd1,&drc1); ptdif1.x = pt.x - drc1.left; ptdif1.y = pt.y - drc1.top; sz1.cx = drc1.right - drc1.left; sz1.cy = drc1.bottom - drc1.top; } SetWindowLong(hWnd,FIGWL_MOUSE,FIM_CAPUTURED); } break; case WM_MOUSEMOVE: dwT = GetWindowLong(hWnd,FIGWL_MOUSE); if (dwT & FIM_MOVED) { DrawUIBorder(&drc); if (IsWindow(hWnd1)) DrawUIBorder(&drc1); GetCursorPos( &pt ); drc.left = pt.x - ptdif.x; drc.top = pt.y - ptdif.y; drc.right = drc.left + sz.cx; drc.bottom = drc.top + sz.cy; if (IsWindow(hWnd1)) { drc1.left = pt.x - ptdif1.x; drc1.top = pt.y - ptdif1.y; drc1.right = drc1.left + sz1.cx; drc1.bottom = drc1.top + sz1.cy; } DrawUIBorder(&drc); if (IsWindow(hWnd1)) DrawUIBorder(&drc1); } else if (dwT & FIM_CAPUTURED) { DrawUIBorder(&drc); if (IsWindow(hWnd1)) DrawUIBorder(&drc1); SetWindowLong(hWnd,FIGWL_MOUSE,dwT | FIM_MOVED); } break; case WM_LBUTTONUP: case WM_RBUTTONUP: dwT = GetWindowLong(hWnd,FIGWL_MOUSE); if (dwT & FIM_CAPUTURED) { ReleaseCapture(); if (dwT & FIM_MOVED) { DrawUIBorder(&drc); if (IsWindow(hWnd1)) DrawUIBorder(&drc1); GetCursorPos( &pt ); MoveWindow(hWnd,pt.x - ptdif.x, pt.y - ptdif.y, sz.cx, sz.cy,TRUE); if(fIsCompWnd) { HWND hUIWnd; LPARAM mylParam; *((LPWORD)(&mylParam)) = (WORD)(pt.x - ptdif.x); *((LPWORD)(&mylParam)+1) = (WORD)(pt.y - ptdif.y); hUIWnd = (HWND)GetWindowLong(hWnd,FIGWL_SVRWND); if (IsWindow(hUIWnd)) SendMessage(hUIWnd,WM_UI_COMPMOVE,0,mylParam); } if (IsWindow(hWnd1)) { MoveWindow(hWnd1,pt.x - ptdif1.x, pt.y - ptdif1.y, sz1.cx, sz1.cy,TRUE); } } } break; } }
void Status_OnCaptureMouse(HWND hWnd,WPARAM wParam,LPARAM lParam) { POINT pt; RECT rcInner; int Offest; if ( HIWORD(lParam) == WM_LBUTTONDOWN ) { SetCapture(hWnd); GetCursorPos(&pt); GetWindowRect(hWnd,&drc); rcInner.left = drc.left; rcInner.top=drc.top; rcInner.bottom=drc.bottom; rcInner.right=rcInner.left+60; if (PtInRect(&rcInner,pt)) //电击可移动区域 { ptdif.x = pt.x - drc.left; //计算鼠标坐标与矩形左上角x坐标的距离 ptdif.y = pt.y - drc.top; //算鼠标坐标与矩形左上角y坐标的距离 sz.cx = drc.right - drc.left; //矩形宽度大小 sz.cy = drc.bottom - drc.top; //矩形高度大小 RECT m_drc = drc; DrawUIBorder(&m_drc); SetCursor(LoadCursor(NULL, IDC_SIZEALL)); fCanMove = TRUE; } else //点击按钮 { Offest=pt.x-drc.left; Offest=Offest/20; switch(Offest) { case 3: //英 中 { if (dwType & TYPE_ZHONGWEN) { dwType=dwType&~TYPE_ZHONGWEN; dwType|=TYPE_YINGYU; } else if (dwType & TYPE_YINGYU) { dwType=dwType&~TYPE_YINGYU; dwType|=TYPE_ZHONGWEN; } } break; case 4: //全 半 { if (dwType & TYPE_CHUANGJIAO) { dwType=dwType&~TYPE_CHUANGJIAO; dwType|=TYPE_BANJIAO; } else if (dwType & TYPE_BANJIAO) { dwType=dwType&~TYPE_BANJIAO; dwType|=TYPE_CHUANGJIAO; } } break; case 5: //标点 { if (dwType & TYPE_BIAO1) { dwType=dwType&~TYPE_BIAO1; dwType|=TYPE_BIAO2; } else if (dwType & TYPE_BIAO2) { dwType=dwType&~TYPE_BIAO2; dwType|=TYPE_BIAO1; } } break; case 6: //小键盘 { HWND hDlg=CreateDialog(hInst,(LPSTR)IDD_SOFTKETBOARD,hStatus,(DLGPROC)KeyBoardProc); ShowWindow(hDlg,SW_NORMAL); } break; case 7: //设置 { SendMessage(hWnd,WM_RBUTTONDOWN,wParam,lParam); }//case break; default: break; } HDC hStatusDC=GetDC(hStatus); Status_OnPaint(hStatus,hStatusDC); ReleaseDC(hStatus,hStatusDC); } } else if (HIWORD(lParam) == WM_RBUTTONDOWN ) { SetCapture(hWnd); } else if (HIWORD(lParam) == WM_MOUSEMOVE) { GetCursorPos(&pt); GetWindowRect(hWnd,&drc); rcInner.left = drc.left; rcInner.top=drc.top; rcInner.bottom=drc.bottom; rcInner.right=rcInner.left+60; if (PtInRect(&rcInner,pt)) //在移动窗口区域 { SetCursor(LoadCursor(NULL, IDC_SIZEALL)); } else //在其它区域 { SetCursor(LoadCursor(NULL,IDC_ARROW)); Offest=pt.x-drc.left; Offest=Offest/20; switch(Offest) { case 3: { if (dwType & TYPE_ZHONGWEN) { } else if (dwType & TYPE_YINGYU) { } } break; case 4: break; case 5: break; case 6: break; default: break; } } } }