Beispiel #1
0
/*
 * Initialize the plugin. Called the first time the browser comes across a
 * MIME Type this plugin is registered to handle.
 */
NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs)
{

// _asm {int 3};

	if(pFuncs == NULL)
		return NPERR_INVALID_FUNCTABLE_ERROR;

#ifdef NDEF
  // The following statements prevented usage of newer Mozilla sources than installed browser at runtime
	if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
		return NPERR_INCOMPATIBLE_VERSION_ERROR;

	if(pFuncs->size < sizeof(NPNetscapeFuncs))
		return NPERR_INVALID_FUNCTABLE_ERROR;
#endif

	if (!AtlAxWinInit()) {

		return NPERR_GENERIC_ERROR;
	}

	CoInitialize(NULL);

	_pAtlModule = &_Module;

	memset(&NPNFuncs, 0, sizeof(NPNetscapeFuncs));
	memcpy(&NPNFuncs, pFuncs, MIN(pFuncs->size, sizeof(NPNetscapeFuncs)));

	return NPERR_NO_ERROR;
}
Beispiel #2
0
HRESULT CMainModule::PreMessageLoop( int nCmdShow )
{
	HRESULT hr = S_OK;

	if( SUCCEEDED(hr) ) {
	    hr = CAtlExeModuleT<CMainModule>::PreMessageLoop( nCmdShow );
	}

	if( SUCCEEDED(hr) ) {
		hr = setIeEmulation();
	}

	if( SUCCEEDED(hr) ) {
		hr = regClass();
	}

	if( SUCCEEDED(hr) )
	{
		AtlAxWinInit();
		RECT rect = { 200, 200, 920, 831 };
		m_wndMain.Create(NULL, rect, L"Trident Host", WS_OVERLAPPED | WS_SYSMENU | WS_THICKFRAME, 0 );
		if( m_wndMain.m_hWnd == NULL ) {
			hr = HRESULT_FROM_WIN32( GetLastError() );
		}
	}

	if( SUCCEEDED(hr) ) {
	    m_wndMain.ShowWindow(nCmdShow);
	}

	return hr;
}
Beispiel #3
0
//==============================================
int g_InitActX_Control( HWND hWnd) {
    IUnknown * pUnk;
    IUnknown * pUnkCont;
    HRESULT hRet;


    x_pIFactory = new CFactory();
    if( x_pIFactory == NULL) return 2;

    hRet = CoRegisterClassObject( CLSID_CP_TimeSyncClass,     //Class identifier (CLSID) to be registered
                                  x_pIFactory,     //Pointer to the class object
                                  CLSCTX_LOCAL_SERVER,  //Context for running executable code
                                  REGCLS_MULTIPLEUSE,  // multiple clients for the same server, we do not start a new server for each client
                                  &x_dwRegister ); //Save registered object info, for future release by CoRevokeClassObject()
    if( hRet != S_OK)  return 3;


    // Initialize ATL control containment code.
    AtlAxWinInit();
    // Create ActiveX control using the window handle
    // and get the IUnknown interface of this control
    hRet = AtlAxCreateControlEx( OLESTR("RPco.X"), hWnd, NULL,
                                 &pUnkCont, &pUnk, IID_NULL, NULL );

    // Obtain smart pointer to TDevAccX using IUnknown of the control
    g_pRPcoX = pUnk;
    pUnk->Release();

    return 0;
}
Beispiel #4
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = CMiniPieFrame::ActivatePreviousInstance(hInstance, lpstrCmdLine);

	if(FAILED(hRes) || S_FALSE == hRes)
	{
		return hRes;
	}

	hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	AtlInitCommonControls(ICC_DATE_CLASSES);
	SHInitExtraControls();

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	AtlAxWinInit();

	int nRet = CMiniPieFrame::AppRun(lpstrCmdLine, nCmdShow);

	AtlAxWinTerm();

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Beispiel #5
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
#ifdef _DEBUG
	::_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);	// add flags to support other controls

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	AtlAxWinInit();

	int nRet = Run(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Beispiel #6
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);	// add flags to support other controls
	HINSTANCE hInstRich = ::LoadLibrary(CRichEditCtrl::GetLibraryName());

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	AtlAxWinInit();

	int nRet = 0;
	// BLOCK: Run application
	{
		CBoggleThreadManager mgr;
		nRet = mgr.Run(lpstrCmdLine, nCmdShow);
	}

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Beispiel #7
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

