bool ISimpleDropTarget::Register(HWND hwnd)
{
	if (IsWindow(m_hwnd))
	{
		Unregister();
	}
	if (!IsWindow(hwnd)) {
		throw L"Tried to register non window for Drag&Drop!";
		return false;
	}
	HRESULT result = OleInitialize(NULL);
	if (SUCCEEDED(result)) {
		result = RegisterDragDrop(hwnd, this);
		if (SUCCEEDED(result)) {
			m_hwnd = hwnd;
			return true;
		}
		else
		{
			RevokeDragDrop(hwnd);
			OleUninitialize();
			throw L"Drag&Drop already attached to window!";
		}
	}
	else
	{
		throw L"Drag&Drop already attached to window!";
		OleUninitialize();
	}
	return false;
}
Beispiel #2
0
void Ctrl::ExitWin32()
{
	RenderAllFormats();

	OleUninitialize();

	sFinished = true;
	for(int i = 0; i < Windows().GetCount(); i++) {
		HWND hwnd = Windows().GetKey(i);
		if(hwnd)
			::DestroyWindow(hwnd);
	}
	MSG msg;
	while(PeekMsg(msg))
		if(msg.message != WM_QUIT)
			::PostQuitMessage(0);
#ifndef flagDLL
#ifndef PLATFORM_WINCE
	ELOG("ExitWin32 1");
	OverwatchEndSession.Set();
	ELOG("ExitWin32 2");
	PostMessage(OverwatchHWND, WM_USER, 0, 0);
	ELOG("ExitWin32 3");
	LLOG("Waiting for overwatch thread to finish...");
	WaitForSingleObject(OverwatchThread, INFINITE);
	ELOG("ExitWin32 4");
	LLOG("...overwatch thread finished");
#endif
#endif
}
Beispiel #3
0
int APIENTRY wWinMain(HINSTANCE hInstance,
                      HINSTANCE hPrevInstance,
                      LPWSTR    lpCmdLine,
                      int       nCmdShow)
{
  ghInstance = hInstance;
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
  UNREFERENCED_PARAMETER(nCmdShow);

  OleInitialize(0); // for system drag-n-drop

  // comment this out if you need system theming
  ::SciterSetOption(NULL,SCITER_SET_UX_THEMING,TRUE);

  auto message_pump = []() -> int {
    MSG msg;
    // Main message loop:
	  while (GetMessage(&msg, NULL, 0, 0))
	  {
  	  TranslateMessage(&msg);
		  DispatchMessage(&msg);
	  }
    return (int) msg.wParam;
  };

  int r = uimain(message_pump);

  OleUninitialize();

  return r;
	  
}
static void __cdecl StartThread(void *vContainer) {
	OleInitialize(NULL);
	DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_GROUPCHAT_CONTAINER), NULL, ContainerDlgProc, (LPARAM) vContainer);
	//MessageBox(NULL, "ChatContainer dies.", "MW", MB_OK);
	OleUninitialize();

}
Beispiel #5
0
DropHandler::~DropHandler()
{
	if (_revokeOnDestroy)
		RevokeHandler();
	if (_uninitializeOLE)
		OleUninitialize();
}
/**
 * @brief Application entry point.
 * @param hInstance - Handle to the current instance of the application.
 * @param hPrevInstance - Handle to the previous instance of the application. This parameter is always NULL.
 * @param pszCmdLine - Pointer to a null-terminated string specifying the command line for the application, excluding the program name.
 * @param nCmdShow - Specifies how the window is to be shown.
 */
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, PTSTR pszCmdLine, int nCmdShow)
{
#ifdef _CRTDBG_MAP_ALLOC
	// Watch for memory leaks.
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

	HRESULT hRes = OleInitialize(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_LISTVIEW_CLASSES | ICC_BAR_CLASSES);	// Add flags to support other controls.

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

	int nRet = Run(pszCmdLine, nCmdShow);

	_Module.Term();
	OleUninitialize();

	return nRet;
}
Beispiel #7
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
	HRESULT Hr = ::CoInitialize(NULL);
	if( FAILED(Hr) ) return 0;
	HRESULT hRes = ::OleInitialize(NULL);
	// 初始化UI管理器
	CPaintManagerUI::SetInstance(hInstance);
	// 初始化资源
	InitResource();

	::SetCurrentDirectory(CPaintManagerUI::GetInstancePath());
