如何动态改变控件大小,请高手指教
void CFlashPlayerDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
m_flash.MoveWindow(0, 0, 1000, 700);
// TODO: 在此处添加消息处理程序代码
}
我在窗体上加了一个SHOCKWAVEFLASH,然后我想在窗体最大化的时候,用代码来调整flash的大小,我上面的代码要怎么修改?
我需要获得窗口大小,然后设置控件大小。
请高手指教
[解决办法]
CRect rc;
GetClientRect(&rc);
m_flash.MoveWindow(0, 0, rc.Width(), rc.Height());
[解决办法]
那正好在debug模式下调试一下啊~~
[解决办法]
我试了下,没有事的啊
[解决办法]
void CFlashPlayerDlg::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if(!m_flash.IsWindowVisible()) //防止出错
return;
m_flash.MoveWindow(0, 0, cx, cy);
}
[解决办法]
3:改变窗口或者控件大小和移动窗口或者控件位置
1:MoveWindow函数,改变窗口的大小和位置
CRect rc;
GetClientRect(&rc);
m_Button.MoveWindow(0, 0, rc.Width(), rc.Height());
2:SetWindowPos函数,可以应用Z轴方向上,改变重叠控件的显示次序。
void CWinApp::HideApplication()
{
//m_pMainWnd is the main application window, a member of CWinApp
ASSERT_VALID(m_pMainWnd);
// hide the application 's windows before closing all the documents
m_pMainWnd-> ShowWindow(SW_HIDE);
m_pMainWnd-> ShowOwnedPopups(FALSE);
// put the window at the bottom of z-order, so it isn 't activated
m_pMainWnd-> SetWindowPos(&CWnd::wndBottom, 0, 0, 0, 0,
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
}