【问题标题】:How to force-redraw IE control on WM_SIZE?如何在 WM_SIZE 上强制重绘 IE 控件?
【发布时间】:2014-09-22 18:29:34
【问题描述】:

在我的 Win32 应用程序中,我在对话框中嵌入了 Internet Explorer ActiveX 控件。当用户调整对话框大小时,我处理 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;
}

我还尝试了 MoveWindow,而不是 SetWindowPos。但是,它似乎没有任何区别。

【问题讨论】:

    标签: winapi activex


    【解决方案1】:

    我有做类似事情的代码。一个嵌入了 IE Ax 控件的对话框(以及工具栏和状态栏)。我所做的只是一个带有 bRepaint=TRUE 的 MoveWindow() 并且 IE 将重绘。

    wndIE 是我的成员 CWindow ATL 包装器,但如果您只是使用直接的 HWND,请调整 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);
    }
    

    【讨论】:

    • 感谢您的帮助。我已经用一些代码更新了我的帖子。 MoveWindow 似乎也没有刷新页面。
    猜你喜欢
    • 1970-01-01
    • 2016-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多