#ifndef _DEBUG
	CPaintManagerUI::LoadPlugin(_T("TroyControls.dll"));
#else
	CPaintManagerUI::LoadPlugin(_T("TroyControls_d.dll"));
#endif
	CMainWnd* pFrame = new CMainWnd();
	if( pFrame == NULL ) return 0;
	pFrame->Create(NULL, _T("TroyBrowser"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 990,690);
	pFrame->CenterWindow();
	pFrame->ShowModal();

	CPaintManagerUI::MessageLoop();
	OleUninitialize();
	::CoUninitialize();
	return 0;
}
Beispiel #8
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int nCmdShow)
{
	_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);

	HRESULT Hr = ::CoInitialize(NULL);
	if( FAILED(Hr) ) return 0;
	HRESULT hRes = ::OleInitialize(NULL);
	// 初始化UI管理器
	CPaintManagerUI::SetInstance(hInstance);
	// 初始化资源
	InitResource();

	CDemoFrame* pFrame = new CDemoFrame();
	if( pFrame == NULL ) return 0;
	pFrame->Create(NULL, _T("duilib使用例子集锦(By Troy)"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 800, 572);
	pFrame->CenterWindow();
	ShowWindow(*pFrame, SW_SHOW);
	CPaintManagerUI::MessageLoop();
	delete pFrame;
	pFrame = NULL;
	CResourceManager::GetInstance()->Release();

	OleUninitialize();
	::CoUninitialize();
	return 0;
}
Beispiel #9
0
// 程序入口.
int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    HRESULT hRes = OleInitialize(NULL);

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

    DemoViewDelegate delegate;

    CommandLine::Init(0, NULL);

    DemoMain main;
    main.Run();

    OleUninitialize();

    return 0;
}
Beispiel #10
0
Webbrowser::Webbrowser(void):
	_refNum(0),
	//_rcWebWnd(0),
	_bInPlaced(false),
	_bExternalPlace(false),
	_bCalledCanInPlace(false),
	_bWebWndInited(false),
	_pOleObj(NULL), 
	_pInPlaceObj(NULL), 
	_pStorage(NULL), 
	_pWB2(NULL), 
	_pHtmlDoc2(NULL), 
	_pHtmlDoc3(NULL), 
	_pHtmlWnd2(NULL), 
	_pHtmlEvent(NULL)
{
	::memset( (PVOID)&_rcWebWnd,0,sizeof(_rcWebWnd));
	HRTEST_SE( OleInitialize(0),L"Failed in Initialize Ole");
	HRTEST_SE( StgCreateDocfile(0,STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DIRECT | STGM_CREATE,0,&_pStorage),L"ERROR:StgCreateDocfile");
	HRTEST_SE( OleCreate(CLSID_WebBrowser,IID_IOleObject,OLERENDER_DRAW,0,this,_pStorage,(void**)&_pOleObj),L"Create Ole Failed");
	HRTEST_SE( _pOleObj->QueryInterface(IID_IOleInPlaceObject,(LPVOID*)&_pInPlaceObj),L"Create OleInPlaceObject Failed");
	GetWebBrowser2();
	OleUninitialize();
RETURN:

	return;
}
Beispiel #11
0
void ModuleEntry::ShutDown()
{
	ModuleEntry * pme;

	for (pme = s_pmeFirst; pme; pme = pme->m_pobjNext)
	{
		try
		{
			pme->ProcessDetach();
		}
		catch (const Throwable & thr)
		{
			WarnHr(thr.Error());
		}
		catch (...)
		{
			return WarnHr(E_FAIL);
		}
	}

	// Uninitialize COM, first shutting down the clipboard.
	if (s_qdobjClipboard.Ptr())
	{
		hr = OleIsCurrentClipboard(s_qdobjClipboard.Ptr());
		WarnHr(hr);
		if (hr == S_OK)
		{
			WarnHr(OleFlushClipboard());
		}
		s_qdobjClipboard.Clear();
	}
	OleUninitialize();
}
Beispiel #12
0
	Win32Host::~Win32Host()
	{
		if (ole_initialized)
		{
			OleUninitialize();
		}
	}
