From 13b99e9e773a322b5fdd7cf4f6f6004a28472eeb Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Fri, 24 Apr 2015 06:38:16 +0000 Subject: crash fix warnings fix git-svn-id: http://svn.miranda-ng.org/main/trunk@13060 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SplashScreen/splashscreen_12.vcxproj | 8 +- plugins/SplashScreen/src/bitmap_funcs.cpp | 79 +--- plugins/SplashScreen/src/bitmap_funcs.h | 3 - plugins/SplashScreen/src/main.cpp | 176 +++---- plugins/SplashScreen/src/options.cpp | 665 ++++++++++++++------------- plugins/SplashScreen/src/services.cpp | 16 +- plugins/SplashScreen/src/splash.cpp | 309 +++++++------ 7 files changed, 593 insertions(+), 663 deletions(-) diff --git a/plugins/SplashScreen/splashscreen_12.vcxproj b/plugins/SplashScreen/splashscreen_12.vcxproj index 28c364ba80..a6bf4123e6 100644 --- a/plugins/SplashScreen/splashscreen_12.vcxproj +++ b/plugins/SplashScreen/splashscreen_12.vcxproj @@ -83,7 +83,7 @@ NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true - Level3 + Level4 false Use headers.h @@ -114,7 +114,7 @@ NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true - Level3 + Level4 false Use headers.h @@ -143,7 +143,7 @@ true EnableFastChecks MultiThreadedDebugDLL - Level3 + Level4 EditAndContinue false Use @@ -171,7 +171,7 @@ _DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL - Level3 + Level4 false Use headers.h diff --git a/plugins/SplashScreen/src/bitmap_funcs.cpp b/plugins/SplashScreen/src/bitmap_funcs.cpp index 7951adb88c..3e4f3d8e54 100644 --- a/plugins/SplashScreen/src/bitmap_funcs.cpp +++ b/plugins/SplashScreen/src/bitmap_funcs.cpp @@ -19,8 +19,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "headers.h" -BOOL (WINAPI *_mempng2dib) (BYTE*, DWORD, BITMAPINFOHEADER**); - MyBitmap::MyBitmap() { dcBmp = 0; @@ -120,39 +118,6 @@ void MyBitmap::restoreAlpha(int x, int y, int w, int h) bitsSave = 0; } -void MyBitmap::Blend(MyBitmap *bmp, int x, int y, int w, int h) -{ - if (!(bits && bmp && bmp->bits)) return; - - if (!w) w = bmp->width; - if (!h) h = bmp->height; - float kx = (float)bmp->width / w; - float ky = (float)bmp->height / h; - - if (x + w >= this->getWidth()) - w = this->getWidth() - x; - if (y + h >= this->getHeight()) - h = this->getHeight() - y; - - for (int i = 0; i < h; i++) { - if (i + y < 0) continue; - if (i + y >= height) break; - for (int j = 0; j < w; j++) { - if (j + x < 0) continue; - if (j + x >= width) break; - COLOR32 src = bmp->bits[int(i*ky)*bmp->width + int(j*kx)]; - COLOR32 dst = bits[(i + y)*width + (j + x)]; - long alpha = geta(src); - bits[(i + y)*width + (j + x)] = rgba( - getr(src) + (255 - alpha)*getr(dst) / 255, - getg(src) + (255 - alpha)*getg(dst) / 255, - getb(src) + (255 - alpha)*getb(dst) / 255, - geta(src) + (255 - alpha)*geta(dst) / 255 - ); - } - } -} - void MyBitmap::DrawText(TCHAR *str, int x, int y) { SIZE sz; GetTextExtentPoint32(this->getDC(), str, (int)mir_tstrlen(str), &sz); @@ -163,36 +128,6 @@ void MyBitmap::DrawText(TCHAR *str, int x, int y) //(x,y,sz.cx,sz.cy); } -HRGN MyBitmap::buildOpaqueRgn() -{ - return CreateRectRgn(0, 0, width, height); - - // - int i, rectCount = 0; - for (i = 0; i < width*height; i++) - if (((bits[i] >> 24) & 0xff) >= 128) - rectCount++; - - RGNDATA *rgnData = (RGNDATA *)malloc(sizeof(RGNDATAHEADER) + rectCount * sizeof(RECT)); - rgnData->rdh.dwSize = sizeof(RGNDATAHEADER); - rgnData->rdh.iType = RDH_RECTANGLES; - rgnData->rdh.nCount = rectCount; - rgnData->rdh.nRgnSize = rectCount * sizeof(RECT); - SetRect(&(rgnData->rdh.rcBound), 0, 0, width, height); - - char *p = (char *)&(rgnData->Buffer); - for (i = 0; i < width*height; i++) - if (((bits[i] >> 24) & 0xff) >= 128) { - SetRect((LPRECT)p, i%width, i / width, i%width + 1, i / width + 1); - p += sizeof(RECT); - } - - HRGN rgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + rectCount * sizeof(RECT), rgnData); - ::free(rgnData); - - return rgn; -} - bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha) { if (bits) free(); @@ -204,10 +139,10 @@ bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha) if (!mir_tstrcmpi(ext, _T(".png"))) { HANDLE hFile, hMap = NULL; - BYTE* ppMap = NULL; + BYTE *ppMap = NULL; long cbFileSize = 0; - BITMAPINFOHEADER* pDib; - BYTE* pDibBits = 0; + BITMAPINFOHEADER *pDib = { 0 }; + BYTE *pDibBits = 0; if (!png2dibConvertor) { return false; @@ -262,9 +197,9 @@ bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha) allocate(abs(bi->bmiHeader.biWidth), abs(bi->bmiHeader.biHeight)); //memcpy(bits, pt, bi->bmiHeader.biSizeImage); - BYTE *p2 = (BYTE *)pt; + BYTE *p2 = (BYTE*)pt; for (int y = 0; y < bi->bmiHeader.biHeight; ++y) { - BYTE *p1 = (BYTE *)bits + (bi->bmiHeader.biHeight - y - 1)*bi->bmiHeader.biWidth * 4; + BYTE *p1 = (BYTE*)bits + (bi->bmiHeader.biHeight - y - 1)*bi->bmiHeader.biWidth * 4; for (int x = 0; x < bi->bmiHeader.biWidth; ++x) { p1[0] = p2[0]; p1[1] = p2[1]; @@ -317,8 +252,6 @@ bool MyBitmap::loadFromFile(TCHAR *fn, TCHAR *fnAlpha) } return true; } - // unreachable place - return false; } void MyBitmap::allocate(int w, int h) @@ -340,7 +273,7 @@ void MyBitmap::allocate(int w, int h) DeleteDC(dcBmp); } - hBmp = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void **)&bits, 0, 0); + hBmp = (HBITMAP)CreateDIBSection(0, &bi, DIB_RGB_COLORS, (void**)&bits, 0, 0); dcBmp = CreateCompatibleDC(0); hBmpSave = (HBITMAP)SelectObject(dcBmp, hBmp); } diff --git a/plugins/SplashScreen/src/bitmap_funcs.h b/plugins/SplashScreen/src/bitmap_funcs.h index f82e909ad2..f91423dc52 100644 --- a/plugins/SplashScreen/src/bitmap_funcs.h +++ b/plugins/SplashScreen/src/bitmap_funcs.h @@ -43,7 +43,6 @@ public: void saveAlpha(int x = 0, int y = 0, int w = 0, int h = 0); void restoreAlpha(int x = 0, int y = 0, int w = 0, int h = 0); - void Blend(MyBitmap *bmp, int x, int y, int w, int h); void DrawText(TCHAR *str, int x, int y); inline COLOR32 *getBits() { return bits; } @@ -70,8 +69,6 @@ public: { return (c >> 24) & 0xff; } - - HRGN buildOpaqueRgn(); }; #endif // __bitmap_funcs_h__ diff --git a/plugins/SplashScreen/src/main.cpp b/plugins/SplashScreen/src/main.cpp index 495d270d61..b2c29a9d06 100644 --- a/plugins/SplashScreen/src/main.cpp +++ b/plugins/SplashScreen/src/main.cpp @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ #include "headers.h" @@ -34,16 +34,16 @@ BOOL png2dibavail = true; // can we use png2dib service? // path to miranda's dir, config file path, splash path, sound path TCHAR szDllName[MAX_PATH], szSplashFile[MAX_PATH], szSoundFile[MAX_PATH], szhAdvaimgPath[MAX_PATH], szPrefix[128], inBuf[80]; -TCHAR * szMirDir; +TCHAR *szMirDir; char szVersion[MAX_PATH]; #ifdef _DEBUG - TCHAR szLogFile[MAX_PATH]; +TCHAR szLogFile[MAX_PATH]; #endif SPLASHOPTS options; HWND hwndSplash; HANDLE hSplashThread; -PLUGININFOEX pluginInfo={ +PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), @@ -54,7 +54,7 @@ PLUGININFOEX pluginInfo={ __AUTHORWEB, UNICODE_AWARE, // C64CC8E0-CF03-474A-8B11-8BD4565CCF04 - {0xc64cc8e0, 0xcf03, 0x474a, {0x8b, 0x11, 0x8b, 0xd4, 0x56, 0x5c, 0xcf, 0x04}} + { 0xc64cc8e0, 0xcf03, 0x474a, { 0x8b, 0x11, 0x8b, 0xd4, 0x56, 0x5c, 0xcf, 0x04 } } }; BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) @@ -72,15 +72,15 @@ void SplashMain() mir_sntprintf(szhAdvaimgPath, SIZEOF(szhAdvaimgPath), _T("%s\\plugins\\advaimg.dll"), szMirDir); CallService(MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, (LPARAM)szVersion); - #ifdef _DEBUG - mir_sntprintf(szLogFile, SIZEOF(szLogFile), _T("%s\\%s.log"), szMirDir, _T(__PLUGIN_NAME)); - initLog(); - TCHAR* mirandaVerString = mir_a2t(szVersion); - logMessage(_T("Miranda version"), mirandaVerString); - mir_free(mirandaVerString); - logMessage(_T("Dll Name"), _T(__FILENAME)); - logMessage(_T("Advaimg path"), szhAdvaimgPath); - #endif +#ifdef _DEBUG + mir_sntprintf(szLogFile, SIZEOF(szLogFile), _T("%s\\%s.log"), szMirDir, _T(__PLUGIN_NAME)); + initLog(); + TCHAR *mirandaVerString = mir_a2t(szVersion); + logMessage(_T("Miranda version"), mirandaVerString); + mir_free(mirandaVerString); + logMessage(_T("Dll Name"), _T(__FILENAME)); + logMessage(_T("Advaimg path"), szhAdvaimgPath); +#endif ReadDbConfig(); } @@ -97,84 +97,84 @@ void SplashMain() } if (hAdvaimg) { - png2dibConvertor = (pfnConvertPng2dib) GetProcAddress(hAdvaimg, "mempng2dib"); + png2dibConvertor = (pfnConvertPng2dib)GetProcAddress(hAdvaimg, "mempng2dib"); if (png2dibConvertor == NULL) { FreeLibrary(hAdvaimg); hAdvaimg = NULL; MessageBox(NULL, - TranslateT("Your advaimg.dll is either obsolete or damaged. Get latest from Miranda alpha builds."), - TranslateT("Error"), - MB_OK | MB_ICONSTOP); + TranslateT("Your advaimg.dll is either obsolete or damaged. Get latest from Miranda alpha builds."), + TranslateT("Error"), + MB_OK | MB_ICONSTOP); } - #ifdef _DEBUG - if (png2dibConvertor) - logMessage(_T("Loading advaimg"), _T("done")); - #endif +#ifdef _DEBUG + if (png2dibConvertor) + logMessage(_T("Loading advaimg"), _T("done")); +#endif } } - DBVARIANT dbv = {0}; + DBVARIANT dbv = { 0 }; if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv)) { - _tcscpy_s(szPrefix, dbv.ptszVal); + mir_tstrcpy(szPrefix, dbv.ptszVal); db_free(&dbv); } else - _tcscpy_s(szPrefix, _T("")); + mir_tstrcpy(szPrefix, _T("")); if (!db_get_ts(NULL, MODNAME, "Path", &dbv)) { - _tcscpy_s(inBuf, dbv.ptszVal); + mir_tstrcpy(inBuf, dbv.ptszVal); db_free(&dbv); } else - _tcscpy_s(inBuf, _T("splash\\splash.png")); + mir_tstrcpy(inBuf, _T("splash\\splash.png")); TCHAR szExpandedSplashFile[MAX_PATH]; ExpandEnvironmentStrings(inBuf, szExpandedSplashFile, SIZEOF(szExpandedSplashFile)); - _tcscpy_s(inBuf, szExpandedSplashFile); + mir_tstrcpy(inBuf, szExpandedSplashFile); TCHAR *pos3 = 0; pos3 = _tcsrchr(inBuf, _T(':')); if (pos3 == NULL) mir_sntprintf(szSplashFile, SIZEOF(szSplashFile), _T("%s\\%s"), szMirDir, inBuf); else - _tcscpy_s(szSplashFile, inBuf); + mir_tstrcpy(szSplashFile, inBuf); if (!db_get_ts(NULL, MODNAME, "Sound", &dbv)) { - _tcscpy_s(inBuf, dbv.ptszVal); + mir_tstrcpy(inBuf, dbv.ptszVal); db_free(&dbv); } else - _tcscpy_s(inBuf, _T("sounds\\startup.wav")); + mir_tstrcpy(inBuf, _T("sounds\\startup.wav")); TCHAR szExpandedSoundFile[MAX_PATH]; ExpandEnvironmentStrings(inBuf, szExpandedSoundFile, SIZEOF(szExpandedSoundFile)); - _tcscpy_s(inBuf, szExpandedSoundFile); + mir_tstrcpy(inBuf, szExpandedSoundFile); TCHAR *pos2; pos2 = _tcschr(inBuf, _T(':')); if (pos2 == NULL) mir_sntprintf(szSoundFile, SIZEOF(szSoundFile), _T("%s\\%s"), szMirDir, inBuf); else - _tcscpy_s(szSoundFile, inBuf); + mir_tstrcpy(szSoundFile, inBuf); - #ifdef _DEBUG - logMessage(_T("SoundFilePath"), szSoundFile); - #endif +#ifdef _DEBUG + logMessage(_T("SoundFilePath"), szSoundFile); +#endif - TCHAR szOldPath[MAX_PATH] = {0}; + TCHAR szOldPath[MAX_PATH] = { 0 }; - if(options.random) // randomly select a splash file + if (options.random) // randomly select a splash file { int filescount = 0; - TCHAR szSplashDir[MAX_PATH] = {0}, szSearch[MAX_PATH] = {0}; - TCHAR* p = 0; - TCHAR files [255][50]; //TODO: make memory allocation dynamic + TCHAR szSplashDir[MAX_PATH] = { 0 }, szSearch[MAX_PATH] = { 0 }; + TCHAR *p = 0; + TCHAR files[255][50]; //TODO: make memory allocation dynamic - _tcscpy_s(szSplashDir, szSplashFile); - _tcscpy_s(szOldPath, szSplashFile); + mir_tstrcpy(szSplashDir, szSplashFile); + mir_tstrcpy(szOldPath, szSplashFile); // find the last \ and null it out, this leaves no trailing slash p = _tcsrchr(szSplashDir, _T('\\')); if (p) *p = 0; @@ -184,43 +184,43 @@ void SplashMain() HANDLE hFind = INVALID_HANDLE_VALUE; WIN32_FIND_DATA ffd; hFind = FindFirstFile(szSearch, &ffd); - if ( hFind != INVALID_HANDLE_VALUE ) + if (hFind != INVALID_HANDLE_VALUE) { do { - if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) + if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) { - #ifdef _DEBUG - logMessage(_T("Found file"), ffd.cFileName); - #endif +#ifdef _DEBUG + logMessage(_T("Found file"), ffd.cFileName); +#endif //files = new char[strlen(ffd.cFileName)]; //files[filescount] = new char[strlen(ffd.cFileName)]; TCHAR ext[5]; - tmemcpy(ext, ffd.cFileName + (_tcslen(ffd.cFileName)-4), 5); + tmemcpy(ext, ffd.cFileName + (mir_tstrlen(ffd.cFileName) - 4), 5); - #ifdef _DEBUG - logMessage(_T("Extention"), ext); - #endif +#ifdef _DEBUG + logMessage(_T("Extention"), ext); +#endif if (mir_tstrcmpi(ext, _T(".png")) & mir_tstrcmpi(ext, _T(".bmp"))) continue; - #ifdef _DEBUG - logMessage(_T("File has valid ext"), ext); - #endif - _tcscpy_s(files[filescount++], ffd.cFileName); +#ifdef _DEBUG + logMessage(_T("File has valid ext"), ext); +#endif + mir_tstrcpy(files[filescount++], ffd.cFileName); } //if } while (FindNextFile(hFind, &ffd)); - srand((unsigned) time(NULL)); + srand((unsigned)time(NULL)); int r = 0; if (filescount) r = (rand() % filescount) + 1; - mir_sntprintf(szSplashFile, SIZEOF(szSplashFile), _T("%s\\%s"), szSplashDir, files[r-1]); + mir_sntprintf(szSplashFile, SIZEOF(szSplashFile), _T("%s\\%s"), szSplashDir, files[r - 1]); - #ifdef _DEBUG - logMessage(_T("final file"), szSplashFile); - #endif +#ifdef _DEBUG + logMessage(_T("final file"), szSplashFile); +#endif FindClose(hFind); } //if } @@ -233,33 +233,33 @@ void SplashMain() int PlugDisableHook(WPARAM wParam, LPARAM lParam) { - #ifdef _DEBUG - TCHAR buf [128]; - #endif +#ifdef _DEBUG + TCHAR buf[128]; +#endif DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - TCHAR * tszModule= mir_a2t(cws->szModule), *tszSetting = mir_a2t(cws->szSetting); - if(options.inheritGS) + TCHAR *tszModule = mir_a2t(cws->szModule), *tszSetting = mir_a2t(cws->szSetting); + if (options.inheritGS) { if (!mir_tstrcmp(tszModule, _T("Skin")) & !mir_tstrcmp(tszSetting, _T("UseSound"))) { db_set_b(NULL, MODNAME, "PlaySound", cws->value.bVal); - #ifdef _DEBUG - cws->value.bVal ? _DebugPopup(NULL, _T("Sounds enabled."), _T("")) : _DebugPopup(NULL, _T("Sounds disabled."), _T("")); - logMessage(_T("Module"), tszModule); - logMessage(_T("Setting"), tszSetting); - logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10)); - #endif +#ifdef _DEBUG + cws->value.bVal ? _DebugPopup(NULL, _T("Sounds enabled."), _T("")) : _DebugPopup(NULL, _T("Sounds disabled."), _T("")); + logMessage(_T("Module"), tszModule); + logMessage(_T("Setting"), tszSetting); + logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10)); +#endif } if (!mir_tstrcmp(tszModule, _T("PluginDisable")) & (!mir_tstrcmp(tszSetting, szDllName))) { db_set_b(NULL, MODNAME, "Active", cws->value.bVal); - #ifdef _DEBUG - cws->value.bVal ? _DebugPopup(NULL, _T("Disabled."), "") : _DebugPopup(NULL, _T("Enabled."), _T("")); - logMessage(_T("PlugDisableHook"), _T("Triggered")); - logMessage(_T("Module"), tszModule); - logMessage(_T("Setting"), tszSetting); - logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10)); - #endif +#ifdef _DEBUG + cws->value.bVal ? _DebugPopup(NULL, _T("Disabled."), "") : _DebugPopup(NULL, _T("Enabled."), _T("")); + logMessage(_T("PlugDisableHook"), _T("Triggered")); + logMessage(_T("Module"), tszModule); + logMessage(_T("Setting"), tszSetting); + logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10)); +#endif } } mir_free(tszModule); @@ -276,9 +276,9 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) { if (PostMessage(hwndSplash, WM_LOADED, 0, 0)) { - #ifdef _DEBUG - logMessage(_T("Posted WM_LOADED message"), _T("done")); - #endif +#ifdef _DEBUG + logMessage(_T("Posted WM_LOADED message"), _T("done")); +#endif } } @@ -289,9 +289,9 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) // Service to call splash CreateServiceFunction(MS_SHOWSPLASH, ShowSplashService); - #ifdef _DEBUG - logMessage(_T("Loading modules"), _T("done")); - #endif +#ifdef _DEBUG + logMessage(_T("Loading modules"), _T("done")); +#endif return 0; } @@ -324,9 +324,9 @@ extern "C" int __declspec(dllexport) Unload(void) if (hAdvaimg) FreeLibrary(hAdvaimg); - #ifdef _DEBUG - logMessage(_T("Unload"), _T("Job done")); - #endif +#ifdef _DEBUG + logMessage(_T("Unload"), _T("Job done")); +#endif return 0; } diff --git a/plugins/SplashScreen/src/options.cpp b/plugins/SplashScreen/src/options.cpp index 398dd337db..84dd4618e9 100644 --- a/plugins/SplashScreen/src/options.cpp +++ b/plugins/SplashScreen/src/options.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "headers.h" -TCHAR szPath2Spash [MAX_PATH], szSoundFilePath[MAX_PATH]; +TCHAR szPath2Spash[MAX_PATH], szSoundFilePath[MAX_PATH]; // Reads values from db void ReadDbConfig() @@ -45,384 +45,385 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP { switch (msg) { - case WM_INITDIALOG: + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + if (!png2dibavail) { + ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW); + EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWVERSION), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWTIME), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_ST_SPIN), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_FADEIN), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_FADEOUT), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false); + EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false); + } + else { + ReadDbConfig(); + TCHAR inBuf[80]; + DBVARIANT dbv = { 0 }; + if (!db_get_ts(NULL, MODNAME, "Path", &dbv)) + { + mir_tstrcpy(inBuf, dbv.ptszVal); + db_free(&dbv); + } + else + mir_tstrcpy(inBuf, _T("splash\\splash.png")); + SetDlgItemText(hwndDlg, IDC_SPLASHPATH, inBuf); + + if (!db_get_ts(NULL, MODNAME, "Sound", &dbv)) + { + mir_tstrcpy(inBuf, dbv.ptszVal); + db_free(&dbv); + } + else + mir_tstrcpy(inBuf, _T("sounds\\startup.wav")); + SetDlgItemText(hwndDlg, IDC_SNDPATH, inBuf); + + if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv)) + { + mir_tstrcpy(inBuf, dbv.ptszVal); + db_free(&dbv); + } + else + mir_tstrcpy(inBuf, _T("")); + SetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, inBuf); + + if (options.active) + CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED); + if (options.playsnd && !options.inheritGS) + CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE); + else if (options.playsnd) + CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false); + if (options.fadein) + CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED); + if (options.fadeout) + CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED); + if (options.random) + CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED); + if (options.showversion) + CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED); + + SetDlgItemText(hwndDlg, IDC_SHOWTIME, _itot(options.showtime, inBuf, 10)); + SetDlgItemText(hwndDlg, IDC_FISTEP, _itot(options.fisteps, inBuf, 10)); + SetDlgItemText(hwndDlg, IDC_FOSTEP, _itot(options.fosteps, inBuf, 10)); + + SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0); + } + + return TRUE; + } + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_PREVIEW: { - TranslateDialogDefault(hwndDlg); - if (!png2dibavail) { - ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW); - EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWVERSION), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWTIME), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_ST_SPIN), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_FADEIN), false); + ShowSplash(true); + break; + } + + case IDC_ACTIVE: + case IDC_PLAYSND: + case IDC_LOOPSOUND: + case IDC_FADEIN: + case IDC_FADEOUT: + case IDC_SHOWTIME: + case IDC_RANDOM: + case IDC_SHOWVERSION: + case IDC_FISTEP: + case IDC_FOSTEP: + { + if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true); + } + else + { EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false); EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_FADEOUT), false); + } + if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true); + EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true); + } + else + { EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false); EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false); - } else { - ReadDbConfig(); - TCHAR inBuf[80]; - DBVARIANT dbv = {0}; - if (!db_get_ts(NULL, MODNAME, "Path", &dbv)) - { - _tcscpy_s(inBuf, dbv.ptszVal); - db_free(&dbv); - } - else - _tcscpy_s(inBuf, _T("splash\\splash.png")); - SetDlgItemText(hwndDlg, IDC_SPLASHPATH, inBuf); - - if (!db_get_ts(NULL, MODNAME, "Sound", &dbv)) - { - _tcscpy_s(inBuf, dbv.ptszVal); - db_free(&dbv); - } - else - _tcscpy_s(inBuf, _T("sounds\\startup.wav")); - SetDlgItemText(hwndDlg, IDC_SNDPATH, inBuf); - - if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv)) - { - _tcscpy_s(inBuf, dbv.ptszVal); - db_free(&dbv); - } - else - _tcscpy_s(inBuf, _T("")); - SetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, inBuf); - - if (options.active) - CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED); - if (options.playsnd && !options.inheritGS) - CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE); - else if (options.playsnd) - CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false); - if (options.fadein) - CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED); - if (options.fadeout) - CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED); - if (options.random) - CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED); - if (options.showversion) - CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED); - - SetDlgItemText(hwndDlg, IDC_SHOWTIME, _itot(options.showtime, inBuf, 10)); - SetDlgItemText(hwndDlg, IDC_FISTEP, _itot(options.fisteps, inBuf, 10)); - SetDlgItemText(hwndDlg, IDC_FOSTEP, _itot(options.fosteps, inBuf, 10)); - - SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0); } - return TRUE; + if ((HWND)lParam != GetFocus()) + return 0; + else { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; } - case WM_COMMAND: + case IDC_CHOOSESPLASH: { - switch(LOWORD(wParam)) + TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; + TCHAR *pos; + + if (Exists(szSplashFile)) { - case IDC_PREVIEW: - { - ShowSplash(true); - break; - } + mir_tstrcpy(initDir, szSplashFile); + pos = _tcsrchr(initDir, _T('\\')); + if (pos != NULL) *pos = 0; + } + else + { + szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%")); + mir_tstrcpy(initDir, szMirDir); + mir_free(szMirDir); + } - case IDC_ACTIVE: - case IDC_PLAYSND: - case IDC_LOOPSOUND: - case IDC_FADEIN: - case IDC_FADEOUT: - case IDC_SHOWTIME: - case IDC_RANDOM: - case IDC_SHOWVERSION: - case IDC_FISTEP: - case IDC_FOSTEP: - { - if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN)) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true); - EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true); - } - else - { - EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false); - } - if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT)) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true); - EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true); - } - else - { - EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false); - EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false); - } + OPENFILENAME ofn = { 0 }; + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + TCHAR tmp[MAX_PATH]; + mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0); + ofn.lpstrFilter = tmp; + ofn.hwndOwner = 0; + ofn.lpstrFile = szTempPath; + ofn.nMaxFile = MAX_PATH; + ofn.nMaxFileTitle = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY; + ofn.lpstrInitialDir = initDir; + *szTempPath = '\0'; + ofn.lpstrDefExt = _T(""); + + if (GetOpenFileName(&ofn)) + { + mir_tstrcpy(szSplashFile, szTempPath); - if ((HWND)lParam != GetFocus()) - return 0; - else { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - break; - } +#ifdef _DEBUG + logMessage(_T("Set path"), szSplashFile); +#endif - case IDC_CHOOSESPLASH: + // Make path relative + int result = PathToRelativeT(szTempPath, szPath2Spash); + if (result && mir_tstrlen(szPath2Spash) > 0) { - TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; - TCHAR *pos; - - if (Exists(szSplashFile)) - { - _tcscpy_s(initDir, szSplashFile); - pos = _tcsrchr(initDir, _T('\\')); - if(pos != NULL) *pos = 0; - } - else - { - szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%")); - _tcscpy_s(initDir, szMirDir); - mir_free(szMirDir); - } - - OPENFILENAME ofn = {0}; - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - TCHAR tmp[MAX_PATH]; - mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0); - ofn.lpstrFilter = tmp; - ofn.hwndOwner = 0; - ofn.lpstrFile = szTempPath; - ofn.nMaxFile = MAX_PATH; - ofn.nMaxFileTitle = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY; - ofn.lpstrInitialDir = initDir; - *szTempPath = '\0'; - ofn.lpstrDefExt = _T(""); - - if (GetOpenFileName(&ofn)) + if (options.random) { - _tcscpy_s(szSplashFile, szTempPath); - - #ifdef _DEBUG - logMessage(_T("Set path"), szSplashFile); - #endif - - // Make path relative - int result = PathToRelativeT(szTempPath, szPath2Spash); - if(result && mir_tstrlen(szPath2Spash) > 0) + TCHAR *pos; + pos = _tcsrchr(szPath2Spash, _T('\\')); + if (pos != NULL) { - if (options.random) - { - TCHAR *pos; - pos = _tcsrchr(szPath2Spash, _T('\\')); - if (pos != NULL) - { - *pos = 0; - _tcscat_s(szPath2Spash, _T("\\")); - } - } - - SetDlgItemText(hwndDlg, IDC_SPLASHPATH, szPath2Spash); + *pos = 0; + mir_tstrcat(szPath2Spash, _T("\\")); } - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } - break; + SetDlgItemText(hwndDlg, IDC_SPLASHPATH, szPath2Spash); } - case IDC_CHOOSESND: - { - TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; - TCHAR *pos; + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } - if (Exists(szSoundFile)) - { - _tcscpy_s(initDir, szSoundFile); - pos = _tcsrchr(initDir, _T('\\')); - if(pos != NULL) *pos = 0; - } - else - { - szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%")); - _tcscpy_s(initDir, szMirDir); - mir_free(szMirDir); - } + break; + } - OPENFILENAME ofn = {0}; - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - TCHAR tmp[MAX_PATH]; - mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.wav, *.mp3)%c*.wav;*.mp3%c%c"), TranslateT("Sound Files"), 0, 0, 0); - ofn.lpstrFilter = tmp; - ofn.hwndOwner = 0; - ofn.lpstrFile = szTempPath; - ofn.nMaxFile = MAX_PATH; - ofn.nMaxFileTitle = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY; - ofn.lpstrInitialDir = initDir; - *szTempPath = '\0'; - ofn.lpstrDefExt = _T(""); - - if (GetOpenFileName(&ofn)) - { - _tcscpy_s(szSoundFile,szTempPath); + case IDC_CHOOSESND: + { + TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; + TCHAR *pos; - #ifdef _DEBUG - logMessage(_T("Set sound path"), szSoundFile); - #endif + if (Exists(szSoundFile)) + { + mir_tstrcpy(initDir, szSoundFile); + pos = _tcsrchr(initDir, _T('\\')); + if (pos != NULL) *pos = 0; + } + else + { + szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%")); + mir_tstrcpy(initDir, szMirDir); + mir_free(szMirDir); + } - // Make path relative - int result = PathToRelativeT(szTempPath, szSoundFilePath); - if(result && mir_tstrlen(szSoundFile) > 0) - SetDlgItemText(hwndDlg, IDC_SNDPATH, szSoundFilePath); + OPENFILENAME ofn = { 0 }; + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + TCHAR tmp[MAX_PATH]; + mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.wav, *.mp3)%c*.wav;*.mp3%c%c"), TranslateT("Sound Files"), 0, 0, 0); + ofn.lpstrFilter = tmp; + ofn.hwndOwner = 0; + ofn.lpstrFile = szTempPath; + ofn.nMaxFile = MAX_PATH; + ofn.nMaxFileTitle = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY; + ofn.lpstrInitialDir = initDir; + *szTempPath = '\0'; + ofn.lpstrDefExt = _T(""); + + if (GetOpenFileName(&ofn)) + { + mir_tstrcpy(szSoundFile, szTempPath); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } +#ifdef _DEBUG + logMessage(_T("Set sound path"), szSoundFile); +#endif - break; - } + // Make path relative + int result = PathToRelativeT(szTempPath, szSoundFilePath); + if (result && mir_tstrlen(szSoundFile) > 0) + SetDlgItemText(hwndDlg, IDC_SNDPATH, szSoundFilePath); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } - default: - { - if (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()) - return 0; - else - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } break; } + } - case WM_NOTIFY: + default: + { + if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) + return 0; + else + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + + case WM_NOTIFY: + { + if (((LPNMHDR)lParam)->idFrom == 0) + switch (((LPNMHDR)lParam)->code) { - if (((LPNMHDR)lParam)->idFrom == 0) - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - TCHAR tmp[MAX_PATH]; + case PSN_APPLY: + { + TCHAR tmp[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_SPLASHPATH, tmp, SIZEOF(tmp)); - db_set_ts(NULL, MODNAME, "Path", tmp); + GetDlgItemText(hwndDlg, IDC_SPLASHPATH, tmp, SIZEOF(tmp)); + db_set_ts(NULL, MODNAME, "Path", tmp); - GetDlgItemText(hwndDlg, IDC_SNDPATH, tmp, SIZEOF(tmp)); - db_set_ts(NULL, MODNAME, "Sound", tmp); + GetDlgItemText(hwndDlg, IDC_SNDPATH, tmp, SIZEOF(tmp)); + db_set_ts(NULL, MODNAME, "Sound", tmp); - GetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, tmp, SIZEOF(tmp)); - db_set_ts(NULL, MODNAME, "VersionPrefix", tmp); - _tcscpy_s(szPrefix, tmp); + GetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, tmp, SIZEOF(tmp)); + db_set_ts(NULL, MODNAME, "VersionPrefix", tmp); + mir_tstrcpy(szPrefix, tmp); - GetDlgItemText(hwndDlg, IDC_SHOWTIME, tmp, SIZEOF(tmp)); - db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp)); - options.showtime = _ttoi(tmp); + GetDlgItemText(hwndDlg, IDC_SHOWTIME, tmp, SIZEOF(tmp)); + db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp)); + options.showtime = _ttoi(tmp); - GetDlgItemText(hwndDlg, IDC_FISTEP, tmp, SIZEOF(tmp)); - db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp)); - options.fisteps = _ttoi(tmp); + GetDlgItemText(hwndDlg, IDC_FISTEP, tmp, SIZEOF(tmp)); + db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp)); + options.fisteps = _ttoi(tmp); - GetDlgItemText(hwndDlg, IDC_FOSTEP, tmp, SIZEOF(tmp)); - db_set_dw(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp)); - options.fosteps = _ttoi(tmp); + GetDlgItemText(hwndDlg, IDC_FOSTEP, tmp, SIZEOF(tmp)); + db_set_dw(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp)); + options.fosteps = _ttoi(tmp); - if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE)) - { - db_set_b(NULL, MODNAME, "Active", 1); - options.active = 1; - } - else - { - db_set_b(NULL, MODNAME, "Active", 0); - options.active = 0; - } + if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE)) + { + db_set_b(NULL, MODNAME, "Active", 1); + options.active = 1; + } + else + { + db_set_b(NULL, MODNAME, "Active", 0); + options.active = 0; + } - if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND)) - { - db_set_b(NULL, MODNAME, "PlaySound", 1); - options.playsnd = 1; - db_set_b(NULL, MODNAME, "InheritGlobalSound", 1); - options.inheritGS = 1; - } - else - { - db_set_b(NULL, MODNAME, "PlaySound", 0); - options.playsnd = 0; - db_set_b(NULL, MODNAME, "InheritGlobalSound", 0); - options.inheritGS = 0; - } + if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND)) + { + db_set_b(NULL, MODNAME, "PlaySound", 1); + options.playsnd = 1; + db_set_b(NULL, MODNAME, "InheritGlobalSound", 1); + options.inheritGS = 1; + } + else + { + db_set_b(NULL, MODNAME, "PlaySound", 0); + options.playsnd = 0; + db_set_b(NULL, MODNAME, "InheritGlobalSound", 0); + options.inheritGS = 0; + } - if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE) - { - db_set_b(NULL, MODNAME, "PlaySound", 1); - options.playsnd = 1; - db_set_b(NULL, MODNAME, "InheritGlobalSound", 0); - options.inheritGS = 0; - } - - /* - if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND)) - { - WritePrivateProfileString("Splash","LoopSound","1",szIniFile); - options.loopsnd = 1; - } - else - { - WritePrivateProfileString("Splash","LoopSound","0",szIniFile); - options.loopsnd = 0; - } - */ + if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE) + { + db_set_b(NULL, MODNAME, "PlaySound", 1); + options.playsnd = 1; + db_set_b(NULL, MODNAME, "InheritGlobalSound", 0); + options.inheritGS = 0; + } - if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN)) - { - db_set_b(NULL, MODNAME, "FadeIn", 1); - options.fadein = 1; - } - else - { - db_set_b(NULL, MODNAME, "FadeIn", 0); - options.fadein = 0; - } - if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT)) - { - db_set_b(NULL, MODNAME, "FadeOut", 1); - options.fadeout = 1; - } - else - { - db_set_b(NULL, MODNAME, "FadeOut", 0); - options.fadeout = 0; - } - if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM)) - { - db_set_b(NULL, MODNAME, "Random", 1); - options.random = 1; - } - else - { - db_set_b(NULL, MODNAME, "Random", 0); - options.random = 0; - } - if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION)) - { - db_set_b(NULL, MODNAME, "ShowVersion", 1); - options.showversion = 1; - } - else - { - db_set_b(NULL, MODNAME, "ShowVersion", 0); - options.showversion = 0; - } - return TRUE; - } + /* + if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND)) + { + WritePrivateProfileString("Splash","LoopSound","1",szIniFile); + options.loopsnd = 1; + } + else + { + WritePrivateProfileString("Splash","LoopSound","0",szIniFile); + options.loopsnd = 0; + } + */ + + if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN)) + { + db_set_b(NULL, MODNAME, "FadeIn", 1); + options.fadein = 1; } + else + { + db_set_b(NULL, MODNAME, "FadeIn", 0); + options.fadein = 0; + } + if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT)) + { + db_set_b(NULL, MODNAME, "FadeOut", 1); + options.fadeout = 1; + } + else + { + db_set_b(NULL, MODNAME, "FadeOut", 0); + options.fadeout = 0; + } + if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM)) + { + db_set_b(NULL, MODNAME, "Random", 1); + options.random = 1; + } + else + { + db_set_b(NULL, MODNAME, "Random", 0); + options.random = 0; + } + if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION)) + { + db_set_b(NULL, MODNAME, "ShowVersion", 1); + options.showversion = 1; + } + else + { + db_set_b(NULL, MODNAME, "ShowVersion", 0); + options.showversion = 0; + } + return TRUE; } + } + } - case WM_DESTROY: - break; + case WM_DESTROY: + break; } return FALSE; } diff --git a/plugins/SplashScreen/src/services.cpp b/plugins/SplashScreen/src/services.cpp index ecf9821208..ee80c9639f 100644 --- a/plugins/SplashScreen/src/services.cpp +++ b/plugins/SplashScreen/src/services.cpp @@ -15,29 +15,29 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ #include "headers.h" -INT_PTR ShowSplashService(WPARAM wparam,LPARAM lparam) +INT_PTR ShowSplashService(WPARAM wparam, LPARAM lparam) { bserviceinvoked = true; - TCHAR szOldfn [256]; - TCHAR* filename = (TCHAR*) wparam; - int timetoshow = (int) lparam; + TCHAR szOldfn[256]; + TCHAR *filename = (TCHAR*)wparam; + int timetoshow = (int)lparam; - _tcscpy_s(szOldfn, szSplashFile); + mir_tstrcpy(szOldfn, szSplashFile); options.showtime = timetoshow; TCHAR *pos = _tcsrchr(filename, _T(':')); if (pos == NULL) mir_sntprintf(szSplashFile, SIZEOF(szSplashFile), _T("%s\\%s"), szMirDir, filename); else - _tcscpy_s(szSplashFile, filename); + mir_tstrcpy(szSplashFile, filename); ShowSplash(false); - _tcscpy_s(szSplashFile, szOldfn); + mir_tstrcpy(szSplashFile, szOldfn); return 0; } diff --git a/plugins/SplashScreen/src/splash.cpp b/plugins/SplashScreen/src/splash.cpp index d2ce106a7c..8fbde3bb40 100644 --- a/plugins/SplashScreen/src/splash.cpp +++ b/plugins/SplashScreen/src/splash.cpp @@ -26,126 +26,124 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM { switch (message) { - case WM_LOADED: - { - #ifdef _DEBUG - logMessage(_T("WM_LOADED"), _T("called")); - #endif + case WM_LOADED: + { +#ifdef _DEBUG + logMessage(_T("WM_LOADED"), _T("called")); +#endif - if (!options.showtime) SetTimer(hwnd, 7, 2000, 0); + if (!options.showtime) SetTimer(hwnd, 7, 2000, 0); - break; - } + break; + } - case WM_LBUTTONDOWN: - PostMessage(hwnd, WM_CLOSE, 0, 0); - break; + case WM_LBUTTONDOWN: + PostMessage(hwnd, WM_CLOSE, 0, 0); + break; - case WM_TIMER: + case WM_TIMER: - #ifdef _DEBUG - TCHAR b [40]; - mir_sntprintf(b, SIZEOF(b), _T("%d"), wParam); - logMessage(_T("Timer ID"), b); - mir_sntprintf(b, SIZEOF(b), _T("%d"), options.showtime); - logMessage(_T("ShowTime value"), b); - #endif +#ifdef _DEBUG + TCHAR b[40]; + mir_sntprintf(b, SIZEOF(b), _T("%d"), wParam); + logMessage(_T("Timer ID"), b); + mir_sntprintf(b, SIZEOF(b), _T("%d"), options.showtime); + logMessage(_T("ShowTime value"), b); +#endif - if (options.showtime > 0) //TimeToShow enabled + if (options.showtime > 0) //TimeToShow enabled + { + if (wParam == 6) { - if (wParam == 6) - { - PostMessage(hwnd, WM_CLOSE, 0, 0); - #ifdef _DEBUG - logMessage(_T("Showtime timer"), _T("triggered")); - #endif - } + PostMessage(hwnd, WM_CLOSE, 0, 0); +#ifdef _DEBUG + logMessage(_T("Showtime timer"), _T("triggered")); +#endif } - else + } + else + { + PostMessage(hwnd, WM_CLOSE, 0, 0); + if (wParam == 7) { - PostMessage(hwnd, WM_CLOSE, 0, 0); - if (wParam == 7) - { - #ifdef _DEBUG - logMessage(_T("On Modules Loaded timer"), _T("triggered")); - #endif - } - if (wParam == 8) - { - #ifdef _DEBUG - logMessage(_T("On Modules Loaded workaround"), _T("triggered")); - #endif - } +#ifdef _DEBUG + logMessage(_T("On Modules Loaded timer"), _T("triggered")); +#endif + } + if (wParam == 8) + { +#ifdef _DEBUG + logMessage(_T("On Modules Loaded workaround"), _T("triggered")); +#endif } + } - break; + break; - case WM_RBUTTONDOWN: - { - ShowWindow(hwndSplash, SW_HIDE); - DestroyWindow(hwndSplash); - bpreviewruns = false; // preview is stopped. - break; - } + case WM_RBUTTONDOWN: + { + ShowWindow(hwndSplash, SW_HIDE); + DestroyWindow(hwndSplash); + bpreviewruns = false; // preview is stopped. + break; + } - case WM_CLOSE: + case WM_CLOSE: + { + RECT rc; GetWindowRect(hwndSplash, &rc); + POINT ptDst = { rc.left, rc.top }; + POINT ptSrc = { 0, 0 }; + SIZE sz = { rc.right - rc.left, rc.bottom - rc.top }; + + BLENDFUNCTION blend; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = 255; + blend.AlphaFormat = AC_SRC_ALPHA; + + // Fade Out + if (options.fadeout) { - RECT rc; GetWindowRect(hwndSplash, &rc); - POINT ptDst = { rc.left, rc.top }; - POINT ptSrc = { 0, 0 }; - SIZE sz = { rc.right - rc.left, rc.bottom - rc.top }; - - BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; - blend.SourceConstantAlpha = 255; - blend.AlphaFormat = AC_SRC_ALPHA; - - // Fade Out - if (options.fadeout) + int i; + for (i = 255; i >= 0; i -= options.fosteps) { - int i; - for (i = 255; i>=0; i -= options.fosteps) - { - blend.SourceConstantAlpha = i; - UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); - Sleep(1); - } + blend.SourceConstantAlpha = i; + UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); + Sleep(1); } - if (bserviceinvoked) bserviceinvoked = false; - if (bpreviewruns) bpreviewruns = false; - - DestroyWindow(hwndSplash); } + if (bserviceinvoked) bserviceinvoked = false; + if (bpreviewruns) bpreviewruns = false; - case WM_MOUSEMOVE: - { - if (bserviceinvoked) - PostMessage(hwnd, WM_CLOSE, 0, 0); - break; - } + DestroyWindow(hwndSplash); + } - case WM_DESTROY: - { - PostQuitMessage(0); - #ifdef _DEBUG - logMessage(_T("WM_DESTROY"), _T("called")); - #endif - break; - } + case WM_MOUSEMOVE: + { + if (bserviceinvoked) + PostMessage(hwnd, WM_CLOSE, 0, 0); + break; + } + case WM_DESTROY: + { +#ifdef _DEBUG + logMessage(_T("WM_DESTROY"), _T("called")); +#endif ShowWindow(hwndSplash, SW_HIDE); DestroyWindow(hwndSplash); + PostQuitMessage(0); break; } + } return DefWindowProc(hwnd, message, wParam, lParam); } int SplashThread(void *arg) { - IGraphBuilder *pGraph = NULL; - IMediaControl *pControl = NULL; + IGraphBuilder *pGraph = NULL; + IMediaControl *pControl = NULL; if (options.playsnd) { @@ -190,7 +188,7 @@ int SplashThread(void *arg) RECT WindowRect; WindowRect.left = (DesktopRect.left + DesktopRect.right - SplashBmp->getWidth()) / 2; - WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2; + WindowRect.top = (DesktopRect.top + DesktopRect.bottom - SplashBmp->getHeight()) / 2; WindowRect.right = WindowRect.left + SplashBmp->getWidth(); WindowRect.bottom = WindowRect.top + SplashBmp->getHeight(); @@ -209,16 +207,16 @@ int SplashThread(void *arg) NULL); RECT rc; GetWindowRect(hwndSplash, &rc); - POINT ptDst = {rc.left, rc.top}; - POINT ptSrc = {0, 0}; - SIZE sz = {rc.right - rc.left, rc.bottom - rc.top}; + POINT ptDst = { rc.left, rc.top }; + POINT ptSrc = { 0, 0 }; + SIZE sz = { rc.right - rc.left, rc.bottom - rc.top }; bool splashWithMarkers = false; BLENDFUNCTION blend; - blend.BlendOp = AC_SRC_OVER; - blend.BlendFlags = 0; + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; blend.SourceConstantAlpha = 0; - blend.AlphaFormat = AC_SRC_ALPHA; + blend.AlphaFormat = AC_SRC_ALPHA; if (options.showversion) { @@ -228,27 +226,29 @@ int SplashThread(void *arg) int splashWidth = SplashBmp->getWidth(); for (i = 0; i < splashWidth; ++i) if (SplashBmp->getRow(0)[i] & 0xFF000000) - { - if (x < 0) { - x = i-1; // 1 pixel for marker line - splashWithMarkers = true; - } else - { - x = -1; - splashWithMarkers = false; - break; + if (x < 0) + { + x = i - 1; // 1 pixel for marker line + splashWithMarkers = true; + } + else + { + x = -1; + splashWithMarkers = false; + break; + } } - } int splashHeight = SplashBmp->getHeight(); for (i = 0; splashWithMarkers && (i < splashHeight); ++i) - if(SplashBmp->getRow(i)[0] & 0xFF000000) + if (SplashBmp->getRow(i)[0] & 0xFF000000) { if (y < 0) { - y = i-1; // 1 pixel for marker line + y = i - 1; // 1 pixel for marker line splashWithMarkers = true; - } else + } + else { y = -1; splashWithMarkers = false; @@ -256,25 +256,25 @@ int SplashThread(void *arg) } } - TCHAR verString[256] = {0}; - TCHAR* mirandaVerString = mir_a2t(szVersion); - mir_sntprintf(verString, SIZEOF(verString), _T("%s%s"), szPrefix, mirandaVerString); - mir_free(mirandaVerString); - LOGFONT lf = {0}; - lf.lfHeight = 14; - _tcscpy_s(lf.lfFaceName, _T("Verdana")); - SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf)); - if (!splashWithMarkers) - { - SIZE v_sz = {0,0}; - GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)_tcslen(verString), &v_sz); - x = SplashBmp->getWidth()/2-(v_sz.cx/2); - y = SplashBmp->getHeight()-(SplashBmp->getHeight()*(100-90)/100); - } + TCHAR verString[256] = { 0 }; + TCHAR *mirandaVerString = mir_a2t(szVersion); + mir_sntprintf(verString, SIZEOF(verString), _T("%s%s"), szPrefix, mirandaVerString); + mir_free(mirandaVerString); + LOGFONT lf = { 0 }; + lf.lfHeight = 14; + mir_tstrcpy(lf.lfFaceName, _T("Verdana")); + SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf)); + if (!splashWithMarkers) + { + SIZE v_sz = { 0, 0 }; + GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)mir_tstrlen(verString), &v_sz); + x = SplashBmp->getWidth() / 2 - (v_sz.cx / 2); + y = SplashBmp->getHeight() - (SplashBmp->getHeight()*(100 - 90) / 100); + } - SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL-SplashBmp->getRow(y)[x])&0x00FFFFFFUL); - SetBkMode(SplashBmp->getDC(), TRANSPARENT); - SplashBmp->DrawText(verString, x, y); + SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL - SplashBmp->getRow(y)[x]) & 0x00FFFFFFUL); + SetBkMode(SplashBmp->getDC(), TRANSPARENT); + SplashBmp->DrawText(verString, x, y); } SetWindowLongPtr(hwndSplash, GWL_EXSTYLE, GetWindowLongPtr(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED); @@ -285,8 +285,7 @@ int SplashThread(void *arg) if (options.fadein) { // Fade in - int i; - for (i = 0; i < 255; i += options.fisteps) + for (int i = 0; i < 255; i += options.fisteps) { blend.SourceConstantAlpha = i; UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); @@ -300,9 +299,9 @@ int SplashThread(void *arg) { if (SetTimer(hwndSplash, 6, DWORD(arg), 0)) { - #ifdef _DEBUG - logMessage(_T("Timer TimeToShow"), _T("set")); - #endif +#ifdef _DEBUG + logMessage(_T("Timer TimeToShow"), _T("set")); +#endif } } else @@ -310,9 +309,9 @@ int SplashThread(void *arg) { if (SetTimer(hwndSplash, 8, 2000, 0)) { - #ifdef _DEBUG - logMessage(_T("Timer Modules loaded"), _T("set")); - #endif +#ifdef _DEBUG + logMessage(_T("Timer Modules loaded"), _T("set")); +#endif } } @@ -332,7 +331,6 @@ int SplashThread(void *arg) } ExitThread(0); - return 1; } BOOL ShowSplash(BOOL bpreview) @@ -344,17 +342,18 @@ BOOL ShowSplash(BOOL bpreview) SplashBmp = new MyBitmap; - #ifdef _DEBUG - logMessage(_T("Loading splash file"), szSplashFile); - #endif +#ifdef _DEBUG + logMessage(_T("Loading splash file"), szSplashFile); +#endif - SplashBmp->loadFromFile(szSplashFile, NULL); + if (!SplashBmp->loadFromFile(szSplashFile, NULL)) + return 0; DWORD threadID; - #ifdef _DEBUG - logMessage(_T("Thread"), _T("start")); - #endif +#ifdef _DEBUG + logMessage(_T("Thread"), _T("start")); +#endif if (bpreview) { @@ -362,25 +361,25 @@ BOOL ShowSplash(BOOL bpreview) DestroyWindow(hwndSplash); timeout = 2000; - #ifdef _DEBUG - logMessage(_T("Preview"), _T("yes")); - #endif +#ifdef _DEBUG + logMessage(_T("Preview"), _T("yes")); +#endif } else { timeout = options.showtime; - #ifdef _DEBUG - TCHAR b [40]; - mir_sntprintf(b, SIZEOF(b), _T("%d"), options.showtime); - logMessage(_T("Timeout"), b); - #endif +#ifdef _DEBUG + TCHAR b[40]; + mir_sntprintf(b, SIZEOF(b), _T("%d"), options.showtime); + logMessage(_T("Timeout"), b); +#endif } hSplashThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SplashThread, (LPVOID)timeout, 0, &threadID); - #ifdef _DEBUG - logMessage(_T("Thread"), _T("end")); - #endif +#ifdef _DEBUG + logMessage(_T("Thread"), _T("end")); +#endif CloseHandle(hSplashThread); hSplashThread = NULL; -- cgit v1.2.3