Beispiel #1
0
BOOL CALLBACK DlgProc(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
	IWebBrowser2* iWebBrowser;
	VARIANT varMyURL;
	CAxWindow WinContainer;
	LPOLESTR pszName = OLESTR("shell.Explorer.2");
	RECT rc;
	BOOL result = FALSE;


	switch(Msg)
	{
	case WM_INITDIALOG:
		browserEventListener.setUnloaded();
		GetClientRect(hwnd, &rc);
		WinContainer.Create(hwnd, rc, 0,WS_CHILD |WS_VISIBLE);
		WinContainer.CreateControl(pszName);
		WinContainer.QueryControl(__uuidof(IWebBrowser2),(void**)&iWebBrowser); 
		VariantInit(&varMyURL);
		varMyURL.vt = VT_BSTR; 
		varMyURL.bstrVal = SysAllocString(OLESTR("about:blank"));
		browserEventListener.Advise(hwnd, iWebBrowser);
		iWebBrowser-> Navigate2(&varMyURL,0,0,0,0);

		VariantClear(&varMyURL);
		iWebBrowser-> Release(); 
		result = TRUE;
		break;
	case WM_HTML_ACTION:
		switch (wParam)
		{
		case ACTION_COMMIT:
			EndDialog(hwnd, ACTION_COMMIT);
			result = TRUE;
			break;
		case ACTION_RETURN:
			EndDialog(hwnd, ACTION_RETURN);
			result = TRUE;
			break;
		}
		break;
	case WM_COMMAND:
		switch(wParam)
		{
		case IDCANCEL:
			EndDialog(hwnd, ACTION_RETURN);
			result = TRUE;
		}
		break;
	}

	return result;
}
    void browser_dialog::on_init_dialog ()
    {
        DlgResize_Init (true, false);
        g_dlg_pos.AddWindow (*this);

        // Query IWebBrowser2 interface
        CAxWindow ie = GetDlgItem (IDC_IE);
        if (ie.IsWindow () != TRUE || ie.QueryControl (&m_wb2) != S_OK)
            close ();
        else {
            SetWindowText (pfc::stringcvt::string_os_from_utf8 (m_title));
            navigate (m_inital_location);
            ShowWindow (SW_SHOWNORMAL);
        }
    }   
