namespace ImageAnalysis { static Gdiplus::GdiplusStartupInput gdiSI; static Gdiplus::GdiplusStartupOutput gdiSO; static ULONG_PTR gdiToken; static ULONG_PTR gdiHookToken; static bool m_bInitialized = false; void CGdiplusLife::Initialize() { if(m_bInitialized) return; gdiSI.SuppressBackgroundThread = TRUE; Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO); gdiSO.NotificationHook(&gdiHookToken); } void CGdiplusLife::Uninitialize() { if(!m_bInitialized) return; gdiSO.NotificationUnhook(gdiHookToken); Gdiplus::GdiplusShutdown(gdiToken); } CGdiplusLife::CGdiplusLife() { Initialize(); } CGdiplusLife::~CGdiplusLife() { Uninitialize(); } }
void CGdiplusLife::Uninitialize() { if(!m_bInitialized) return; gdiSO.NotificationUnhook(gdiHookToken); Gdiplus::GdiplusShutdown(gdiToken); }
void CGdiplusLife::Initialize() { if(m_bInitialized) return; gdiSI.SuppressBackgroundThread = TRUE; Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO); gdiSO.NotificationHook(&gdiHookToken); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // Used to find memory leaks //_CrtSetBreakAlloc(1585977); //Also create a debug console window //if(AllocConsole()) //{ // freopen("CONOUT$", "w", stdout); // SetConsoleTitle(L"Debug Console"); // SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); //} #endif //------Splash Screen-------// Gdiplus::GdiplusStartupInput gdiSI; Gdiplus::GdiplusStartupOutput gdiSO; ULONG_PTR gdiToken; ULONG_PTR gdiHookToken; gdiSI.SuppressBackgroundThread = TRUE; Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO); gdiSO.NotificationHook(&gdiHookToken); //--------------------------// Projekt theApp(hInstance); if (!theApp.Init()) return 0; gdiSO.NotificationUnhook(gdiHookToken); Gdiplus::GdiplusShutdown(gdiToken); return theApp.Run(); }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) //int _tmain(int argc, TCHAR *argv[]) { try{ MyRegisterClass(hThisInstance); Gdiplus::GdiplusStartupInput gdiSI; Gdiplus::GdiplusStartupOutput gdiSO; ULONG_PTR gdiToken; ULONG_PTR gdiHookToken; gdiSI.SuppressBackgroundThread = TRUE; Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO); gdiSO.NotificationHook(&gdiHookToken); CSplashWnd splash; Gdiplus::Bitmap* pImage; if (_access("splash.png", 0)==-1) { CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource; if (pBitmap->Load(SPLASH_GIF)) { pImage = pBitmap->m_pBitmap; } }else{ pImage = Gdiplus::Bitmap::FromFile(L"splash.png"); } splash.SetImage(pImage); splash.SetWindowName(L"Marktfuehrer wird geladen..."); delete pImage; // you are free to delete now if (checkIfProcessIsAlreadyRunning()) { ::MessageBox(NULL, L"Die Anwendung wurde bereits geladen...", L"Info", MB_ICONINFORMATION); exit(0); }else { splash.Show(); CreateChildProcess(); BOOL loaded = FALSE; UINT progressTotal = 0; UINT oldProgress = -1; // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } gdiSO.NotificationUnhook(gdiHookToken); Gdiplus::GdiplusShutdown(gdiToken); exit(0); return (int) msg.wParam; } } catch(exception& e){ ::MessageBox(NULL, L"Die Anwendung konnte die Ladeanzeige nicht finden. Der Marktführer wurde dennoch gestartet. Das kann einen Momemt dauern. Dabei wir Ihnen kein Ladebildschirm gezeigt.", L"Failed", MB_ICONSTOP); exit(0); return (int) msg.wParam; } }