AutoLocateWnd.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:1k
- /*****************************************************************************************
- // 窗口自动定位
- // Copyright : Kingsoft 2003
- // Author : Wooy(Wu yue)
- // CreateTime: 2003-2-17
- *****************************************************************************************/
- #include "KWin32.h"
- #include "Wnds.h"
- #define CURSOR_HEIGHT 32
- void ALW_GetWndPosition(int& nX, int& nY, int nWidth, int nHeight,
- bool bUseInputParamPos/* = false*/,
- bool bIgnoreCursorPos/* = false*/)
- {
- int nSWidth, nSHeight;
- if (bUseInputParamPos == false)
- Wnd_GetCursorPos(&nX, &nY);
- Wnd_GetScreenSize(nSWidth, nSHeight);
-
- nX -= nWidth / 2;
- if (nX + nWidth > nSWidth)
- nX = nSWidth - nWidth;
- if (nX < 0)
- nX = 0;
- int nCentrePos;
- if (bIgnoreCursorPos == false)
- nCentrePos = (nSHeight - CURSOR_HEIGHT) / 2;
- else
- nCentrePos = nSHeight / 2;
- if (nY > nCentrePos)
- nY -= nHeight;
- else if (bIgnoreCursorPos == false)
- nY += CURSOR_HEIGHT;
- if (nY + nHeight > nSHeight)
- nY = nSHeight - nHeight;
- if (nY < 0)
- nY = 0;
- }