HWND CIETabProcControl::CreateControlWindow(HWND hwndParent, RECT &rcPos)
{
    CAxWindow axWin;
    HWND hwndCtrl;
    HWND hwndIE;

    hwndCtrl = Create(hwndParent, rcPos, NULL, WS_CHILD|WS_VISIBLE);

    hwndIE = axWin.Create(hwndCtrl, rcPos, L"{8856F961-340A-11D0-A96B-00C04FD705A2}", WS_CHILD|WS_VISIBLE);
    ::SetWindowPos(hwndIE, hwndCtrl, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

    g_hwndApp = hwndCtrl;

    axWin.QueryControl(IID_IWebBrowser2, (void**)&m_spInnerWebBrowser);
    if (m_spInnerWebBrowser)
    {
        WCHAR wszUrl[2048] = {0};

        m_spInnerWebBrowser->QueryInterface(IID_IOleInPlaceActiveObject, 
                                            (void**)&g_pIOleInPlaceActiveObject);

        CComPtr<IConnectionPointContainer> spConnectionPointContainer;
        m_spInnerWebBrowser->QueryInterface(IID_IConnectionPointContainer,(void**)&spConnectionPointContainer);
        if (spConnectionPointContainer)
        {
            spConnectionPointContainer->FindConnectionPoint(DIID_DWebBrowserEvents2,&m_spCP);
            if (m_spCP)
            {
                m_spCP->Advise((IDispatch*)this,&m_dwCookie);
            }
        }

        if (ExpandEnvironmentStrings(L"%programfiles%\\multiloginhelper\\help.htm", 
                                     wszUrl, 2048))
        {
            m_spInnerWebBrowser->Navigate(wszUrl, NULL, NULL, NULL, NULL);
        }
        else
        {
            m_spInnerWebBrowser->Navigate(L"www.live.com", NULL, NULL, NULL, NULL);
        }
    }

    return hwndCtrl;
}
Beispiel #4
0
LRESULT CHTMLDialogEx::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    RECT rect = {0, 0, 0, 0};

    SetWindowPos(NULL, 0, 0, m_cx, m_cy, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
    GetClientRect(&rect);
    ModifyStyleEx(WS_EX_APPWINDOW|WS_EX_CONTROLPARENT/*dwRemove*/, 0/*dwAdd*/);

    // Create the web browser control
    CAxWindow wnd;
    wnd.Create(m_hWnd, rect, m_strURL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_HSCROLL | WS_VSCROLL, 0/*WS_EX_CLIENTEDGE*/, ID_HTMLCONTROL);
    HRESULT hr = wnd.SetExternalDispatch(m_pDispatch);
    //{
    //	m_hWndCtrl = wnd.m_hWnd;
    //	ATLASSERT(::IsWindow(m_hWndCtrl));
    //	CHTMLDialogEx::m_wpOrigHtmlProc = (WNDPROC) ::SetWindowLong(m_hWndCtrl,
    //		GWL_WNDPROC, (LONG) CHTMLDialogEx::HtmlCtrlSubclassProc);
    //}

    if (m_pBrowser)
        m_pBrowser.Release();

    m_pBrowser = NULL;
    if (SUCCEEDED(hr))
    {
        hr = wnd.QueryControl(&m_pBrowser);
        if (m_pBrowser)
        {
            hr = m_pBrowser->put_RegisterAsDropTarget(VARIANT_FALSE);
            Connect(m_pBrowser);
        }
    }

    DragAcceptFiles(false);
    wnd.DragAcceptFiles(false);

    //if (m_bModal && m_pDocWnd)
    //	m_pDocWnd->SetHTMLDlgHWND(m_hWnd);

    CenterWindow();
    ShowWindow(SW_SHOW);

    return IDOK;  // Let the system set the focus
}
Beispiel #5
0
LRESULT CDownloadSkinDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	CenterWindow();
	CAxWindow wndIE = GetDlgItem(IDC_EXPLORER1);
	HRESULT hr;
	hr = wndIE.QueryControl ( &m_pWB2 );

	m_Events = new CWebBrowserEvents<CDownloadSkinDlg>(this, m_pWB2);


	if ( m_pWB2 )
    {
		CComVariant v;  // empty variant
 
		m_pWB2->Navigate ( CComBSTR("http://www.wippien.com/SkinUpdate.php"), &v, &v, &v, &v );
    }	


	SetWindowText(_Settings.Translate("Download more skins from Wippien website"));
	SetDlgItemText(IDC_S1, _Settings.Translate("Click on the skin to download and install it."));
	SetDlgItemText(ID_CANCEL, _Settings.Translate("&Cancel"));
	return FALSE;
}
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	DlgResize_Init();
	// center the dialog on the screen
	CenterWindow();

	sAppTooltip="MtConnectDboard";
	nIcon=0;

	// set icons
	HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
	SetIcon(hIconSmall, FALSE);

	// register object for message filtering and idle updates
	//CMessageLoop* pLoop = _Module.GetMessageLoop();
	CMessageLoop* pLoop = _thread->GetMessageLoop();
	
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	UIAddChildWindowContainer(m_hWnd);

	// Remove Max/Min buttons - if using TrayIcon
	DWORD style = ::GetWindowLong(this->m_hWnd, GWL_STYLE);
	style &= ~(WS_MAXIMIZEBOX); // WS_MINIMIZEBOX NOT WS_THICKFRAME
	::SetWindowLong(this->m_hWnd, GWL_STYLE, style);

	// Install tray icon
	hSmileyIcon = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME));
	hIdleIcon = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_IDLEICON));
	hStopIcon = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_STOPICON));
	hClearIcon = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_CLEARICON));
	InstallIcon(sAppTooltip, hSmileyIcon, IDR_MENU1);

	CAxWindow wndIE = GetDlgItem(IDC_EXPLORER1);
	HRESULT hr;
	hr = wndIE.QueryControl ( &m_spWebBrowser );

	if ( m_spWebBrowser )
	{
		CComVariant v;  // empty variant
		m_spWebBrowser->Navigate ( CComBSTR("about:blank"), 
			&v, &v, &v, &v );
	}
	//Handle NavigateComplete2 event from the browser, get the document  element, call DispEventAdvise(pDocument). onclick event bubbles, so you  can handle it on the document and get clicks from all contained  elements.
	//DispEventAdvise(m_spWebBrowser); 

	//Then you need to register your interface to be used proccess wide:
	hr = pGIT->RegisterInterfaceInGlobal( (IUnknown*)(IWebBrowser2*)m_spWebBrowser, IID_IWebBrowser2, &dwWebBrowserCookie);

	//std::string html = MTConnectStreamsParser().CreateHtmlDocument();
	//CHtmlTableSnapshots().SetDocumentText(m_spWebBrowser,html);


	// Icon mapping
	std::vector<HICON> icons(2);
	icons[0]=hSmileyIcon; icons[1]=hClearIcon;	StateIconMap["EXECUTING"] = icons; // flashing green
	icons[0]=hSmileyIcon; icons[1]=hSmileyIcon;	StateIconMap["IDLE"] = icons; // idle auto
	icons[0]=hStopIcon;    icons[1]=hStopIcon;	StateIconMap["STOPPED"] = icons; // stopped
	icons[0]=hStopIcon;    icons[1]=hClearIcon;	StateIconMap["FAULT"] = icons; // stopped fault

	this->SetTimer(1, 250); 

	dlgMainThead = ::GetCurrentThread();
	return TRUE;
}
LRESULT CFlashPlayerDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// center the dialog on the screen
	CenterWindow();

	// set icons
	HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
	SetIcon(hIconSmall, FALSE);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	UIAddChildWindowContainer(m_hWnd);

	if(m_applang == 2)
		m_popmenu.LoadMenu(IDR_MENU_FLASH_EN);
	else if(m_applang == 3 || m_applang == 4)
		m_popmenu.LoadMenu(IDR_MENU_FLASH_TC);
	else
		m_popmenu.LoadMenu(IDR_MENU_FLASH);

	s_uTBBC = RegisterWindowMessage(L"TaskbarButtonCreated");
	HINSTANCE user32 = GetModuleHandle(L"user32.dll");
	if(user32) ChangeWindowMessageFilterDLL = (ChangeWindowMessageFilterFunction)GetProcAddress(user32, "ChangeWindowMessageFilter");
	if(ChangeWindowMessageFilterDLL) {
		ChangeWindowMessageFilterDLL(s_uTBBC, MSGFLT_ADD);
		ChangeWindowMessageFilterDLL(WM_COMMAND, MSGFLT_ADD);
	}

	m_wndFlashPlayer.Attach(GetDlgItem(IDC_SHOCKWAVEFLASH));
	m_control.Attach(GetDlgItem(IDC_SLIDER_CONTROL));

	m_wndFlashPlayer.QueryControl(&pFlashPtr);

	m_control.SetRange(0, 100);
	m_inited = true;


	if(m_ontop)
		::SetWindowPos(this->m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
	SetTimer(0, 300, 0);

	DoDataExchange();

	LoadConfig();
	
	pFlashPtr->put_Loop(FALSE);
	if(m_playlist.GetSize() > 0) {
		m_current = 0;
		PlayFile();
		if(m_fs_init)
			FullScreen(true);
	}
	
	return TRUE;
}
bool Win32WebControl::createWebView(
    const std::function<bool (const std::string &)> &shouldStartLoading,
    const std::function<void (const std::string &)> &didFinishLoading,
    const std::function<void (const std::string &)> &didFailLoading,
    const std::function<void (const std::string &)> &onJsCallback)
{
    bool ret = false;
    IConnectionPointContainer *container = NULL;
    do
    {
        HWND hwnd = cocos2d::Director::getInstance()->getOpenGLView()->getWin32Window();
        _winContainer.Create(hwnd, NULL, NULL, WS_CHILD | WS_VISIBLE);

        HRESULT hr;
        hr = _winContainer.CreateControl(L"shell.Explorer.2");
        CC_BREAK_IF(FAILED(hr));

        hr = _winContainer.QueryControl(__uuidof(IWebBrowser2), (void **)&_webBrowser2);
        CC_BREAK_IF(FAILED(hr) || _webBrowser2 == NULL);

        _webBrowser2->put_Silent(VARIANT_TRUE);

        VARIANT var;
        VariantInit(&var);
        var.vt = VT_BSTR;
        var.bstrVal = SysAllocString(L"about:blank");
        hr = _webBrowser2->Navigate2(&var, NULL, NULL, NULL, NULL);
        SysFreeString(var.bstrVal);
        VariantClear(&var);
        CC_BREAK_IF(FAILED(hr));

        hr = _webBrowser2->QueryInterface(IID_IConnectionPointContainer, (void **)&container);
        CC_BREAK_IF(FAILED(hr));

        hr = container->FindConnectionPoint(DIID_DWebBrowserEvents2, &_connectionPoint);
        CC_BREAK_IF(FAILED(hr));

        hr = _connectionPoint->Advise(this, &_cookie);
        CC_BREAK_IF(FAILED(hr));

        hr = _webBrowser2->get_Document(&_htmlDoc);
        CC_BREAK_IF(FAILED(hr));

        ret = true;
    } while (0);

    if (!ret)
    {
        removeWebView();
    }
    if (container != NULL)
    {
        container->Release();
        container = NULL;
    }

    _shouldStartLoading = shouldStartLoading;
    _didFinishLoading = didFinishLoading;
    _didFailLoading = didFailLoading;
    _onJsCallback = onJsCallback;
    return ret;
}
Beispiel #9
0
DWORD __stdcall CreateThreadActiveX(IN void* pParam)
{
	static TCHAR szAppName[] = TEXT ("HelloWin") ;
	MSG          msg ;
	WNDCLASS     wndclass ;
	HWND         hwnd ;

	wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
	wndclass.lpfnWndProc   = WndProc ;
	wndclass.cbClsExtra    = 0 ;
	wndclass.cbWndExtra    = 0 ;
	wndclass.hInstance     = g_hInstance ;
	wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
	wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
	wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
	wndclass.lpszMenuName  = NULL ;
	wndclass.lpszClassName = szAppName ;

	//HWND hq=FindWindow(TEXT("Chrome_WidgetWin_100"),NULL);

	HWND hwndChrome=FindWindow(TEXT("Chrome_WidgetWin_1"),0);
	hwndChrome=GetParent(hwndChrome);   // ¸¸´°¿Ú

	if (!RegisterClass (&wndclass))
	{
		MessageBox (NULL, TEXT ("This program requires Windows NT!"), 
			szAppName, MB_ICONERROR) ;
		return 0 ;
	}

	hwnd = CreateWindow (szAppName,                  // window class name
		TEXT ("The Hello Program"), // window caption
		WS_CHILDWINDOW,//WS_POPUP|WS_EX_TOOLWINDOW,//WS_OVERLAPPEDWINDOW,        // window style
		200,              // initial x position
		200,              // initial y position
		400,              // initial x size
		40,              // initial y size
		//CW_USEDEFAULT,              // initial x position
		//CW_USEDEFAULT,              // initial y position
		hwndChrome,                       // parent window handle
		NULL,                       // window menu handle
		g_hInstance,                  // program instance handle
		NULL) ;                     // creation parameters


	AtlAxWinInit();

	CoInitialize(NULL);

	// The window is attached; act appropriately

	if(hwnd)
	{			

		CAxWindow wnd;
		CLSID clsid;
		LPUNKNOWN pUnkCtrl, pUnkCont;

		IDispatch* pIDsp=NULL;

		HRESULT hr =::CLSIDFromString(L"{ED75F074-4A89-40B3-844C-B28281C3FD8E}",&clsid);

		hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IUnknown,
			(void**)&pUnkCtrl);
		CComQIPtr <IPersistStreamInit> spPerStm(pUnkCtrl);
		spPerStm->InitNew();
		wnd.Attach(hwnd);
		wnd.AttachControl(pUnkCtrl, &pUnkCont);

		wnd.QueryControl(IID_IDispatch, (void**)&pIDsp);
	}
			
	ShowWindow (hwnd, SW_SHOW) ;
	UpdateWindow (hwnd) ;

	

	while (GetMessage (&msg, NULL, 0, 0))
	{
		TranslateMessage (&msg) ;
		DispatchMessage (&msg) ;
	}

	::CoUninitialize();

	return msg.wParam;
}