Beispiel #13
0
int CDownloadTask::Run()
{
//	if ( theApp.m_bIsVistaOrNewer )
//		::SetThreadPriority( GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN );	// Too aggressive?

	BOOL bCOM = SUCCEEDED( OleInitialize( NULL ) );

	switch ( m_nTask )
	{
	case dtaskCopy:
		RunCopy();
		break;
	case dtaskMergeFile:
		RunMerge();
		break;
	case dtaskPreviewRequest:
		RunPreviewRequest();
	//	break;
	}

	if ( bCOM )
		OleUninitialize();

	return 0;
}
bool ISimpleDropTarget::Unregister()
{
	RevokeDragDrop(m_hwnd);
	OleUninitialize();
	m_hwnd = NULL;
	return true;
}
Beispiel #15
0
void ReleaseHelpViewer(HHInfo *info)
{
    TRACE("(%p)\n", info);

    if (!info)
        return;

    /* Free allocated strings */
    heap_free(info->pszType);
    heap_free(info->pszCaption);
    heap_free(info->pszToc);
    heap_free(info->pszIndex);
    heap_free(info->pszFile);
    heap_free(info->pszHome);
    heap_free(info->pszJump1);
    heap_free(info->pszJump2);
    heap_free(info->pszUrlJump1);
    heap_free(info->pszUrlJump2);

    if (info->pCHMInfo)
        CloseCHM(info->pCHMInfo);

    ReleaseWebBrowser(info);
    ReleaseContent(info);
    ReleaseIndex(info);
    ReleaseSearch(info);

    if(info->WinType.hwndHelp)
        DestroyWindow(info->WinType.hwndHelp);

    heap_free(info);
    OleUninitialize();
}
Beispiel #16
0
int WINAPI wWinMain(HINSTANCE ins, HINSTANCE prev, LPWSTR cmd, int show)
{
   _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
   OleInitialize(NULL);

   WCHAR path [MAX_PATH];
   if(GetModuleFileNameW(NULL, path, _countof(path))) {
      PathRenameExtensionW(path, L".dll");
      //DONT_RESOLVE_DLL_REFERENCESを指定すると依存関係の解決や
      //DllMainの呼び出しが行われない
      hinstDLL = LoadLibraryExW(path, NULL, DONT_RESOLVE_DLL_REFERENCES);
   }
   if(!hinstDLL) {
      errmsg(IDS_DLL, HresultFromLastError());
   } else {
      PathRemoveFileSpecW(path);
      SetCurrentDirectoryW(path);

      HRESULT hr = HookAndExecute(show);
      if(hr != S_OK) {
         errmsg(IDC_EXEC, hr);
      }
   }

   OleUninitialize();
   return 0;
}
Beispiel #17
0
XmlFixture::~XmlFixture()
{
	root->Release();
	doc->Release();

	OleUninitialize();
}
Beispiel #18
0
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
    // SHBrowseForFolder needs this, and says it's better to use OleInitialize than ComInitialize
    VERIFY_HRESULT(OleInitialize(NULL));

    app_check_kill_date();

    app_init_message_loop();
    app_init_sparkle();
    app_init_win32_ui();
    mainwnd_init();
    os_init();                // must be called before app_init_logging
    app_init_logging();
    node_init();

    mainwnd_show();

    win_sparkle_init();
    app_init_pings();

    app_run_message_loop();

    node_shutdown();
    OleUninitialize();

    return 0;
}
Beispiel #19
0
static void* cliprdr_thread_func(void* arg)
{
	int ret;
	MSG msg;
	BOOL mcode;
	wfClipboard* clipboard = (wfClipboard*) arg;

	OleInitialize(0);

	if ((ret = create_cliprdr_window(clipboard)) != 0)
	{
		DEBUG_CLIPRDR("error: create clipboard window failed.");
		return NULL;
	}

	while ((mcode = GetMessage(&msg, 0, 0, 0)) != 0)
	{
		if (mcode == -1)
		{
			DEBUG_CLIPRDR("error: clipboard thread GetMessage failed.");
			break;
		}
		else
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	OleUninitialize();

	return NULL;
}
Beispiel #20
0
/*************************************************************************
 * SHBrowseForFolderW [SHELL32.@]
 *
 * NOTES
 *  crashes when passed a null pointer
 */
LPITEMIDLIST WINAPI SHBrowseForFolderW (LPBROWSEINFOW lpbi)
{
    browse_info info;
    DWORD r;
    HRESULT hr;
    const WCHAR * templateName;
    INITCOMMONCONTROLSEX icex;

    info.hWnd = 0;
    info.pidlRet = NULL;
    info.lpBrowseInfo = lpbi;
    info.hwndTreeView = NULL;

    icex.dwSize = sizeof( icex );
    icex.dwICC = ICC_TREEVIEW_CLASSES;
    InitCommonControlsEx( &icex );

    hr = OleInitialize(NULL);

    if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE)
        templateName = swNewBrowseTemplateName;
    else
        templateName = swBrowseTemplateName;
    r = DialogBoxParamW( shell32_hInstance, templateName, lpbi->hwndOwner,
	                 BrsFolderDlgProc, (LPARAM)&info );
    if (SUCCEEDED(hr)) 
        OleUninitialize();
    if (!r)
    {
        ILFree(info.pidlRet);
        return NULL;
    }

    return info.pidlRet;
}
Beispiel #21
0
/*************************************************************************
 * SHBrowseForFolderW [SHELL32.@]
 *
 * NOTES
 *  crashes when passed a null pointer
 */
