Windows Media Player 请问各位大虾如何使windows media player控件随着窗口大小而自动重绘?我尝试获取它的大小然后movewindow,但是这样不成功。希望能给出源代码,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 简单的说,就是一个对话框上放了一个windows media player控件,如何让它随着对话框大小改变而改变。 我现在在OnSize事件里能够处理其他控件例如按钮和文本框控件的大小改变,但是没有办法去动态改变windows media player的大小。 借鉴了别人的做法,他是在OnSize里面这么处理的:void CRecordHWndDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy);/////////////////listRect:CListRect listRect;////////////////对话框初始化时做了下面操作:////////CRect rectWnd; //此段代码的作用是记录窗口初始时的矩阵,便于用于缩放窗口////////GetWindowRect(&rectWnd);////////listRect.AddTail(&rectWnd);////////CWnd *pWndChild = GetWindow(GW_CHILD);////////while(pWndChild)////////{ ////////pWndChild->GetWindowRect(&rectWnd); ////////listRect.AddTail(&rectWnd); ////////pWndChild = pWndChild->GetNextWindow();////////}//////////////////////// int nCount=listRect.GetCount(); if(nCount > 0) { //m_VedioPlayer.GetWindowRect(&wmpRect); CRect rectDlgNow; GetWindowRect(&rectDlgNow); POSITION mP = listRect.GetHeadPosition(); CRect rectDlgSaved; rectDlgSaved = listRect.GetNext(mP); ScreenToClient(rectDlgSaved); ScreenToClient(rectDlgNow); float fRateScaleX = (float)(rectDlgNow.right-rectDlgNow.left)/(rectDlgSaved.right-rectDlgSaved.left); float fRateScaleY = (float)(rectDlgNow.bottom-rectDlgNow.top)/(rectDlgSaved.bottom-rectDlgSaved.top); ClientToScreen(rectDlgSaved); ClientToScreen(rectDlgNow); LOGFONT stFont; ::GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT), sizeof(stFont), &stFont); strcpy(stFont.lfFaceName,"Times New Roman"); stFont.lfHeight = (long)(fRateScaleY*14); stFont.lfWidth = (long)(fRateScaleX*7); CFont * m_pCFont; m_pCFont = new CFont; m_pCFont->CreateFontIndirect(&stFont); CRect rectChildSaved; CWnd *pWndChild = GetWindow(GW_CHILD); while(pWndChild) { rectChildSaved = listRect.GetNext(mP); rectChildSaved.left = rectDlgNow.left+(int)((rectChildSaved.left-rectDlgSaved.left)* fRateScaleX); rectChildSaved.top = rectDlgNow.top+(int)((rectChildSaved.top-rectDlgSaved.top)*fRateScaleY); rectChildSaved.right = rectDlgNow.right+(int)((rectChildSaved.right-rectDlgSaved.right)* fRateScaleX); rectChildSaved.bottom = rectDlgNow.bottom+(int)((rectChildSaved.bottom-rectDlgSaved.bottom)* fRateScaleY); ScreenToClient(rectChildSaved); pWndChild->MoveWindow(rectChildSaved); pWndChild->SetFont(m_pCFont); pWndChild = pWndChild->GetNextWindow(); }}Invalidate();}但是这么做只能让按钮等控件动态改变,却不能使window media player动态改变,不知道为什么。 使用 SetWindowPos 函数就可以void CDD2Dlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here if(m_MMPlayer.GetSafeHwnd()) { m_MMPlayer.SetWindowPos(&wndTop,0,0,cx,cy, SWP_NOZORDER); }} 这样可以吗?我的控件也不是充满在整个Dialog里面啊 响应 OnSize事件后,在里面操作。 IAxWinHostWindow CreateControl失败 怎样制作自己的控件 如何实现一次性执行多条插入语句(插入是调用存储过程,插入操作可能调用多个存储过程)? StrStrI 请问:全局变量的紧急问题 失业了~~~~ up就有分 帮帮我!!!!!!!!!!! 按键问题,谁会??? 请问高手如下编译错误怎么解决阿? 工具栏按钮怎样设置四种状态图片? 一个写文件的问题
void CRecordHWndDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
/////////////////listRect:CListRect listRect;
////////////////对话框初始化时做了下面操作:
////////CRect rectWnd; //此段代码的作用是记录窗口初始时的矩阵,便于用于缩放窗口
////////GetWindowRect(&rectWnd);
////////listRect.AddTail(&rectWnd);
////////CWnd *pWndChild = GetWindow(GW_CHILD);
////////while(pWndChild)
////////{
////////pWndChild->GetWindowRect(&rectWnd);
////////listRect.AddTail(&rectWnd);
////////pWndChild = pWndChild->GetNextWindow();
////////}
////////////////////////
int nCount=listRect.GetCount();
if(nCount > 0)
{
//m_VedioPlayer.GetWindowRect(&wmpRect);
CRect rectDlgNow;
GetWindowRect(&rectDlgNow);
POSITION mP = listRect.GetHeadPosition();
CRect rectDlgSaved;
rectDlgSaved = listRect.GetNext(mP);
ScreenToClient(rectDlgSaved);
ScreenToClient(rectDlgNow);
float fRateScaleX = (float)(rectDlgNow.right-rectDlgNow.left)/(rectDlgSaved.right-rectDlgSaved.left);
float fRateScaleY = (float)(rectDlgNow.bottom-rectDlgNow.top)/(rectDlgSaved.bottom-rectDlgSaved.top);
ClientToScreen(rectDlgSaved);
ClientToScreen(rectDlgNow);
LOGFONT stFont;
::GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT), sizeof(stFont), &stFont);
strcpy(stFont.lfFaceName,"Times New Roman");
stFont.lfHeight = (long)(fRateScaleY*14);
stFont.lfWidth = (long)(fRateScaleX*7);
CFont * m_pCFont;
m_pCFont = new CFont;
m_pCFont->CreateFontIndirect(&stFont);
CRect rectChildSaved;
CWnd *pWndChild = GetWindow(GW_CHILD);
while(pWndChild)
{
rectChildSaved = listRect.GetNext(mP);
rectChildSaved.left = rectDlgNow.left+(int)((rectChildSaved.left-rectDlgSaved.left)* fRateScaleX);
rectChildSaved.top = rectDlgNow.top+(int)((rectChildSaved.top-rectDlgSaved.top)*fRateScaleY);
rectChildSaved.right = rectDlgNow.right+(int)((rectChildSaved.right-rectDlgSaved.right)* fRateScaleX);
rectChildSaved.bottom = rectDlgNow.bottom+(int)((rectChildSaved.bottom-rectDlgSaved.bottom)* fRateScaleY);
ScreenToClient(rectChildSaved);
pWndChild->MoveWindow(rectChildSaved);
pWndChild->SetFont(m_pCFont);
pWndChild = pWndChild->GetNextWindow();
}
}
Invalidate();
}
但是这么做只能让按钮等控件动态改变,却不能使window media player动态改变,不知道为什么。
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if(m_MMPlayer.GetSafeHwnd())
{
m_MMPlayer.SetWindowPos(&wndTop,0,0,cx,cy, SWP_NOZORDER);
}
}