| #define WIDTHMOVEDLG   4 //拉伸對(duì)話框的寬度 //拉伸對(duì)話框 CTransparentDlg *m_pMoveDlg; //對(duì)話框是否處于可移動(dòng)狀態(tài) BOOL m_bMoveable; //拉伸的起始位置 CPoint m_ptOrigin;//在OnLButtonDown中取值 //模板對(duì)話框是否處于移動(dòng)狀態(tài) BOOL m_bDlgMoving; //模板對(duì)話框拉伸的類(lèi)型,1表示從左邊拉伸,2表示從右邊拉伸,3表示從下面拉伸 int m_nMoveStyle; void C**Dlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: 在此添加消息處理程序代碼和/或調(diào)用默認(rèn)值 //-----以下的程序用于實(shí)現(xiàn)對(duì)話框的拉伸------///// CRect rect,rectLeft,rectRight,rectDown; GetClientRect(&rect); //設(shè)置可移動(dòng)矩形區(qū)域的大小 //左邊可移動(dòng)區(qū)域 rectLeft.SetRect( rect.left, rect.top, rect.left+WIDTHMOVEDLG+2, rect.bottom ); //右邊可移動(dòng)區(qū)域 rectRight.SetRect( rect.right-WIDTHMOVEDLG-2, rect.top, rect.right, rect.bottom ); //下方可移動(dòng)區(qū)域 rectDown.SetRect( rect.left, rect.bottom-WIDTHMOVEDLG-2, rect.right, rect.bottom ); //從左邊拉伸 if (rectLeft.PtInRect(point))//如果鼠標(biāo)點(diǎn)在左邊區(qū)域上 { //設(shè)置鼠標(biāo)指針表現(xiàn)形式:指向西東 SetCursor(LoadCursor(NULL,IDC_SIZEWE)); m_bMoveable = TRUE; m_nMoveStyle = 1; } //從右邊拉伸 else if (rectRight.PtInRect(point))//如果鼠標(biāo)點(diǎn)在右邊區(qū)域上 { //設(shè)置鼠標(biāo)指針表現(xiàn)形式:指向西東 SetCursor(LoadCursor(NULL,IDC_SIZEWE)); m_bMoveable = TRUE; m_nMoveStyle = 2; } //從下方拉伸 else if(rectDown.PtInRect(point))//如果鼠標(biāo)點(diǎn)在下邊區(qū)域上 { //設(shè)置鼠標(biāo)指針表現(xiàn)形式:指向南北 SetCursor(LoadCursor(NULL,IDC_SIZENS)); m_bMoveable = TRUE; m_nMoveStyle = 3; } else { m_bMoveable = FALSE; } //移動(dòng)虛線對(duì)話框 ClientToScreen(&point);//客戶(hù)區(qū)域坐標(biāo)轉(zhuǎn)換成為屏幕區(qū)域坐標(biāo) int dx,dy; //如果左鍵已經(jīng)點(diǎn)擊下去 if (m_pMoveDlg && m_bDlgMoving && nFlags == MK_LBUTTON) { //水平方向移動(dòng)的距離 dx = point.x- m_ptOrigin.x; dy = point.y - m_ptOrigin.y; //豎直方向移動(dòng)的距離 if (m_nMoveStyle == 1) { m_pMoveDlg -> MoveWindow( rect.left+dx, 101, WIDTHMOVEDLG+2, rect.Height()); } else if (m_nMoveStyle == 2) { CRect rc; GetWindowRect(&rc); int width = point.x - rc.left; if (width <200) { m_pMoveDlg -> MoveWindow( rc.left+194, 101, WIDTHMOVEDLG+2, rect.Height()); } else { m_pMoveDlg -> MoveWindow( rect.right+dx-WIDTHMOVEDLG-2, 101, WIDTHMOVEDLG+2, rect.Height()); } } else if ( 3 == m_nMoveStyle) { CRect rc; GetWindowRect(&rc); int y = point.y - rc.top; if (y >150) { m_pMoveDlg -> MoveWindow( rc.left, rect.bottom+dy-WIDTHMOVEDLG-2, rect.Width(), WIDTHMOVEDLG+2); } else { m_pMoveDlg -> MoveWindow( rc.left, rc.top +150, rect.Width(), WIDTHMOVEDLG+2); } } else { return; } } ////--------------------------------------------//// CDialog::OnMouseMove(nFlags, point); } 創(chuàng)建鼠標(biāo)指針的風(fēng)格與樣式 HINSTANCE hinst; // handle to current instance HCURSOR hCurs1, hCurs2; // cursor handles // Create a standard cursor. hCurs1 = LoadCursor(NULL, IDC_WAIT); //見(jiàn)附注 // Create a custom cursor based on a resource. hCurs2 = LoadCursor(hinst, MAKEINTRESOURCE(240)); | 
|  |