#if (_WIN32_IE >= 0x0300)
	INITCOMMONCONTROLSEX iccx;
	iccx.dwSize = sizeof(iccx);
	iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
	BOOL bRet = ::InitCommonControlsEx(&iccx);
	bRet;
	ATLASSERT(bRet);
#else
	::InitCommonControls();
#endif

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	AtlAxWinInit();

	int nRet = Run(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Beispiel #8
0
static void test_ax_win(void)
{
    BOOL ret;
    WNDCLASSEXW wcex;
    static const WCHAR AtlAxWin100[] = {'A','t','l','A','x','W','i','n','1','0','0',0};
    static const WCHAR AtlAxWinLic100[] = {'A','t','l','A','x','W','i','n','L','i','c','1','0','0',0};
    static HMODULE hinstance = 0;

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

    hinstance = GetModuleHandleA(NULL);

    memset(&wcex, 0, sizeof(wcex));
    wcex.cbSize = sizeof(wcex);
    ret = GetClassInfoExW(hinstance, AtlAxWin100, &wcex);
    ok(ret, "AtlAxWin100 has not registered\n");
    ok(wcex.style == (CS_GLOBALCLASS | CS_DBLCLKS), "wcex.style %08x\n", wcex.style);

    memset(&wcex, 0, sizeof(wcex));
    wcex.cbSize = sizeof(wcex);
    ret = GetClassInfoExW(hinstance, AtlAxWinLic100, &wcex);
    ok(ret, "AtlAxWinLic100 has not registered\n");
    ok(wcex.style == (CS_GLOBALCLASS | CS_DBLCLKS), "wcex.style %08x\n", wcex.style);
}
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::OleInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_WIN95_CLASSES);	// add flags to support other controls

#if _ATL_VER < 0x0700
    hRes = _Module.Init(NULL, hInstance);
#else
    hRes = _Module.Init(NULL, hInstance, &LIBID_ATLLib);
