示例#1
0
//---중요!!! 다이얼로그가 액티브상태가 아니라 그려지 않으면 원래 하위 게임유아이들도 그려지지 않으나,
//---이 브라우저는 윈도우가 뜨는 것이라 꼭 액티브상태를 꺼줘야한다.
//---따라서 cDialog::SetActiveRecursive() 를 사용하라. 
//---void CItemShopDlg::SetActive( BOOL val ) 참고.
void cBrowser::SetActive(BOOL val)
{
	if(IsDisable())
	{
		return;
	}
	
	m_bActive = val;

	if(val)
	{
		// 091221 LUJ, 맵 이동 시 종종 cBrowser의 소멸자 호출 시에
		//			ATL 오류가 발생한다. m_hwndIE가 사용되지 않은
		//			핸들로 나타난다. 오류 빈도를 줄이기 위해 창을
		//			열때에만 창을 생성하도록 수정
		if(0 == m_hwndIE)
		{
			m_hwndIE = CreateWindow(
				"AtlAxWin71",
				"about:blank",
				FULLSCREEN_WITH_BLT == GAMERESRCMNGR->GetResolution().dispType ? WS_POPUP : WS_CHILD,
				int(GetAbsX()),
				int(GetAbsY()),
				GetWidth(),
				GetHeight(),
				_g_hWnd,
				0,
				GetModuleHandle(0),
				0);
			CComPtr<IUnknown> punkIE = 0;

			if(S_OK == AtlAxGetControl(
				m_hwndIE,
				&punkIE))
			{
				m_pWebBrowser = punkIE;
			}
		}

		ShowWindow(
			m_hwndIE,
			SW_SHOW);
	}
	else
	{
		if(m_hwndIE)
		{
			ShowWindow(
				m_hwndIE,
				SW_HIDE);
		}
	}
}
示例#2
0
文件: Source.cpp 项目: kenjinote/2048
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static CComQIPtr<IWebBrowser2>pWebBrowser2;
	static HWND	hBrowser;
	switch (msg)
	{
	case WM_CREATE:
		::CoInitialize(0);
		g_Module.Init(0, ((LPCREATESTRUCT)lParam)->hInstance);
		AtlAxWinInit();
		hBrowser = CreateWindow(TEXT("AtlAxWin140"), TEXT("Shell.Explorer.2"), WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 0, 0, 0, hWnd, 0, ((LPCREATESTRUCT)lParam)->hInstance, 0);
		if (hBrowser)
		{
			CComPtr<IUnknown>punkIE;
			if (AtlAxGetControl(hBrowser, &punkIE) == S_OK)
			{
				pWebBrowser2 = punkIE;
				if (pWebBrowser2)
				{
					if (SUCCEEDED(pWebBrowser2->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pOleInPlaceActiveObject)))
					{
						TCHAR szModulePath[MAX_PATH];
						GetModuleFileName(0, szModulePath, MAX_PATH);
						TCHAR szNavigateToResource[1024];
						wsprintf(szNavigateToResource, L"res://%s/%d", szModulePath, IDR_HTML1);
						pWebBrowser2->Navigate(szNavigateToResource, 0, 0, 0, 0);
						return 0;
					}
				}
			}
		}
		return -1;
	case WM_SETFOCUS:
		SetFocus(hBrowser);
		break;
	case WM_SIZE:
		MoveWindow(hBrowser, 0, 0, LOWORD(lParam), HIWORD(lParam), 0);
		break;
	case WM_DESTROY:
		pWebBrowser2.Release();
		AtlAxWinTerm();
		g_Module.Term();
		::CoUninitialize();
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}
示例#3
0
BOOL CIECanvas::Initialize(HWND hwnd, int tryMozilla) {

	hwndParent = hwnd;
	
	/*if (tryMozilla) { // Initialize using mozilla..

		hwndChild = ::CreateWindow("AtlAxWin", CLSID_MozillaBrowserString, 
			WS_CHILD|WS_VISIBLE|WS_TABSTOP, 0,0,0,0, hwnd, NULL,
			::GetModuleHandle(NULL), NULL);

		// We should try to fallback to IE if mozilla not available...

	} else { // Initialize with IE5
*/
		hwndChild = ::CreateWindow("AtlAxWin", "Shell.Explorer.1", 
			WS_CHILD|WS_VISIBLE|WS_TABSTOP, 0,0,0,0, hwnd, NULL,
			::GetModuleHandle(NULL), NULL);
/*	}*/

    IUnknown *pUnk = NULL;
    AtlAxGetControl(hwndChild, &pUnk);
    
    pUnk->QueryInterface(IID_IWebBrowser2, (void**)&m_spBrowser);

    if (m_spBrowser) {
        m_spBrowser->put_Visible(VARIANT_TRUE);

		// Set up the event sink
        BOOL bAdvised = AfxConnectionAdvise(pUnk /*m_spBrowser*/, DIID_DWebBrowserEvents2,
                                            m_pIE4Events->GetInterface(&IID_IUnknown),
                                            TRUE, &m_dwCookie);

        //printf("Advise for DWebBrowserEvents2 %s\n", bAdvised ? "succeeded" : "failed");

		m_spBrowser->Refresh();
        CComVariant ve;
        CComVariant vurl("about:blank");
		m_spBrowser->Navigate2(&vurl, &ve, &ve, &ve, &ve);
		return TRUE;
	}
	return FALSE;
}
示例#4
0
/*!
	ウインドウを作成
	@param[in]	iNowPage	プレビュりたい頁番号
	@param[in]	bForeg		非0なら再プレビューのときにフォアグランドにする・0ならしない・プレビュー開いてないなら何もしない
	@return	HRESULT	終了状態コード
*/
HRESULT PreviewVisibalise( INT iNowPage, BOOLEAN bForeg )
{
	HWND	hWnd;
	TCHAR	atBuffer[MAX_STRING];
//	UINT	iIndex;
	RECT	rect;
	RECT	tbRect;

	HRESULT	hRslt;

	CComPtr<IUnknown>	comPunkIE;	
	CComPtr<IDispatch>	pDispatch;
	CComVariant	vEmpty;
	CComVariant	vUrl( TEXT("about:blank") );

#ifdef REDRAW_ATSCROLL
	LONG	height, offhei, scrtop;
//	CComQIPtr<IHTMLWindow2>		pWindow2;
	CComQIPtr<IHTMLElement>		pElement;
	CComQIPtr<IHTMLElement2>	pElement2;
#endif

	if( ghPrevWnd )	//	已にPreview窓有ったら
	{
	//	SendMessage( ghToolWnd, TB_CHECKBUTTON, IDM_PVW_ALLVW, FALSE );

#pragma message ("全プレ書換時に、スクロールバーの位置覚えておいて、そこまでScrollさせる?")

#ifdef REDRAW_ATSCROLL
		gpWebBrowser2->get_Height( &height );	//	多分コンポーネントの高さ

		gpDocument2->get_body( &pElement );
		pElement.QueryInterface( &pElement2 );
		pElement.Release(  );

		pElement2->get_scrollHeight( &offhei );	//	全体の高さ
		pElement2->get_scrollTop( &scrtop );	//	表示位置のスクロール量
		pElement2.Release(  );

#endif

		//	内容書き換え
		if( 0 > giViewMode ){	PreviewPageWrite(  -1 );	}
		else{	PreviewPageWrite( iNowPage );	}

		gpWebBrowser2->Refresh(  );

#ifdef REDRAW_ATSCROLL
		gpDocument2->get_body( &pElement );
		pElement.QueryInterface( &pElement2 );
		pElement.Release(  );

		pElement2->get_scrollHeight( &offhei );	//	全体の高さ

		pElement2->put_scrollTop(  scrtop );	//	表示位置のスクロール量
		pElement2.Release(  );
#endif

		InvalidateRect( ghPrevWnd, NULL, TRUE );

		if( bForeg )	SetForegroundWindow( ghPrevWnd );

		return S_FALSE;
	}

	//	プレビュー開いてないときに、非フォアグランドなら何もしない
	if( !(bForeg) ){	return  E_ABORT;	}


	InitWindowPos( INIT_LOAD, WDP_PREVIEW, &rect );
	if( 0 >= rect.right || 0 >= rect.bottom )	//	幅高さが0はデータ無し
	{
		hWnd = GetDesktopWindow( );
		GetWindowRect( hWnd, &rect );
		rect.left   = ( rect.right  - PVW_WIDTH ) / 2;
		rect.top    = ( rect.bottom - PVW_HEIGHT ) / 2;
		rect.right  = PVW_WIDTH;
		rect.bottom = PVW_HEIGHT;
		InitWindowPos( INIT_SAVE , WDP_PREVIEW, &rect );	//	起動時保存
	}


	ghPrevWnd = CreateWindowEx( WS_EX_TOOLWINDOW, DOC_PREVIEW_CLASS, TEXT("IEコンポーネントによるプレビュー"),
		WS_POPUP | WS_THICKFRAME | WS_CAPTION | WS_VISIBLE | WS_SYSMENU,
		rect.left, rect.top, rect.right, rect.bottom, NULL, NULL, ghInst, NULL );

	//ツールバー作る
	ghToolWnd = CreateWindowEx( 0, TOOLBARCLASSNAME, TEXT("toolbar"),
		WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TOOLTIPS | CCS_NODIVIDER,
		0, 0, 0, 0, ghPrevWnd, (HMENU)IDW_PVW_TOOL_BAR, ghInst, NULL );

	//	自動ツールチップスタイルを追加
	SendMessage( ghToolWnd, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS );

	SendMessage( ghToolWnd, TB_SETIMAGELIST, 0, (LPARAM)ghPrevwImgLst );

	SendMessage( ghToolWnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(16,16) );

	SendMessage( ghToolWnd, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0 );
	//	ツールチップ文字列を設定・ボタンテキストがツールチップになる
	StringCchCopy( atBuffer, MAX_STRING, TEXT("全プレビュースタイル") );	gstTBInfo[0].iString = SendMessage( ghToolWnd, TB_ADDSTRING, 0, (LPARAM)atBuffer );

	SendMessage( ghToolWnd , TB_ADDBUTTONS, (WPARAM)TB_ITEMS, (LPARAM)&gstTBInfo );	//	ツールバーにボタンを挿入

	SendMessage( ghToolWnd , TB_AUTOSIZE, 0, 0 );	//	ボタンのサイズに合わせてツールバーをリサイズ
	InvalidateRect( ghToolWnd , NULL, TRUE );		//	クライアント全体を再描画する命令

	//	ツールバーサブクラス化が必要

	GetWindowRect( ghToolWnd, &tbRect );
	tbRect.right  -= tbRect.left;
	tbRect.bottom -= tbRect.top;
	tbRect.left = 0;
	tbRect.top  = 0;

	GetClientRect( ghPrevWnd, &rect );
	rect.top     = tbRect.bottom;
	rect.bottom -= tbRect.bottom;

	AtlAxWinInit(  );

	ghIEwnd = CreateWindowEx( 0, ATL_AX_WIN, TEXT("Shell.Explorer.2"),
		WS_CHILD | WS_VISIBLE, rect.left, rect.top, rect.right, rect.bottom,
		ghPrevWnd, (HMENU)IDW_PVW_VIEW_WNDW, ghInst, NULL );

	//	ActiveXコントロールのインターフェースを要求
	if( SUCCEEDED( AtlAxGetControl( ghIEwnd, &comPunkIE ) ) )
	{
		gpWebBrowser2 = comPunkIE;	//	ポインタに格納

		if( gpWebBrowser2 )
		{
			gpWebBrowser2->Navigate2( &vUrl, &vEmpty, &vEmpty, &vEmpty, &vEmpty );

			while( 1 )
			{
				hRslt = gpWebBrowser2->get_Document( &pDispatch );
				if( SUCCEEDED(hRslt) && pDispatch )
				{
					gpDocument2 = pDispatch;
					if( gpDocument2 ){	hRslt = S_OK;	break;	}
				}
				Sleep(100);
			}
		}
		else
		{
			NotifyBalloonExist( TEXT("IEコンポーネントを初期化出来なかったよ・・・"), TEXT("お燐からのお知らせ"), NIIF_ERROR );
			hRslt = E_ACCESSDENIED;
		}
	}

	if( SUCCEEDED(hRslt)  ){	PreviewPageWrite( iNowPage );	}

	UpdateWindow( ghPrevWnd );

	return hRslt;
}
示例#5
0
//
//  関数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的:  メイン ウィンドウのメッセージを処理します。
//
//  WM_COMMAND	- アプリケーション メニューの処理
//  WM_PAINT	- メイン ウィンドウの描画
//  WM_DESTROY	- 中止メッセージを表示して戻る
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
	int id;
	RECT rc;
	HICON hIcon;

	CComPtr<IUnknown> pfunc;

	switch (msg)
	{
	case WM_CREATE:
		//ATLコントロールコンテナコードの初期化
		//これで、ActiveXコントロールを生成できるようになる
		if(!AtlAxWinInit()){
			MessageBox(hWnd, L"初期化エラー", L"エラー", MB_OK);
		}

		//ActiveXコントロールを生成
		hMyIE = CreateWindow( L"AtlAxWin7",	//クラス名
			L"Shell.Explorer.2",	//タイトル、GUID, ProgID, URLのいずれかを指定。
								//"Shell.Explorer.2"を指定すると必要に応じてスクロールバーが出てくる
			WS_CHILD | WS_VISIBLE , 0, 0, 0, 0, 
			hWnd, (HMENU)NULL, hInst, NULL);
		if(hMyIE == NULL){
			MessageBox(hWnd, L"hMyIE Error", L"エラー", MB_OK);
		}

		//このままでは、内容が何も見えないので、作成したウインドウのハンドルを指定して
		//ATLコントロールのダイレクトインターフェースポインタを取得
		AtlAxGetControl(hMyIE, &pfunc);
		pMyBr = pfunc;	//これをコントロールインターフェースポインタに格納

		//これでpMyBrを使って直接コントロールに命令できる
		//メンバーについては、"IWebBrowser2 Interface"のヘルプを参照
		pMyBr->GoHome();	//Home画面に行く

		break;
	case WM_SIZE:
		GetClientRect(hWnd, &rc);	//親ウインドウの表示領域を取得
		//hMyIEのサイズを親ウインドウのサイズにする
		MoveWindow(hMyIE, 0, 0, rc.right - rc.left, rc.bottom - rc.top, TRUE);
		break;
	case WM_COMMAND:
		// 選択されたメニューの解析:
		switch (LOWORD(wp))
		{
		case IDM_NAVI:
			if(DialogBox(hInst, L"MYURL", hWnd, (DLGPROC)MyUrlProc) == IDOK){
				//szUrlにジャンプする
				pMyBr->Navigate(CComBSTR(szUrl), NULL, NULL, NULL, NULL);
			}
			break;
		case IDM_RELOAD:
			pMyBr->Refresh();
			break;
		case IDM_END:
			SendMessage(hWnd, WM_CLOSE, 0, 0);
			break;
		case IDM_HOME:
			pMyBr->GoHome();
			break;
		case IDM_PREVIOUS:
			pMyBr->GoBack();
			break;
		case IDM_NEXT:
			pMyBr->GoForward();
			break;
		case IDM_STOP:
			pMyBr->Stop();
			break;
		case IDM_ABOUT:
			hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INETBR));
			ShellAbout(hWnd, L"猫でもわかるブラウザ#ブラウザ Ver0.9", L"Copyright(C) 2006 粂井康孝", hIcon);
			break;
		}
		break;
	case WM_CLOSE:
		id = MessageBox(hWnd, L"終了してもよろしいですか", (LPCWSTR)szAppName, MB_YESNO | MB_ICONQUESTION);
		if (id == IDYES)
			DestroyWindow(hWnd);
		break;
	case WM_DESTROY:
		//メモリをリリースする
		pMyBr.Release();
		pfunc.Release();
		_Module.Term();
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, msg, wp, lp);
	}
	return 0;
}
示例#6
0
文件: atl.c 项目: MaddTheSane/wine
static void test_ax_win(void)
{
    DWORD ret, ret_size, i;
    HRESULT res;
    HWND hwnd;
    HANDLE hfile;
    IUnknown *control;
    WNDPROC wndproc[2] = {NULL, NULL};
    WCHAR file_uri1W[MAX_PATH], pathW[MAX_PATH];
    WNDCLASSEXW wcex;
    static HMODULE hinstance = 0;
    static const WCHAR cls_names[][16] =
    {
        {'A','t','l','A','x','W','i','n','1','0','0',0},
        {'A','t','l','A','x','W','i','n','L','i','c','1','0','0',0}
    };

    ret = AtlAxWinInit();
    ok(ret, "AtlAxWinInit failed\n");

    hinstance = GetModuleHandleA(NULL);

    for (i = 0; i < 2; i++)
    {
        memset(&wcex, 0, sizeof(wcex));
        wcex.cbSize = sizeof(wcex);
        ret = GetClassInfoExW(hinstance, cls_names[i], &wcex);
        ok(ret, "%s has not registered\n", wine_dbgstr_w(cls_names[i]));
        ok(wcex.style == (CS_GLOBALCLASS | CS_DBLCLKS), "wcex.style %08x\n", wcex.style);
        wndproc[i] = wcex.lpfnWndProc;

        hwnd = CreateWindowW(cls_names[i], NULL, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = (IUnknown *)0xdeadbeef;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res);
        ok(!control, "returned %p\n", control);
        if (control) IUnknown_Release(control);
        DestroyWindow(hwnd);

        hwnd = CreateWindowW(cls_names[i], emptyW, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = (IUnknown *)0xdeadbeef;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res);
        ok(!control, "returned %p\n", control);
        if (control) IUnknown_Release(control);
        DestroyWindow(hwnd);

        hwnd = CreateWindowW(cls_names[i], randomW, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        todo_wine ok(!hwnd, "returned %p\n", hwnd);
        if(hwnd) DestroyWindow(hwnd);

        hwnd = CreateWindowW(cls_names[i], progid1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);

        hwnd = CreateWindowW(cls_names[i], clsid1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);

        hwnd = CreateWindowW(cls_names[i], url1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);

        /* test html stream with "MSHTML:" prefix */
        hwnd = CreateWindowW(cls_names[i], mshtml1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);

        hwnd = CreateWindowW(cls_names[i], mshtml2W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);

        /* test html stream without "MSHTML:" prefix */
        hwnd = CreateWindowW(cls_names[i], mshtml3W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        todo_wine ok(!hwnd, "returned %p\n", hwnd);
        if(hwnd) DestroyWindow(hwnd);

        ret = GetTempPathW(MAX_PATH, pathW);
        ok(ret, "GetTempPath failed!\n");
        lstrcatW(pathW, html_fileW);
        hfile = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0);
        ok(hfile != INVALID_HANDLE_VALUE, "failed to create file\n");
        ret = WriteFile(hfile, html_str, sizeof(html_str), &ret_size, NULL);
        ok(ret, "WriteFile failed\n");
        CloseHandle(hfile);

        /* test C:// scheme */
        hwnd = CreateWindowW(cls_names[i], pathW, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);

        /* test file:// scheme */
        lstrcpyW(file_uri1W, fileW);
        lstrcatW(file_uri1W, pathW);
        hwnd = CreateWindowW(cls_names[i], file_uri1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);

        /* test file:// scheme on non-existent file */
        ret = DeleteFileW(pathW);
        ok(ret, "DeleteFile failed!\n");
        hwnd = CreateWindowW(cls_names[i], file_uri1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
        ok(hwnd != NULL, "CreateWindow failed!\n");
        control = NULL;
        res = AtlAxGetControl(hwnd, &control);
        ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
        ok(control != NULL, "AtlAxGetControl failed!\n");
        IUnknown_Release(control);
        DestroyWindow(hwnd);
    }
    todo_wine ok(wndproc[0] != wndproc[1], "expected different proc!\n");
}