问问题
3050 次
2 回答
1
注意:未经测试的代码 - 其中一些是伪代码,但它应该为您提供 IDEA:
inline BOOL MoveWindow(HWND hwnd, const RECT & rect, BOOL bRepaint)
{
return ::MoveWindow(hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
}
void CDrawToolView::LoadPic(CString strPicPath)
{
if(!m_MyImage.IsNull())
m_MyImage.Destroy();
HRESULT hResult=m_MyImage.Load(strPicPath);
int iWidth=m_MyImage.GetWidth();
int iHeight=m_MyImage.GetHeight();
CRect client(0, 0, iWidth, iHeight);
AdjustWindowRect(&client, GetWindowStyle(GetHwnd()), TRUE/FALSE); // You will need to write the helper: GetWindowStyle, or replace this with more statements to obtain the style into a DWORD and then use that DWORD here...
ResizeWindow(GetHwnd(), &client, TRUE);
}
于 2013-09-16T17:01:01.343 回答
1
要在创建窗口之前将所需的窗口尺寸调整为特定的客户端大小,您需要调用AdjustWindowRect
或AdjustWindowRectEx
。
从文档中:
根据客户矩形的所需大小计算窗口矩形的所需大小。
所需的窗口样式和扩展的窗口样式可通过CREATESTRUCT
成员style
和获得dwExStyle
。
于 2013-09-16T13:50:29.797 回答