高分求取磁性窗体的vc源码 在http://tech521.com/show_data.asp?tid=1534有一个DELPHI的不知道能否翻译成C你看看吧或许能找出些思路8-) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个函数可使窗体自动靠边,希望对你有所启发BOOL AdjustPos(CRect* lpRect){//自动靠边 int iSX=GetSystemMetrics(SM_CXFULLSCREEN); int iSY=GetSystemMetrics(SM_CYFULLSCREEN); RECT rWorkArea; BOOL bResult = SystemParametersInfo(SPI_GETWORKAREA, sizeof(RECT), &rWorkArea, 0); CRect rcWA; if(!bResult) {//如果调用不成功就利用GetSystemMetrics获取屏幕面积 rcWA=CRect(0,0,iSX,iSY); } else rcWA=rWorkArea; int iX=lpRect->left; int iY=lpRect->top; if(iX < rcWA.left + DETASTEP && iX!=rcWA.left) {//调整左 //pWnd->SetWindowPos(NULL,rcWA.left,iY,0,0,SWP_NOSIZE); lpRect->OffsetRect(rcWA.left-iX,0); AdjustPos(lpRect); return TRUE; } if(iY < rcWA.top + DETASTEP && iY!=rcWA.top) {//调整上 //pWnd->SetWindowPos(NULL ,iX,rcWA.top,0,0,SWP_NOSIZE); lpRect->OffsetRect(0,rcWA.top-iY); AdjustPos(lpRect); return TRUE; } if(iX + lpRect->Width() > rcWA.right - DETASTEP && iX !=rcWA.right-lpRect->Width()) {//调整右 //pWnd->SetWindowPos(NULL ,rcWA.right-rcW.Width(),iY,0,0,SWP_NOSIZE); lpRect->OffsetRect(rcWA.right-lpRect->right,0); AdjustPos(lpRect); return TRUE; } if(iY + lpRect->Height() > rcWA.bottom - DETASTEP && iY !=rcWA.bottom-lpRect->Height()) {//调整下 //pWnd->SetWindowPos(NULL ,iX,rcWA.bottom-rcW.Height(),0,0,SWP_NOSIZE); lpRect->OffsetRect(0,rcWA.bottom-lpRect->bottom); return TRUE; } return FALSE;} 下面的代码可以看懂吗?有问题给我留言好了void CFashionWnd::OnMoving(UINT nSide, LPRECT lpRect){ long ScreenX,ScreenY; CRect WndRect; CRect RealRect; CPoint CursorPos; int nSnaping=0; ScreenX=GetSystemMetrics(SM_CXSCREEN); ScreenY=GetSystemMetrics(SM_CYSCREEN); GetCursorPos(&CursorPos); GetWindowRect(&WndRect); RealRect.left = CursorPos.x - m_CursorOffset.cx; RealRect.right = RealRect.left + (WndRect.right - WndRect.left); RealRect.top = CursorPos.y - m_CursorOffset.cy; RealRect.bottom = RealRect.top + (WndRect.bottom - WndRect.top); //left edge if(abs(RealRect.left) < m_SnapDist) { lpRect->left = 0; lpRect->right = (WndRect.right - WndRect.left); nSnaping=1; } else { lpRect->left = RealRect.left; lpRect->right = RealRect.right; } //top edge if(abs(RealRect.top) < m_SnapDist) { lpRect->top = 0; lpRect->bottom = (WndRect.bottom - WndRect.top); nSnaping=2; } else { lpRect->top = RealRect.top; lpRect->bottom = RealRect.bottom; } //right edge if(abs(ScreenX - RealRect.right) < m_SnapDist) { lpRect->right = ScreenX; lpRect->left = lpRect->right - (WndRect.right - WndRect.left); nSnaping=1; } else { if(nSnaping!=1 && nSnaping!=2) { lpRect->left = RealRect.left; lpRect->right = RealRect.right; } } //bottom edge if(abs(ScreenY - RealRect.bottom) < m_SnapDist) { lpRect->bottom = ScreenY; lpRect->top = lpRect->bottom - (WndRect.bottom - WndRect.top); nSnaping=2; } else { if(nSnaping!=1 && nSnaping!=2) { lpRect->top = RealRect.top; lpRect->bottom = RealRect.bottom; } }} 注:m_SnapDist为自定义的吸引距离,随便啦 【请教】 如何判定串口发送完成 ? vc实现计算器backspace功能 问个关于session的问题 打开一个txt文件 有几个函数 获得一个已打开的文本文件(openfile.txt),并把里面的内容输出到新的文本文件中(new.txt) 怎么由文件路径C:\dd\fp\tt.exe得到文件名称tt.exe WSPConnect與WSAConnect有什麽區別麽 如何用socket连接到代理后面的机器? 大哥帮忙 为什么建立的dc是单色的? 关于计数器 文件操作的怪事
BOOL AdjustPos(CRect* lpRect)
{//自动靠边
int iSX=GetSystemMetrics(SM_CXFULLSCREEN);
int iSY=GetSystemMetrics(SM_CYFULLSCREEN);
RECT rWorkArea;
BOOL bResult = SystemParametersInfo(SPI_GETWORKAREA,
sizeof(RECT),
&rWorkArea,
0);
CRect rcWA;
if(!bResult)
{//如果调用不成功就利用GetSystemMetrics获取屏幕面积
rcWA=CRect(0,0,iSX,iSY);
}
else
rcWA=rWorkArea;
int iX=lpRect->left;
int iY=lpRect->top;
if(iX < rcWA.left + DETASTEP && iX!=rcWA.left)
{//调整左
//pWnd->SetWindowPos(NULL,rcWA.left,iY,0,0,SWP_NOSIZE);
lpRect->OffsetRect(rcWA.left-iX,0);
AdjustPos(lpRect);
return TRUE;
}
if(iY < rcWA.top + DETASTEP && iY!=rcWA.top)
{//调整上
//pWnd->SetWindowPos(NULL ,iX,rcWA.top,0,0,SWP_NOSIZE);
lpRect->OffsetRect(0,rcWA.top-iY);
AdjustPos(lpRect);
return TRUE;
}
if(iX + lpRect->Width() > rcWA.right - DETASTEP && iX !=rcWA.right-lpRect->Width())
{//调整右
//pWnd->SetWindowPos(NULL ,rcWA.right-rcW.Width(),iY,0,0,SWP_NOSIZE);
lpRect->OffsetRect(rcWA.right-lpRect->right,0);
AdjustPos(lpRect);
return TRUE;
}
if(iY + lpRect->Height() > rcWA.bottom - DETASTEP && iY !=rcWA.bottom-lpRect->Height())
{//调整下
//pWnd->SetWindowPos(NULL ,iX,rcWA.bottom-rcW.Height(),0,0,SWP_NOSIZE);
lpRect->OffsetRect(0,rcWA.bottom-lpRect->bottom);
return TRUE;
}
return FALSE;
}
{
long ScreenX,ScreenY;
CRect WndRect;
CRect RealRect;
CPoint CursorPos;
int nSnaping=0; ScreenX=GetSystemMetrics(SM_CXSCREEN);
ScreenY=GetSystemMetrics(SM_CYSCREEN);
GetCursorPos(&CursorPos);
GetWindowRect(&WndRect); RealRect.left = CursorPos.x - m_CursorOffset.cx;
RealRect.right = RealRect.left + (WndRect.right - WndRect.left);
RealRect.top = CursorPos.y - m_CursorOffset.cy;
RealRect.bottom = RealRect.top + (WndRect.bottom - WndRect.top); //left edge
if(abs(RealRect.left) < m_SnapDist)
{
lpRect->left = 0;
lpRect->right = (WndRect.right - WndRect.left);
nSnaping=1;
}
else
{
lpRect->left = RealRect.left;
lpRect->right = RealRect.right;
}
//top edge
if(abs(RealRect.top) < m_SnapDist)
{
lpRect->top = 0;
lpRect->bottom = (WndRect.bottom - WndRect.top);
nSnaping=2;
}
else
{
lpRect->top = RealRect.top;
lpRect->bottom = RealRect.bottom;
} //right edge
if(abs(ScreenX - RealRect.right) < m_SnapDist)
{
lpRect->right = ScreenX;
lpRect->left = lpRect->right - (WndRect.right - WndRect.left);
nSnaping=1;
}
else
{
if(nSnaping!=1 && nSnaping!=2)
{
lpRect->left = RealRect.left;
lpRect->right = RealRect.right;
}
} //bottom edge
if(abs(ScreenY - RealRect.bottom) < m_SnapDist)
{
lpRect->bottom = ScreenY;
lpRect->top = lpRect->bottom - (WndRect.bottom - WndRect.top);
nSnaping=2;
}
else
{
if(nSnaping!=1 && nSnaping!=2)
{
lpRect->top = RealRect.top;
lpRect->bottom = RealRect.bottom;
}
}
}