From: <man...@us...> - 2015-06-19 20:57:04
|
Revision: 5348 http://sourceforge.net/p/modplug/code/5348 Author: manxorist Date: 2015-06-19 20:56:58 +0000 (Fri, 19 Jun 2015) Log Message: ----------- [Ref] Cleanup splash screen startup logic. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-19 19:07:56 UTC (rev 5347) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-06-19 20:56:58 UTC (rev 5348) @@ -1297,7 +1297,7 @@ PNG::Bitmap *bitmap; public: - CSplashScreen(CWnd *parent); + CSplashScreen(); ~CSplashScreen(); virtual BOOL OnInitDialog(); virtual void OnOK(); @@ -1318,11 +1318,10 @@ static DWORD gSplashScreenStartTime = 0; -CSplashScreen::CSplashScreen(CWnd *parent) -//---------------------------------------- +CSplashScreen::CSplashScreen() +//---------------------------- { bitmap = PNG::ReadPNG(MAKEINTRESOURCE(IDB_SPLASHNOFOLDFIN)); - Create(IDD_SPLASHSCREEN, parent); } @@ -1353,26 +1352,21 @@ BOOL CSplashScreen::OnInitDialog() //-------------------------------- { + CDialog::OnInitDialog(); + CDC *dc = GetDC(); bitmap->ToDIB(m_Bitmap, dc); ReleaseDC(dc); CRect rect; - int cx, cy, newcx, newcy; + GetWindowRect(&rect); + SetWindowPos(nullptr, + rect.left - ((static_cast<int32>(bitmap->width) - rect.Width()) / 2), + rect.top - ((static_cast<int32>(bitmap->height) - rect.Height()) / 2), + bitmap->width, + bitmap->height, + SWP_NOZORDER | SWP_NOCOPYBITS); - CDialog::OnInitDialog(); - - GetWindowRect(&rect); - cx = rect.Width(); - cy = rect.Height(); - newcx = bitmap->width; - newcy = bitmap->height; - if(newcx && newcy) - { - rect.left -= (newcx - cx) / 2; - rect.top -= (newcy - cy) / 2; - SetWindowPos(nullptr, rect.left, rect.top, newcx, newcy, SWP_NOCOPYBITS | SWP_NOZORDER); - } return TRUE; } @@ -1380,22 +1374,17 @@ void CSplashScreen::OnOK() //------------------------ { - if (gpSplashScreen) - { - EndWaitCursor(); - gpSplashScreen = NULL; - } - DestroyWindow(); - delete this; + StopSplashScreen(); } static void StartSplashScreen() //----------------------------- { - if (!gpSplashScreen) + if(!gpSplashScreen) { - gpSplashScreen = new CSplashScreen(theApp.m_pMainWnd); + gpSplashScreen = new CSplashScreen(); + gpSplashScreen->Create(IDD_SPLASHSCREEN, theApp.m_pMainWnd); gpSplashScreen->ShowWindow(SW_SHOW); gpSplashScreen->UpdateWindow(); gpSplashScreen->BeginWaitCursor(); @@ -1407,11 +1396,12 @@ static void StopSplashScreen() //---------------------------- { - if (gpSplashScreen) + if(gpSplashScreen) { gpSplashScreen->EndWaitCursor(); gpSplashScreen->DestroyWindow(); delete gpSplashScreen; + gpSplashScreen = nullptr; } } Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2015-06-19 19:07:56 UTC (rev 5347) +++ trunk/OpenMPT/mptrack/mptrack.rc 2015-06-19 20:56:58 UTC (rev 5348) @@ -1501,7 +1501,7 @@ LTEXT "In ""Relative"" base note mode, all notes are relative to a previously entered note in the pattern cell where the chord is entered.",IDC_STATIC,6,136,234,20 END -IDD_SPLASHSCREEN DIALOGEX 0, 0, 188, 95 +IDD_SPLASHSCREEN DIALOGEX 0, 0, 266, 188 STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |