2014-09-22 124 views
0

在我的Win32應用程序中,我在對話框中嵌入了Internet Explorer ActiveX控件。當用戶調整對話框大小時,我處理WM_SIZE事件,並將IE控件的大小設置爲佔用對話框的客戶端矩形。如何在WM_SIZE上強制重繪IE控件?

儘管調整控件的大小,控件本身不會刷新。我想知道是否有一些命令我可以發送到控制刷新/重繪本身。問候。

這是我DLGPROC代碼調整:

case WM_SIZE: { 
    HWND hX = GetDlgItem(hh, IDC_EXPLORER); 
    if (hX) { 
     RECT rc = { 0 }; 
     GetClientRect(hh, &rc); 
     ::SetWindowPos(hX, 0, 0, 0, rc.right, rc.bottom, SWP_SHOWWINDOW); 
     // ::MoveWindow(hX, 0, 0, rc.right, rc.bottom, TRUE); 
    } 
    return 0; 
} 

SetWindowPos的相反,我也嘗試過的MoveWindow。但是,它似乎沒有任何區別。

回答

0

我有類似的代碼。嵌入了IE Ax控件的對話框(以及工具欄和狀態欄)。我所做的只是一個帶有bRepaint = TRUE的MoveWindow(),並且IE會重繪。

wndie是我的成員CWindow ATL包裝,但如果你只是使用直HWNDs,適應MoveWindow()。

// Common private function to handle resizing of the child windows on our browser dialog. 
void CBrowserWindow::resize_dialog_and_controls(RECT *rcClient) { 

// Tell the toolbar to resize 
m_wndToolbar.SendMessage(TB_AUTOSIZE, 0, 0); 

RECT rcTool; 
m_wndToolbar.GetClientRect(&rcTool); 
int iToolHeight = rcTool.bottom - rcTool.top; 

// Tell the statusbar to auto-size 
m_wndStatus.SendMessage(WM_SIZE, 0, 0); 

// Now get the new height of the statusbar 
RECT rcStatus; 
m_wndStatus.GetClientRect(&rcStatus); 
int iStatusHeight = rcStatus.bottom - rcStatus.top; 

// Now set the adjusted size of our IE host window 
rcClient->top += iToolHeight; 
rcClient->bottom -= iStatusHeight; 

wndIE.MoveWindow(rcClient, true); 
} 
+0

謝謝你的幫助。我用一些代碼更新了我的帖子。 MoveWindow似乎也不刷新頁面。 – Peter 2014-09-23 17:14:17