#endif

	ATLASSERT(SUCCEEDED(hRes));

	AtlAxWinInit();

	int nRet = Run(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::OleUninitialize(); 

	return nRet;
}
Beispiel #10
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
//	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);	// add flags to support other controls

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	AtlAxWinInit();

	int nRet = 0;
	
	BOOL bFirstInst = CSingleInstApp::InitInstance(APP_INST_UID);
	if (!bFirstInst) {

		if (::lstrcmpi(_T("/exit"), lpstrCmdLine) == 0) {

			CSingleInstApp::PostInstanceMesage(AIMSG_EXIT, 0);
			nRet = 251;

		} else if (::lstrcmpi(_T("/restart"), lpstrCmdLine) == 0) {

			CSingleInstApp::PostInstanceMesage(AIMSG_EXIT, 0);
			CSingleInstApp::WaitInstance(APP_INST_UID);
			nRet = Run(lpstrCmdLine, nCmdShow);
			CSingleInstApp::InitInstance(APP_INST_UID);

		} else {

			CSingleInstApp::PostInstanceMesage(AIMSG_POPUP, 0);
			nRet = 250;
		}

		//		ATOM atCmdLine = ::GlobalAddAtom(lpstrCmdLine);
		//		if (NULL != atCmdLine) {
		//		}


	} else {

		nRet = Run(lpstrCmdLine, nCmdShow);

	}

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
void Win32WebControl::lazyInit()
{
    // reset the main windows style so that its drawing does not cover the webview sub window
    HWND hwnd = cocos2d::Director::getInstance()->getOpenGLView()->getWin32Window();
    LONG style = GetWindowLong(hwnd, GWL_STYLE);
    SetWindowLong(hwnd, GWL_STYLE, style | WS_CLIPCHILDREN);

    HINSTANCE hInstance = GetModuleHandle(NULL);
    CoInitialize(NULL);
    s_module.Init(NULL, hInstance);
    AtlAxWinInit();
}
Beispiel #12
0
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;
}
Beispiel #13
0
/*!
\brief Creates a XCP control container
@param[in]	hWnd	Already created control container.  Static control.
\retval HANDLE	XcpControlHost
*/
HRESULT LoAgXcpCreateControl( HWND hWnd ) 
{
	AtlAxWinInit();

	HRESULT hr;
	static const GUID IID_IXcpControl = { 0x1FB839CC, 0x116C, 0x4C9B, { 0xAE, 0x8E, 0x3D, 0xBB, 0x64, 0x96, 0xE3, 0x26 }};
	static const GUID CLSID_XcpControl = { 0xDFEAF541, 0xF3E1, 0x4c24, { 0xAC, 0xAC, 0x99, 0xC3, 0x07, 0x15, 0x08, 0x4A }};
	static const GUID IID_IXcpControl2 = { 0x1c3294f9, 0x891f, 0x49b1, { 0xBB, 0xAE, 0x49, 0x2a, 0x68, 0xBA, 0x10, 0xcc }};

	//	static const GUID CLSID_XcpControl2 = 
	//		{ 0xDFEAF541, 0xF3E1, 0x4c24, { 0xAC, 0xAC, 0x99, 0xC3, 0x07, 0x15, 0x08, 0x4A }};

	//static const GUID IID_IXcpControlHost2 = 
	//	{ 0xfb3ed7c4, 0x5797, 0x4b44, { 0x86, 0x95, 0x0c, 0x51, 0x2e, 0xa2, 0x7D, 0x8f }};

	hr = CoCreateInstance(CLSID_XcpControl, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&CXcpControlHost::pUnKnown);

	if (SUCCEEDED(hr)) 
	{
		//CComPtr<IUnknown> spUnkContainer;
		IUnknown	*spUnkContainer = NULL;
		//CoCreateInstance( __uuidof(IUnknown), &CXcpControlHost::pUnKnown, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&spUnkContainer );
		hr = CXcpControlHost::_CreatorClass::CreateInstance(NULL, IID_IUnknown, (void**)&spUnkContainer);
		
		if (SUCCEEDED(hr)) 
		{
			//CComPtr<IAxWinHostWindow> pAxWindow;
			IAxWinHostWindow	*pAxWindow = NULL;

			spUnkContainer->QueryInterface(IID_IAxWinHostWindow, (void**)&pAxWindow);
			if( NULL != pAxWindow )
			{
				CXcpControlHost::pUnKnown->QueryInterface(IID_IXcpControl2, (void**)&CXcpControlHost::pControl);
				hr = pAxWindow->AttachControl(CXcpControlHost::pUnKnown, hWnd);            
			}
			CXcpControlHost::hControlWindow = hWnd;

			IOleInPlaceActiveObject *pObj;
			hr = CXcpControlHost::pControl->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pObj);
			spUnkContainer->Release();
		}
	}
	return hr;
}
Beispiel #14
0
LRESULT CMainFrame::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CRect rect;

	AtlAxWinInit();
	
	// create command bar window
	HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
	// atach menu
	m_CmdBar.AttachMenu(GetMenu());
	// load command bar images
	m_CmdBar.LoadImages(IDR_MAINFRAME);
	// remove old menu
	SetMenu(NULL);

	HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);

	CreateSimpleReBar(ATL_SIMPLE_REBAR_STYLE);
	AddSimpleReBarBand(hWndCmdBar);
	AddSimpleReBarBand(hWndToolBar, NULL, TRUE);

	CreateSimpleStatusBar();
	m_sbar.SubclassWindow(m_hWndStatusBar);
	
	m_sbar.SetPanes(arrParts, sizeof(arrParts) / sizeof(int), false);

	GetClientRect(&rect);
	m_hWndClient = m_wndScriptEidor.Create(m_hWnd, rect, _T(""), 
		WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);

	m_spScriptEditor.CoCreateInstance(CLSID_CxScriptEditor);

	CComPtr<IAxWinHostWindow> spContainer;
	m_wndScriptEidor.QueryHost(&spContainer);
	// Attach the browser control to the container
	spContainer->AttachControl(m_spScriptEditor, m_wndScriptEidor);

	DispEventAdvise(m_spScriptEditor);

	UIAddToolBar(hWndToolBar);
	UISetCheck(ID_VIEW_SYMBOL, 1);

	return 0;
}
Beispiel #15
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR pCmdLine, int nCmdShow)
{
	AtlAxWinInit();
	_Module.Init(ObjectMap, hInstance);
	MSG msg;
	WNDCLASS wndclass = {
		0,
		WndProc,
		0,
		0,
		hInstance,
		0,
		LoadCursor(0, IDC_ARROW),
		0,
		0,
		szClassName
	};
	RegisterClass(&wndclass);
	HWND hWnd = CreateWindow(
		szClassName,
		TEXT("SVG画像表示"),
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		0,
		CW_USEDEFAULT,
		0,
		0,
		0,
		hInstance,
		0
	);
	ShowWindow(hWnd, SW_SHOWDEFAULT);
	UpdateWindow(hWnd);
	while (GetMessage(&msg, 0, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	_Module.Term();
	AtlAxWinTerm();
	return (int)msg.wParam;
}
Beispiel #16
0
//==============================================================================
int CTimeSync::Initialize( HWND hWnd ){

  IUnknown * pUnk;
  IUnknown * pUnkCont;
  HRESULT hRet;

  // Initialize ATL control containment code.
  AtlAxWinInit(); 
  // Create ActiveX control using the window handle 
  // and get the IUnknown interface of this control
  hRet = AtlAxCreateControlEx( OLESTR("RPco.X"), hWnd, NULL, 
                                      &pUnkCont, &pUnk, IID_NULL, NULL );

  // Obtain smart pointer to TDevAccX using IUnknown of the control
  m_pTDev = pUnk;
  pUnk->Release();
//  m_InitTimerThread();
  m_iState = ecInitialized;
  return 0;
}
Beispiel #17
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_USEREX_CLASSES);

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	AtlAxWinInit();

	int nRet = Run(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Beispiel #18
0
int WINAPI _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpstrCmdLine,int nCmdShow){
  /*
  string url="http://s201.uu.avgarden.com|http://s200.uu.avgarden.com|http://s101.uu.avgarden.com|http://s300.uu.avgarden.com|http://s301.uu.avgarden.com|http://s100.uu.avgarden.com|http://s4.avgarden.net|http://s3.avgarden.net|http://uu2.avgarden.net|http://uu3.avgarden.net|http://o0i0o.avgarden.net|http://uu1.avgarden.net|http://f1.uu.lishaochang.com|http://x.uu.lishaochang.com|http://y.uu.lishaochang.com|http://z.uu.lishaochang.com|http://f2.uu.lishaochang.com|http://f3.hh.lishaochang.com|http://5.s5.uufile.com|http://o0i0o.uufile.com|http://3.s3.uufile.com|http://4.s4.uufile.com|http://2.s2.uufile.com|http://1.s1.uufile.com|http://u.uufile.net|http://8.uufile.net|http://i.uufile.net|http://9.uufile.net|http://o.uufile.net|http://0.uufile.net|http://bbs.uugarden.com|http://bbs2.uugarden.com|http://u2.s1.uugarden.com|http://u1.s1.uugarden.com|http://bbs.uugarden.net|http://f1.gg.uugarden.net|http://f2.gg.uugarden.net|http://f3.hh.uugarden.net|http://f3.gg.uugarden.net|http://www.uugarden.net|http://bbs.uugarden.net|http://www.uugarden.net|http://f1.gg.uugarden.net|http://f2.gg.uugarden.net|http://f3.hh.uugarden.net|http://f3.gg.uugarden.net";
  string encoded = base64_encode(reinterpret_cast<const unsigned char*>(url.c_str()), (unsigned int)url.length());
  FILE * pFile;
  pFile = fopen ("c:\\urls.txt","w");
  if (pFile!=NULL){
    fputs (encoded.c_str(),pFile);
    fclose (pFile);
  }
  string decoded = base64_decode(encoded);*/

  HRESULT hRes = ::CoInitialize(NULL);
  ::DefWindowProc(NULL, 0, 0, 0L);
  AtlInitCommonControls(ICC_BAR_CLASSES);
  hRes = _Module.Init(NULL, hInstance);

  AtlAxWinInit();
  int nRet = Run(lpstrCmdLine, nCmdShow);
  _Module.Term();
  ::CoUninitialize();
  return nRet;
}
Beispiel #19
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;
}
HRESULT InitIEStuff (WebShellInitContext * initContext)
{
    HRESULT hr;
    HWND m_hWndClient;
    RECT rect;

    CMyDialog *bObj = initContext->browserObject;

    HRESULT hRes = CoInitializeEx(NULL,  COINIT_APARTMENTTHREADED);
    ATLASSERT(SUCCEEDED(hRes));

/*if (_WIN32_IE >= 0x0300)
	INITCOMMONCONTROLSEX iccx;
	iccx.dwSize = sizeof(iccx);
	iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
	BOOL bRet = ::InitCommonControlsEx(&iccx);
	bRet;
	ATLASSERT(bRet);
#else
*/
//  ::InitCommonControls();
//#endif

    GetClientRect(initContext->parentHWnd, &rect);

    HINSTANCE newInst = GetModuleHandleA(NULL);
    hRes = _Module.Init(NULL, newInst);
    ATLASSERT(SUCCEEDED(hRes));

    AtlAxWinInit();

    m_hWndClient = bObj->Create(initContext->parentHWnd,
				rect,
				_T("about:blank"),
				WS_CHILD | WS_VISIBLE |
				   WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
				   WS_VSCROLL | WS_HSCROLL,
				WS_EX_CLIENTEDGE,
				ID_WEBBROWSER);

    hr = bObj->QueryControl(&(initContext->browserObject->m_pWB));

    if FAILED(hr)
    {
	ATLTRACE(_T("Couldn't retrieve webbrowser"));
	return (-1);
    }

    if SUCCEEDED(hr)
    {
	ATLTRACE(_T("Browser successfully retrieved"));
    }

    initContext->browserHost = m_hWndClient;

    if (!bObj->spUnk) {
	hr = bObj->QueryControl(&(bObj->spUnk));
	hr = bObj->DispEventAdvise(bObj->spUnk);
    }

    if FAILED(hr)
    {
	ATLTRACE(_T("Couldn't establish connection points"));
	return -1;
    }

    hr = bObj->m_pWB->QueryInterface(IID_IServiceProvider,
                                     (void**)&(bObj->m_pISP));

    if (FAILED(hr) || (bObj->m_pISP == NULL))
    {
	ATLTRACE(_T("Couldn't obtain COM IServiceProvider"));
	return -1;
    }

    hr = bObj->m_pISP->QueryService(SID_STravelLogCursor,
                                    IID_ITravelLogStg,
				    (void**)&(bObj->m_pTLStg));

    if (FAILED(hr) || (bObj->m_pTLStg == NULL))
    {
	ATLTRACE(_T("Couldn't obtain ITravelLog interface"));
	return -1;
    }

    processEventLoop(initContext);

    return 0;
}
Beispiel #21
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;
}
/*!
	ウインドウを作成
	@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;
}
/***********************************************************************
* OnInitDialog
* 
* Initialize member variables of handlers
* Initialize WMP OCX
***********************************************************************/
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    ::InitCommonControls();
    AtlAxWinInit();
    
    // dialog items
    m_hLibTree = GetDlgItem(IDC_TREE);
    m_hDetailList = GetDlgItem(IDC_DETAILLIST);
    
    // Create a WMP OCX
    CreateWmpOcx();
    
    // Fill in combo box for media type
    HWND    hMediaTypeList = GetDlgItem(IDC_MEDIATYPELIST);
    SendMessage(hMediaTypeList, CB_ADDSTRING, 0, (LPARAM)L"Music");
    SendMessage(hMediaTypeList, CB_ADDSTRING, 0, (LPARAM)L"Pictures");
    SendMessage(hMediaTypeList, CB_ADDSTRING, 0, (LPARAM)L"Video");
    SendMessage(hMediaTypeList, CB_ADDSTRING, 0, (LPARAM)L"Playlists");
    SendMessage(hMediaTypeList, CB_ADDSTRING, 0, (LPARAM)L"Other Media");
    SendMessage(hMediaTypeList, CB_SETCURSEL, 0, (LPARAM)m_mtCurMediaType);
    
    // Use IWMPLibraryServices to enumerate the libries and fill in combo box
    HRESULT                         hr = E_POINTER;
    LONG                            lLibCount = 0;
    HWND                            hLibList = GetDlgItem(IDC_LIBLIST);
    CComPtr<IWMPLibraryServices>    spLibSvc;
    
    if(m_spPlayer != NULL)
    {
        hr = m_spPlayer->QueryInterface(&spLibSvc);
    }
    if(SUCCEEDED(hr) && spLibSvc)
    {
        hr = spLibSvc->getCountByType(wmpltAll, &lLibCount);
    }
    if(SUCCEEDED(hr))
    {
        for(LONG i = 0; i < lLibCount; i++)
        {
            CComPtr<IWMPLibrary>    spLib;
            CComBSTR                bstrLibName;
            
            hr = spLibSvc->getLibraryByType(wmpltAll, i , &spLib);
            if(SUCCEEDED(hr) && spLib)
            {
                hr = spLib->get_name(&bstrLibName);
            }
            if(SUCCEEDED(hr))
            {
                SendMessage(hLibList, CB_ADDSTRING, 0, (LPARAM)bstrLibName.m_str);
            }
        }
    }
    SendMessage(hLibList, CB_SETCURSEL, 0, 0);
    
    // Set WordWheel text to Search...
    SetDlgItemText(IDC_WORDWHEEL, L"Search...");
    
    // Set m_spMC to correct mediaCollection of currently selected library
    UpdateCurMC();

    // Now we try to build the tree
    BuildLibTree();
    
    return 0;
}
Beispiel #24
0
HRESULT CBrowserModule::PreMessageLoop(int nShowCmd) throw()
{
    HRESULT hr = 0;
    RECT rc = {0, 0, 0, 0};
    DWORD dwExStyle = 0;
    DWORD dwStyle = 0;
    char szWindowTitle[256];
    char szWindowInfo[256];
    char szDebuggingInfo[256];
    int iWebServerPort = 0;
    char szWebServerUsername[256];
    char szWebServerPassword[256];


	hr = __super::PreMessageLoop(nShowCmd);
	if (FAILED(hr)) {
        return hr;
	}

    // Initialize ATL Window Classes
    //
    AtlAxWinInit();

    // Prepare environment for web browser control
    //
    RegisterWebControlCompatiblity();

    // Prepare environment for detecting system conditions
    //
    boinc_parse_init_data_file();

    // Initialize Web Server
    //
    _snprintf(szWebServerUsername, sizeof(szWebServerUsername)-1, "%d", GetCurrentThreadId());
    _snprintf(szWebServerPassword, sizeof(szWebServerPassword)-1, "%d", GetCurrentThreadId());
    boinc_get_port(false, iWebServerPort);
    webserver_initialize(iWebServerPort, szWebServerUsername, szWebServerPassword, m_bDebugging);
        
    // Create Window Instance
    //
    m_pWnd = new CHTMLBrowserWnd();
	if (m_pWnd == NULL)
	{
		__super::PostMessageLoop();
		return E_OUTOFMEMORY;
	}

    // Store a copy of APP_INIT_DATA for future use
    //
    boinc_get_init_data(m_pWnd->aid);

    // Store web server information for future use
    //
    m_pWnd->m_iWebServerPort = iWebServerPort;
    m_pWnd->m_strWebServerUsername = szWebServerUsername;
    m_pWnd->m_strWebServerPassword = szWebServerPassword;

    // Construct the window caption
    //
    if (m_pWnd->aid.app_version) {
        snprintf(
            szWindowInfo, sizeof(szWindowInfo),
            "%s version %.2f [workunit: %s]",
            m_pWnd->aid.app_name, m_pWnd->aid.app_version/100.0, m_pWnd->aid.wu_name
        );
    } else {
        snprintf(
            szWindowInfo, sizeof(szWindowInfo),
            "%s [workunit: %s]",
            m_pWnd->aid.app_name, m_pWnd->aid.wu_name
        );
    }

    if (m_bDebugging) {
        snprintf(szDebuggingInfo, sizeof(szDebuggingInfo), "[Web Server Port: %d]", iWebServerPort);
    } else {
        strcpy(szDebuggingInfo, "");
    }

    snprintf(szWindowTitle, sizeof(szWindowTitle)-1, "%s %s", szWindowInfo, szDebuggingInfo);

    // Determine window size and placement
    if (m_bFullscreen) {
        HDC dc = GetDC(NULL);
        rc.left = 0;
        rc.top = 0;
        rc.right = GetDeviceCaps(dc, HORZRES);
        rc.bottom = GetDeviceCaps(dc, VERTRES);
        ReleaseDC(NULL, dc);

        dwStyle = WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_POPUP;
        dwExStyle = WS_EX_APPWINDOW|WS_EX_TOPMOST;
        while(ShowCursor(false) >= 0);
    } else {
        rc.left = 0;
        rc.top = 0;
        rc.right = 1024;
        rc.bottom = 768;

        dwStyle = WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW;
        dwExStyle = WS_EX_APPWINDOW|WS_EX_WINDOWEDGE;
        while(ShowCursor(true) < 0);
    }

    // Create Window
    //
	m_pWnd->Create(GetDesktopWindow(), rc, szWindowTitle, dwStyle, dwExStyle);
	m_pWnd->ShowWindow(nShowCmd);

	return S_OK;
}
Beispiel #25
0
CIECanvas::CIECanvas(JavaVM *pJavaVM, jobject pObj): 
	m_pJavaVM(pJavaVM), m_pObj(pObj), m_dwCookie(0) {

    AtlAxWinInit();
	m_pIE4Events = new CIE4Events(this, pJavaVM, pObj);
}
Beispiel #26
0
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");
}