int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int show)
{
	MainDialog dlg;
	WTL::CMessageLoop loop;
	int ret = 1;
	
	CoInitialize(NULL);
	_Module.Init(NULL, hinst);
	_Module.AddMessageLoop(&loop);
	if(dlg.Create(NULL)) {
		dlg.ShowWindow(show);
		ret = loop.Run();
	}
	_Module.RemoveMessageLoop();
	_Module.Term();
	CoUninitialize();
	
	return ret;
}
Exemple #2
0
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);

    ImmDisableIME(-1);

    // 检查单例,并通知旧程序
    HANDLE mutex = ::CreateMutex(NULL, TRUE, repeat_run);
    if (::GetLastError() == ERROR_ALREADY_EXISTS)
    {
        UINT WM_REPEAT_RUN = ::RegisterWindowMessage(repeat_run);
        ::PostMessage(HWND_BROADCAST, WM_REPEAT_RUN, 0, 0);
        ::CloseHandle(mutex);
        return 0;
    }

    InitializeVirtualDesktopManagerInternal();

    // 加载lua引擎
    lua_engine = new LuaEngine();

    // 加载配置
    Config::Init();

    // 启动程序
    Window wnd;
    if (!wnd.Create(NULL, CRect(0, 0, 400, 400), app_name, WS_CAPTION))
    {
        return 0;
    }
    // wnd.ShowWindow(nCmdShow);

    // 消息循环
    WTL::CMessageLoop msgLoop;
    int ret = msgLoop.Run();

    delete lua_engine;
    return ret;
}
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
	WTL::CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	CMainFrame wndMain;

	if(wndMain.CreateEx() == NULL)
	{
		ATLTRACE(_T("Main window creation failed!\n"));
		return 0;
	}

	wndMain.ShowWindow(nCmdShow);

	int nRet = theLoop.Run();

	_Module.RemoveMessageLoop();
	return nRet;
}
LRESULT MainDialog::OnInitDialog(HWND hwnd, LPARAM lp)
{
	WTL::CMessageLoop *loop = _Module.GetMessageLoop();
	loop->AddMessageFilter(this);
	
	DragAcceptFiles(*this, true);
	SetIcon(WTL::AtlLoadIconImage(IDI_MEDIAWIKI, 0,
		GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)));
	SetIcon(WTL::AtlLoadIconImage(IDI_MEDIAWIKI, 0,
		GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), false);
	
	EnableDlgItem(IDC_OPT_COMPRESS_FULL, false);
	EnableDlgItem(IDC_START, false);
	
	DoDataExchange();
	m_progress.SetRange(0, 100);
	
	m_waitcursor.LoadOEMCursor(IDC_WAIT);
	
	return false;
}
Exemple #5
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	CoInitialize(NULL);

	ULONG_PTR token;
	{
		Gdiplus::GdiplusStartupInput gdisi;
		Gdiplus::Status s = Gdiplus::GdiplusStartup(&token, &gdisi, NULL);
		ATLTRACE("GDI+ init returned %d\n", s);
	}

	CAnimatedAlphaWindow wnd;
	wnd.Initialize();
	wnd.Create(NULL);
	wnd.ShowWindow(SW_SHOW);

	WTL::CMessageLoop loop;
	return loop.Run();
}
 ~impl()
 {
     WTL::CMessageLoop *pLoop = _Module.GetMessageLoop(m_dwThreadID);
     pstade::verify( pLoop && pLoop->RemoveIdleHandler(m_pIdleHandler) );
 }
 impl(WTL::CIdleHandler *pIdleHandler, DWORD dwThreadID) :
     m_pIdleHandler(pIdleHandler), m_dwThreadID(dwThreadID)
 {
     WTL::CMessageLoop *pLoop = _Module.GetMessageLoop(m_dwThreadID);
     PSTADE_REQUIRE( pLoop && pLoop->AddIdleHandler(m_pIdleHandler) );
 }