getclientrect,getwindowrect函数
这2个函数怎么使用呢,谁能举个简单例子?返回值是什么,得到的返回值能用?谢谢,能不能举个小例子。比如说把当前窗口坐标得到,然后输出。...
这2个函数怎么使用呢,谁能举个简单例子?
返回值是什么,得到的返回值能用?
谢谢,能不能举个小例子。
比如说把当前窗口坐标得到,然后输出。 展开
返回值是什么,得到的返回值能用?
谢谢,能不能举个小例子。
比如说把当前窗口坐标得到,然后输出。 展开
展开全部
CWnd::GetClientRect
This method copies the client coordinates of the CWnd client area into the structure pointed to by lpRect. The client coordinates specify the upper-left and lower-right corners of the client area. Since client coordinates are relative to the upper-left corners of the CWnd client area, the coordinates of the upper-left corner are (0,0).
void GetClientRect(
LPRECT lpRect )
const;
Parameters
lpRect
Points to a RECT structure or a CRect object to receive the client coordinates. The left and top members will be zero. The right and bottom members will contain the width and height of the window.
Example
This is the example from the CWnd::IsIconic method.
// This code, normally emitted by the AppWizard for a dialog-based
// project for the dialog's WM_PAINT handler, it runs only if the
// window is iconic. The window erases the icon's area, then
// paints the icon referenced by m_hIcon.
if (IsIconic())
{
CPaintDC dc(this); // Device context for painting.
IconEraseBkgnd(dc);
// Center the icon in client rectangle.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon.
dc.DrawIcon(x, y, m_hIcon);
}
CWnd::GetWindowRect
This method copies the dimensions of the bounding rectangle of the CWnd object into the structure pointed to by lpRect. The dimensions are given in screen coordinates relative to the upper-left corner of the display screen. The dimensions of the caption, border, and scroll bars, if present, are included.
void GetWindowRect(
LPRECT lpRect )
const;
Parameters
lpRect
Points to a CRect object or a RECT structure that will receive the screen coordinates of the upper-left and lower-right corners.
This method copies the client coordinates of the CWnd client area into the structure pointed to by lpRect. The client coordinates specify the upper-left and lower-right corners of the client area. Since client coordinates are relative to the upper-left corners of the CWnd client area, the coordinates of the upper-left corner are (0,0).
void GetClientRect(
LPRECT lpRect )
const;
Parameters
lpRect
Points to a RECT structure or a CRect object to receive the client coordinates. The left and top members will be zero. The right and bottom members will contain the width and height of the window.
Example
This is the example from the CWnd::IsIconic method.
// This code, normally emitted by the AppWizard for a dialog-based
// project for the dialog's WM_PAINT handler, it runs only if the
// window is iconic. The window erases the icon's area, then
// paints the icon referenced by m_hIcon.
if (IsIconic())
{
CPaintDC dc(this); // Device context for painting.
IconEraseBkgnd(dc);
// Center the icon in client rectangle.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon.
dc.DrawIcon(x, y, m_hIcon);
}
CWnd::GetWindowRect
This method copies the dimensions of the bounding rectangle of the CWnd object into the structure pointed to by lpRect. The dimensions are given in screen coordinates relative to the upper-left corner of the display screen. The dimensions of the caption, border, and scroll bars, if present, are included.
void GetWindowRect(
LPRECT lpRect )
const;
Parameters
lpRect
Points to a CRect object or a RECT structure that will receive the screen coordinates of the upper-left and lower-right corners.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询