LPITEMIDLIST WINAPI SHBrowseForFolderW (LPBROWSEINFOW lpbi)
{
    browse_info info;
    DWORD r;
    HRESULT hr;
    const WCHAR * templateName;

    info.hWnd = 0;
    info.pidlRet = NULL;
    info.lpBrowseInfo = lpbi;
    info.hwndTreeView = NULL;

    hr = OleInitialize(NULL);

    if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE)
        templateName = swNewBrowseTemplateName;
    else
        templateName = swBrowseTemplateName;
    r = DialogBoxParamW( shell32_hInstance, templateName, lpbi->hwndOwner,
	                 BrsFolderDlgProc, (LPARAM)&info );
    if (SUCCEEDED(hr))
        OleUninitialize();
    if (!r)
        return NULL;

    return info.pidlRet;
}
Beispiel #22
0
// routine to find what a shortcut is pointing at
int
get_target(char *target_fname, char *retPath)
{
    HRESULT hres;
    IShellLink *shell_link;
    IPersistFile *persist_file;
    int result = 0;
	WCHAR wsz[MAX_PATH];

    hres = OleInitialize(NULL);
	if (hres != S_FALSE && hres != S_OK)
		return (-1);

    // Get a pointer to the IShellLink interface
    hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
			  &IID_IShellLink, (void **) &shell_link);

	if (!SUCCEEDED(hres)) {
		OleUninitialize();
		return (-1);
	}

    // Get a pointer to the IPersistFile interface
    hres = shell_link->lpVtbl->QueryInterface(shell_link, &IID_IPersistFile,
					    (void **) &persist_file);

	if (SUCCEEDED(hres)) {
		// Ensure that the string is Unicode
		MultiByteToWideChar(CP_ACP, 0, (LPCSTR) target_fname, -1, wsz, MAX_PATH);

		// Load the shortcut
		hres = persist_file->lpVtbl->Load(persist_file, wsz, STGM_READ);

		if (SUCCEEDED(hres)) {
			// read stuff from the link object and print it to the screen
			shell_link->lpVtbl->GetPath(shell_link, retPath,
							 MAX_PATH, NULL, SLGP_RAWPATH);
		} else
			result = -1;

		// Release the pointer to the IPersistFile interface
		persist_file->lpVtbl->Release(persist_file);
	}

	OleUninitialize();
	return(result);
}
Beispiel #23
0
void Win32Host::UnInitialize()
{
	// Shut down the CEF
	//CefShutdown();
	// Shut down COM.
	OleUninitialize();
	MCruxWin32Window::unInitWindowClass(GetModuleHandle(NULL));
}
Beispiel #24
0
ExcelEngine::~ExcelEngine()
{
    if ( bIsOpen )
    {
        //析构前,先保存数据,然后关闭workbook
        close();
    }
    OleUninitialize();
}
Beispiel #25
0
int mainLoop()
{
	MSG msg;
	HACCEL hAccel;
	bool screenSaver = isScreenSaver();
//	DWORD startTickCount = GetTickCount();

	hAccel = LoadAccelerators(CUIWindow::getLanguageModule(),
		MAKEINTRESOURCE(IDR_ACCELERATORS));
	while (1)
	{
		HWND parentWindow;
		HWND topParent;
		HWND newParent;
		DWORD tickCount = GetTickCount();

		debugOut("%d\n", tickCount);
/*
		if (tickCount > startTickCount + 3000 || tickCount < startTickCount)
		{
			OleUninitialize();
			return 0;
		}
*/
		if (!GetMessage(&msg, NULL, 0, 0))
		{
			OleUninitialize();
			return (int)msg.wParam;
		}
#ifdef _DEBUG
//			_CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "hWnd: 0x%6X msg: 0x%X\n", msg.hwnd, msg.message);
#endif // _DEBUG
		parentWindow = GetParent(msg.hwnd);
		topParent = msg.hwnd;
		while ((newParent = GetParent(topParent)) != NULL)
		{
			topParent = newParent;
		}
		if (screenSaver || !TranslateAccelerator( 
		    topParent,     // handle to receiving window 
			hAccel,        // handle to active accelerator table 
			&msg))
		{
			if (!parentWindow || !IsDialogMessage(parentWindow, &msg))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				if (screenSaver && msg.message == WM_DESTROY)
				{
					debugOut("WM_DESTROY\n", tickCount);
					PostQuitMessage(0);
				}
			}
		}
		TCAutoreleasePool::processReleases();
	}
}
Beispiel #26
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE /*hPrevInstance*/,
                     LPSTR     /*lpCmdLine*/,
                     int       /*nCmdShow*/)
{

	appInstance = hInstance;

	OleInitialize(NULL);

	INITCOMMONCONTROLSEX icx;
	icx.dwSize = sizeof(INITCOMMONCONTROLSEX);
	icx.dwICC = ICC_DATE_CLASSES | ICC_LISTVIEW_CLASSES|ICC_WIN95_CLASSES;
	InitCommonControlsEx(&icx);


	resInstance = LoadLibrary(_T("TaskRes.dll"));

	CryptoUtil::GetCryptoUtil();

	NetInit();

	DataManager * pMM = DataManager::Get();
//	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_XMLTREE);
    CTaskMainWnd *pAppWnd = new CTaskMainWnd(hInstance, pMM);
    RECT r = {
		pMM->GetConfiguration()->GetConfigurationInt(_T("mainWindowLeft"), 40), 
		pMM->GetConfiguration()->GetConfigurationInt(_T("mainWindowTop"), 40), 
		pMM->GetConfiguration()->GetConfigurationInt(_T("mainWindowRight"), 750), 
		pMM->GetConfiguration()->GetConfigurationInt(_T("mainWindowBottom"), 550)
	};
    mainAppHWND = pAppWnd->Create(NULL, r, WS_OVERLAPPEDWINDOW | WS_VISIBLE);


    MSG msg;
    ZeroMemory(&msg, sizeof(MSG));
	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
//TODO: review why translate accelerator is not being used..
//		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
//		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
//		}
	}

	pMM->Save(pMM->GetFileManager()->GetUserPlanFilename());
	delete pAppWnd;
	mainAppHWND = NULL;

	NetConclude();

    OleUninitialize();

	return msg.wParam;
}
Beispiel #27
0
//-----------------------------------------------------------------------------
PluginGUIEditor::~PluginGUIEditor () 
{
	#if WINDOWS
	OleUninitialize ();
	#endif
	#if MAC
	ExitMachOLibrary ();
	#endif
}
Beispiel #28
0
QWindowsContext::~QWindowsContext()
{
    unregisterWindowClasses();
    if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE)
        OleUninitialize();

    d->m_screenManager.clearScreens(); // Order: Potentially calls back to the windows.
    m_instance = 0;
}
Beispiel #29
0
void TOLEInitializer::Release()
{
	if(m_bAllocated)
	{
		m_bAllocated = false;

		OleUninitialize();
	}
}
Beispiel #30
0
DLL int AtmoInitialize() {
    OleInitialize(NULL);
    if(getAtmoRemoteControl() == NULL) {
       OleUninitialize();
       return -1;
    } else {
       return 1;
    }
}