From 878d72910cccf4f84c7cb45bb4c11134920f3166 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Aug 2015 11:49:54 +0000 Subject: - naming conflict; - warning fixes; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@14988 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SplashScreen/src/bitmap_funcs.cpp | 4 +- plugins/SplashScreen/src/main.cpp | 115 +++--- plugins/SplashScreen/src/options.cpp | 634 ++++++++++++++---------------- plugins/SplashScreen/src/splash.cpp | 6 +- 4 files changed, 356 insertions(+), 403 deletions(-) (limited to 'plugins/SplashScreen') diff --git a/plugins/SplashScreen/src/bitmap_funcs.cpp b/plugins/SplashScreen/src/bitmap_funcs.cpp index 5359adc3d2..46e8ee86c7 100644 --- a/plugins/SplashScreen/src/bitmap_funcs.cpp +++ b/plugins/SplashScreen/src/bitmap_funcs.cpp @@ -133,9 +133,9 @@ bool MyBitmap::loadFromFile(TCHAR *fn) HBITMAP hBmpLoaded = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, IMGL_TCHAR); if (!hBmpLoaded) { -#ifdef _DEBUG + #ifdef _DEBUG logMessage(_T("MyBitmap::loadFromFile"), _T("Bitmap load failed")); -#endif + #endif return false; } diff --git a/plugins/SplashScreen/src/main.cpp b/plugins/SplashScreen/src/main.cpp index 4f7007a5ab..88dd563466 100644 --- a/plugins/SplashScreen/src/main.cpp +++ b/plugins/SplashScreen/src/main.cpp @@ -1,21 +1,21 @@ /* - Splash Screen Plugin for Miranda NG (www.miranda-ng.org) - (c) 2004-2007 nullbie, (c) 2005-2007 Thief +Splash Screen Plugin for Miranda NG (www.miranda-ng.org) +(c) 2004-2007 nullbie, (c) 2005-2007 Thief - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - 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 - */ +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 "stdafx.h" @@ -62,14 +62,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) void SplashMain() { - if (bstartup) - { + if (bstartup) { // Retrive path to exe of current running Miranda is located szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%")); mir_sntprintf(szhAdvaimgPath, _countof(szhAdvaimgPath), _T("%s\\plugins\\advaimg.dll"), szMirDir); CallService(MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, (LPARAM)szVersion); -#ifdef _DEBUG + #ifdef _DEBUG mir_sntprintf(szLogFile, _countof(szLogFile), _T("%s\\%s.log"), szMirDir, _T(__PLUGIN_NAME)); initLog(); TCHAR *mirandaVerString = mir_a2t(szVersion); @@ -77,24 +76,21 @@ void SplashMain() mir_free(mirandaVerString); logMessage(_T("Dll Name"), _T(__FILENAME)); logMessage(_T("Advaimg path"), szhAdvaimgPath); -#endif + #endif ReadDbConfig(); } - if (bstartup & (options.active == 1)) - { + if (bstartup & (options.active == 1)) { DBVARIANT dbv = { 0 }; - if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv)) - { + if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv)) { mir_tstrcpy(szPrefix, dbv.ptszVal); db_free(&dbv); } else mir_tstrcpy(szPrefix, _T("")); - if (!db_get_ts(NULL, MODNAME, "Path", &dbv)) - { + if (!db_get_ts(NULL, MODNAME, "Path", &dbv)) { mir_tstrcpy(inBuf, dbv.ptszVal); db_free(&dbv); } @@ -112,8 +108,7 @@ void SplashMain() else mir_tstrcpy(szSplashFile, inBuf); - if (!db_get_ts(NULL, MODNAME, "Sound", &dbv)) - { + if (!db_get_ts(NULL, MODNAME, "Sound", &dbv)) { mir_tstrcpy(inBuf, dbv.ptszVal); db_free(&dbv); } @@ -131,9 +126,9 @@ void SplashMain() else mir_tstrcpy(szSoundFile, inBuf); -#ifdef _DEBUG + #ifdef _DEBUG logMessage(_T("SoundFilePath"), szSoundFile); -#endif + #endif TCHAR szOldPath[MAX_PATH] = { 0 }; @@ -155,30 +150,27 @@ void SplashMain() HANDLE hFind = INVALID_HANDLE_VALUE; WIN32_FIND_DATA ffd; hFind = FindFirstFile(szSearch, &ffd); - if (hFind != INVALID_HANDLE_VALUE) - { - do - { - if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) - { -#ifdef _DEBUG + if (hFind != INVALID_HANDLE_VALUE) { + do { + if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) { + #ifdef _DEBUG logMessage(_T("Found file"), ffd.cFileName); -#endif + #endif //files = new char[mir_strlen(ffd.cFileName)]; //files[filescount] = new char[mir_strlen(ffd.cFileName)]; TCHAR ext[5]; wmemcpy(ext, ffd.cFileName + (mir_tstrlen(ffd.cFileName) - 4), 5); -#ifdef _DEBUG + #ifdef _DEBUG logMessage(_T("Extention"), ext); -#endif + #endif if (mir_tstrcmpi(ext, _T(".png")) & mir_tstrcmpi(ext, _T(".bmp"))) continue; -#ifdef _DEBUG + #ifdef _DEBUG logMessage(_T("File has valid ext"), ext); -#endif + #endif mir_tstrcpy(files[filescount++], ffd.cFileName); } //if } while (FindNextFile(hFind, &ffd)); @@ -189,9 +181,9 @@ void SplashMain() mir_sntprintf(szSplashFile, _countof(szSplashFile), _T("%s\\%s"), szSplashDir, files[r - 1]); -#ifdef _DEBUG + #ifdef _DEBUG logMessage(_T("final file"), szSplashFile); -#endif + #endif FindClose(hFind); } //if } @@ -204,33 +196,30 @@ void SplashMain() int PlugDisableHook(WPARAM wParam, LPARAM lParam) { -#ifdef _DEBUG + #ifdef _DEBUG TCHAR buf[128]; -#endif + #endif DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; 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"))) - { + 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 + #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 + #endif } - if (!mir_tstrcmp(tszModule, _T("PluginDisable")) & (!mir_tstrcmp(tszSetting, szDllName))) - { + if (!mir_tstrcmp(tszModule, _T("PluginDisable")) & (!mir_tstrcmp(tszSetting, szDllName))) { db_set_b(NULL, MODNAME, "Active", cws->value.bVal); -#ifdef _DEBUG + #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 + #endif } } mir_free(tszModule); @@ -243,13 +232,11 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) { bmodulesloaded = true; // all modules are loaded now, let other parts know about this fact - if (hwndSplash) - { - if (PostMessage(hwndSplash, WM_LOADED, 0, 0)) - { -#ifdef _DEBUG + if (hwndSplash) { + if (PostMessage(hwndSplash, WM_LOADED, 0, 0)) { + #ifdef _DEBUG logMessage(_T("Posted WM_LOADED message"), _T("done")); -#endif + #endif } } @@ -260,9 +247,9 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) // Service to call splash CreateServiceFunction(MS_SHOWSPLASH, ShowSplashService); -#ifdef _DEBUG + #ifdef _DEBUG logMessage(_T("Loading modules"), _T("done")); -#endif + #endif return 0; } @@ -293,9 +280,9 @@ extern "C" int __declspec(dllexport) Unload(void) if (hAdvaimg) FreeLibrary(hAdvaimg); -#ifdef _DEBUG + #ifdef _DEBUG logMessage(_T("Unload"), _T("Job done")); -#endif + #endif return 0; } diff --git a/plugins/SplashScreen/src/options.cpp b/plugins/SplashScreen/src/options.cpp index 95a3f09e75..70f0b2bb3e 100644 --- a/plugins/SplashScreen/src/options.cpp +++ b/plugins/SplashScreen/src/options.cpp @@ -43,384 +43,350 @@ BOOL Exists(LPCTSTR strName) INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { + switch (msg) { 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: - { - 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 - { + 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); - } - if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT)) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true); - EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true); - } - else - { + EnableWindow(GetDlgItem(hwndDlg, IDC_FADEOUT), false); EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false); EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false); } - - if ((HWND)lParam != GetFocus()) - return 0; else { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; + 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); } - break; + + return TRUE; } - case IDC_CHOOSESPLASH: + case WM_COMMAND: { - TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; - TCHAR *pos; - - if (Exists(szSplashFile)) - { - 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); - } + switch (LOWORD(wParam)) { + case IDC_PREVIEW: + { + ShowSplash(true); + break; + } - OPENFILENAME ofn = { 0 }; - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - TCHAR tmp[MAX_PATH]; - mir_sntprintf(tmp, _countof(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); - -#ifdef _DEBUG - logMessage(_T("Set path"), szSplashFile); -#endif - - // Make path relative - int result = PathToRelativeT(szTempPath, szPath2Spash); - if (result && mir_tstrlen(szPath2Spash) > 0) + 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 (options.random) - { - TCHAR *pos; - pos = _tcsrchr(szPath2Spash, _T('\\')); + 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); + } + + if ((HWND)lParam != GetFocus()) + return 0; + else { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; + } + + case IDC_CHOOSESPLASH: + { + TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; + + if (Exists(szSplashFile)) { + mir_tstrcpy(initDir, szSplashFile); + TCHAR *pos = _tcsrchr(initDir, _T('\\')); if (pos != NULL) - { *pos = 0; - mir_tstrcat(szPath2Spash, _T("\\")); + } + else { + szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%")); + mir_tstrcpy(initDir, szMirDir); + mir_free(szMirDir); + } + + TCHAR tmp[MAX_PATH]; + mir_sntprintf(tmp, _countof(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0); + + OPENFILENAME ofn = { 0 }; + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.lpstrFilter = tmp; + 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); + + #ifdef _DEBUG + logMessage(_T("Set path"), szSplashFile); + #endif + // Make path relative + int result = PathToRelativeT(szTempPath, szPath2Spash); + if (result && mir_tstrlen(szPath2Spash) > 0) { + if (options.random) { + TCHAR *pos = _tcsrchr(szPath2Spash, _T('\\')); + if (pos != NULL) { + *pos = 0; + mir_tstrcat(szPath2Spash, _T("\\")); + } + } + + SetDlgItemText(hwndDlg, IDC_SPLASHPATH, szPath2Spash); } + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } - SetDlgItemText(hwndDlg, IDC_SPLASHPATH, szPath2Spash); + break; } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - - break; - } + case IDC_CHOOSESND: + { + TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; + TCHAR *pos; - case IDC_CHOOSESND: - { - TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH]; - TCHAR *pos; - - 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); - } + 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); + } - OPENFILENAME ofn = { 0 }; - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - TCHAR tmp[MAX_PATH]; - mir_sntprintf(tmp, _countof(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); - -#ifdef _DEBUG - logMessage(_T("Set sound path"), szSoundFile); -#endif - - // 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, _countof(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); + + #ifdef _DEBUG + logMessage(_T("Set sound path"), szSoundFile); + #endif + + // 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); + } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } } - break; + default: + { + if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) + return 0; + else + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } + break; } - 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) { - case PSN_APPLY: - { - TCHAR tmp[MAX_PATH]; + if (((LPNMHDR)lParam)->idFrom == 0) + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + { + TCHAR tmp[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_SPLASHPATH, tmp, _countof(tmp)); - db_set_ts(NULL, MODNAME, "Path", tmp); + GetDlgItemText(hwndDlg, IDC_SPLASHPATH, tmp, _countof(tmp)); + db_set_ts(NULL, MODNAME, "Path", tmp); - GetDlgItemText(hwndDlg, IDC_SNDPATH, tmp, _countof(tmp)); - db_set_ts(NULL, MODNAME, "Sound", tmp); + GetDlgItemText(hwndDlg, IDC_SNDPATH, tmp, _countof(tmp)); + db_set_ts(NULL, MODNAME, "Sound", tmp); - GetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, tmp, _countof(tmp)); - db_set_ts(NULL, MODNAME, "VersionPrefix", tmp); - mir_tstrcpy(szPrefix, tmp); + GetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, tmp, _countof(tmp)); + db_set_ts(NULL, MODNAME, "VersionPrefix", tmp); + mir_tstrcpy(szPrefix, tmp); - GetDlgItemText(hwndDlg, IDC_SHOWTIME, tmp, _countof(tmp)); - db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp)); - options.showtime = _ttoi(tmp); + GetDlgItemText(hwndDlg, IDC_SHOWTIME, tmp, _countof(tmp)); + db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp)); + options.showtime = _ttoi(tmp); - GetDlgItemText(hwndDlg, IDC_FISTEP, tmp, _countof(tmp)); - db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp)); - options.fisteps = _ttoi(tmp); + GetDlgItemText(hwndDlg, IDC_FISTEP, tmp, _countof(tmp)); + db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp)); + options.fisteps = _ttoi(tmp); - GetDlgItemText(hwndDlg, IDC_FOSTEP, tmp, _countof(tmp)); - db_set_dw(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp)); - options.fosteps = _ttoi(tmp); + GetDlgItemText(hwndDlg, IDC_FOSTEP, tmp, _countof(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_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_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; + 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; + } } - return TRUE; - } } - } case WM_DESTROY: break; diff --git a/plugins/SplashScreen/src/splash.cpp b/plugins/SplashScreen/src/splash.cpp index df0f3367e9..6550f5fda0 100644 --- a/plugins/SplashScreen/src/splash.cpp +++ b/plugins/SplashScreen/src/splash.cpp @@ -263,8 +263,8 @@ void __cdecl SplashThread(void *arg) blend.SourceConstantAlpha = 255; UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA); - if (DWORD(arg) > 0) { - if (SetTimer(hwndSplash, 6, DWORD(arg), 0)) { + if (DWORD_PTR(arg) > 0) { + if (SetTimer(hwndSplash, 6, DWORD_PTR(arg), 0)) { #ifdef _DEBUG logMessage(_T("Timer TimeToShow"), _T("set")); #endif @@ -338,4 +338,4 @@ BOOL ShowSplash(BOOL bpreview) logMessage(_T("Thread"), _T("end")); #endif return 1; -} \ No newline at end of file +} -- cgit v1.2.3