Ejemplo n.º 1
0
void DoPageAction(WebBrowserContainer *container, DWORD dwAction)
{
    if (!container || !container->web_browser)
        return;

    switch (dwAction)
    {
        case WB_GOBACK:
            IWebBrowser2_GoBack(container->web_browser);
            break;
        case WB_GOFORWARD:
            IWebBrowser2_GoForward(container->web_browser);
            break;
        case WB_GOHOME:
            IWebBrowser2_GoHome(container->web_browser);
            break;
        case WB_SEARCH:
            IWebBrowser2_GoSearch(container->web_browser);
            break;
        case WB_REFRESH:
            IWebBrowser2_Refresh(container->web_browser);
            break;
        case WB_STOP:
            IWebBrowser2_Stop(container->web_browser);
            break;
        case WB_PRINT:
            IWebBrowser2_ExecWB(container->web_browser, OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0);
            break;
    }
}
Ejemplo n.º 2
0
static IWebBrowser2 *create_ie_window(LPCSTR cmdline)
{
    IWebBrowser2 *wb = NULL;

    InternetExplorer_Create(NULL, &IID_IWebBrowser2, (void**)&wb);
    if(!wb)
        return NULL;

    IWebBrowser2_put_Visible(wb, VARIANT_TRUE);

    if(!*cmdline) {
        IWebBrowser2_GoHome(wb);
    }else {
        VARIANT var_url;
        DWORD len;

        if(!strncasecmp(cmdline, "-nohome", 7))
            cmdline += 7;

        V_VT(&var_url) = VT_BSTR;

        len = MultiByteToWideChar(CP_ACP, 0, cmdline, -1, NULL, 0);
        V_BSTR(&var_url) = SysAllocStringLen(NULL, len);
        MultiByteToWideChar(CP_ACP, 0, cmdline, -1, V_BSTR(&var_url), len);

        /* navigate to the first page */
        IWebBrowser2_Navigate2(wb, &var_url, NULL, NULL, NULL, NULL);

        SysFreeString(V_BSTR(&var_url));
    }

    return wb;
}