diff options
Diffstat (limited to 'splashscreen/src/splash.cpp')
-rw-r--r-- | splashscreen/src/splash.cpp | 300 |
1 files changed, 144 insertions, 156 deletions
diff --git a/splashscreen/src/splash.cpp b/splashscreen/src/splash.cpp index a5c6a14..3bac389 100644 --- a/splashscreen/src/splash.cpp +++ b/splashscreen/src/splash.cpp @@ -1,4 +1,4 @@ -/*
+\\/*
Splash Screen Plugin for Miranda-IM (www.miranda-im.org)
(c) 2004-2007 nullbie, (c) 2005-2007 Thief
@@ -18,75 +18,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA File name : $URL: http://svn.miranda.im/mainrepo/splashscreen/trunk/src/splash.cpp $
Revision : $Rev: 1585 $
-Last change on : $Date: 2010-04-09 12:13:29 +0300 (Пт, 09 апр 2010) $
+Last change on : $Date: 2010-04-09 13:13:29 +0400 (Пт, 09 апр 2010) $
Last change by : $Author: ghazan $
*/
#include "headers.h"
-#include "splash.h"
-bool ShowSplash(bool bpreview)
-{
- if (bpreview && bpreviewruns) return 0;
-
- if (bpreview) bpreviewruns = true;
- unsigned long timeout = 0;
-
- SplashBmp = new MyBitmap;
-
-#ifdef _DEBUG
- logMessage("Loading splash file", szSplashFile);
-#endif
+BOOL bpreviewruns;
+MyBitmap *SplashBmp, *tmpBmp;
- SplashBmp->loadFromFile(szSplashFile, NULL);
-
- DWORD threadID;
-
-#ifdef _DEBUG
- logMessage("Thread","start");
-#endif
-
- if (bpreview)
- {
- ShowWindow(hwndSplash, SW_HIDE);
- DestroyWindow(hwndSplash);
-
- timeout = 2000;
-#ifdef _DEBUG
- logMessage("Preview","yes");
-#endif
- }
- else
- {
- timeout = options.showtime;
-#ifdef _DEBUG
- char b [40];
- sprintf(b,"%d",options.showtime);
- logMessage("Timeout",b);
-#endif
- }
-
- hSplashThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SplashThread, (LPVOID)timeout, 0, &threadID);
-
-#ifdef _DEBUG
- logMessage("Thread","end");
-#endif
-
- CloseHandle(hSplashThread);
- hSplashThread = NULL;
-
- return 1;
-}
LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
- case WM_LOADED:
+ case WM_LOADED:
{
-#ifdef _DEBUG
- logMessage("WM_LOADED","called");
-#endif
+ #ifdef _DEBUG
+ logMessage(_T("WM_LOADED"), _T("called"));
+ #endif
if (!MyUpdateLayeredWindow) ShowWindow(hwndSplash, SW_SHOWNORMAL);
if (!options.showtime) SetTimer(hwnd, 7, 2000, 0);
@@ -94,59 +44,58 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM 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
- char b [40];
- sprintf(b,"%d",wParam);
- logMessage("Timer ID",b);
- sprintf(b,"%d",options.showtime);
- logMessage("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 (wParam == 6)
+ if (options.showtime > 0) //TimeToShow enabled
{
- PostMessage(hwnd, WM_CLOSE, 0, 0);
-#ifdef _DEBUG
- logMessage("Showtime timer","triggered");
-#endif
- }
- }
- else
- {
- PostMessage(hwnd, WM_CLOSE, 0, 0);
- if (wParam == 7)
- {
-#ifdef _DEBUG
- logMessage("On Modules Loaded timer","triggered");
-#endif
+ if (wParam == 6)
+ {
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ #ifdef _DEBUG
+ logMessage(_T("Showtime timer"), _T("triggered"));
+ #endif
+ }
}
- if (wParam == 8)
+ else
{
-#ifdef _DEBUG
- logMessage("On Modules Loaded workaround","triggered");
-#endif
+ 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
+ }
}
- }
- break;
-
- case WM_RBUTTONDOWN:
- {
- ShowWindow(hwndSplash, SW_HIDE);
- DestroyWindow(hwndSplash);
- bpreviewruns = false; // preview is stopped.
+ break;
- break;
- }
+ case WM_RBUTTONDOWN:
+ {
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+ bpreviewruns = false; // preview is stopped.
+ break;
+ }
- case WM_CLOSE:
+ case WM_CLOSE:
{
if (MyUpdateLayeredWindow) // Win 2000+
{
@@ -179,31 +128,29 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM DestroyWindow(hwndSplash);
}
- case WM_MOUSEMOVE:
+ case WM_MOUSEMOVE:
{
if (bserviceinvoked)
- {
PostMessage(hwnd, WM_CLOSE, 0, 0);
- }
break;
}
- case WM_DESTROY:
+ case WM_DESTROY:
{
PostQuitMessage(0);
-#ifdef _DEBUG
- logMessage("WM_DESTROY","called");
-#endif
+ #ifdef _DEBUG
+ logMessage(_T("WM_DESTROY"), _T("called"));
+ #endif
break;
}
- case WM_PAINT:
+ case WM_PAINT:
{
if (!MyUpdateLayeredWindow) // Win 9x
{
-#ifdef _DEBUG
- logMessage("WM_PAINT","painting..");
-#endif
+ #ifdef _DEBUG
+ logMessage(_T("WM_PAINT"), _T("painting.."));
+ #endif
PAINTSTRUCT ps;
BeginPaint(hwndSplash, &ps);
BitBlt(ps.hdc, 0, 0, SplashBmp->getWidth(), SplashBmp->getHeight(), tmpBmp->getDC(), 0, 0, SRCCOPY);
@@ -212,9 +159,9 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM break;
}
- ShowWindow(hwndSplash, SW_HIDE);
- DestroyWindow(hwndSplash);
- break;
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+ break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
@@ -223,30 +170,15 @@ LRESULT CALLBACK SplashWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM int SplashThread(void *arg)
{
// Old code, doesn't support mp3 files
- if (options.playsnd) PlaySound(szSoundFile, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT);
-
- /*
- // Buggy code, dropped for now
- if (options.playsnd)
+ //if (options.playsnd) PlaySound(szSoundFile, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT);
+ if (options.playsnd)
{
- char cmd[32] = "play";
-
- // TODO: figure out if this is working.
- if(options.loopsnd) strcat(cmd, " repeat");
-
- #ifdef _DEBUG
- logMessage("Command",cmd);
- #endif
-
- if(strlen(szSoundFile) && (mciWnd = MCIWndCreate(NULL, 0, MCIWNDF_NOPLAYBAR, szSoundFile)) != NULL)
- {
- SetWindowPos(mciWnd,HWND_BOTTOM,-1000,-1000,0,0,SWP_NOSIZE);
- ShowWindow(mciWnd, SW_HIDE);
- if(MCIWndCanPlay(mciWnd))
- MCIWndSendString(mciWnd, cmd);
- }
+ TCHAR cmd[MAX_PATH];
+ mir_sntprintf(cmd, SIZEOF(cmd), _T("open \"%s\" type mpegvideo alias %s"), szSoundFile, szSoundFile);
+ mciSendString(cmd, NULL, 0, 0);
+ mir_sntprintf(cmd, SIZEOF(cmd), _T("play %s from 0"), szSoundFile);
+ mciSendString(cmd, NULL, 0, 0);
}
- */
WNDCLASSEX wcl;
wcl.cbSize = sizeof(wcl);
@@ -259,7 +191,7 @@ int SplashThread(void *arg) wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszMenuName = NULL;
- wcl.lpszClassName = SPLASH_CLASS;
+ wcl.lpszClassName = _T(SPLASH_CLASS);
wcl.hIconSm = NULL;
RegisterClassEx(&wcl);
@@ -279,7 +211,7 @@ int SplashThread(void *arg) hwndSplash = CreateWindowEx(
WS_EX_TOOLWINDOW | WS_EX_TOPMOST,//dwStyleEx
- SPLASH_CLASS, //Class name
+ _T(SPLASH_CLASS), //Class name
NULL, //Title
DS_SETFONT | DS_FIXEDSYS | WS_POPUP, //dwStyle
WindowRect.left, // x
@@ -339,21 +271,18 @@ int SplashThread(void *arg) }
}
- char verString[256] = {0};
- //char* ptr_verString = &verString;
- /*
- if (strlen(szPrefix)) strcat(verString,(char*)szPrefix);
- strcat(verString,mirandaVerString);
- */
- mir_snprintf(verString, sizeof(verString), "%s%s", szPrefix, mirandaVerString);
+ 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;
- strcpy(lf.lfFaceName, "Verdana");
+ _tcscpy_s(lf.lfFaceName, _T("Verdana"));
SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf));
if (!splashWithMarkers)
{
SIZE v_sz = {0,0};
- GetTextExtentPoint32(SplashBmp->getDC(),verString,strlen(verString),&v_sz);
+ 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);
}
@@ -361,13 +290,13 @@ int SplashThread(void *arg) SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL-SplashBmp->getRow(y)[x])&0x00FFFFFFUL);
//SplashBmp->DrawText(verString,SplashBmp->getWidth()/2-(v_sz.cx/2),SplashBmp->getHeight()-30);
SetBkMode(SplashBmp->getDC(), TRANSPARENT);
- SplashBmp->DrawText(verString,x,y);
+ SplashBmp->DrawText(verString, x, y);
//free (ptr_verString);
}
if (MyUpdateLayeredWindow) // Win 2000+
{
- SetWindowLong(hwndSplash, GWL_EXSTYLE, GetWindowLong(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED);
+ SetWindowLongPtr(hwndSplash, GWL_EXSTYLE, GetWindowLongPtr(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED);
/*
if (splashWithMarkers)
{
@@ -421,9 +350,9 @@ int SplashThread(void *arg) {
if (SetTimer(hwndSplash, 6, DWORD(arg), 0))
{
-#ifdef _DEBUG
- logMessage("Timer TimeToShow","set");
-#endif
+ #ifdef _DEBUG
+ logMessage(_T("Timer TimeToShow"), _T("set"));
+ #endif
}
}
else
@@ -431,9 +360,9 @@ int SplashThread(void *arg) {
if (SetTimer(hwndSplash, 8, 2000, 0))
{
-#ifdef _DEBUG
- logMessage("Timer Modules loaded","set");
-#endif
+ #ifdef _DEBUG
+ logMessage(_T("Timer Modules loaded"), _T("set"));
+ #endif
}
}
@@ -445,6 +374,65 @@ int SplashThread(void *arg) DispatchMessage(&msg);
}
+ if (options.playsnd)
+ {
+ TCHAR cmd[MAX_PATH];
+ mir_sntprintf(cmd, SIZEOF(cmd), _T("close %s"), szSoundFile);
+ mciSendString(cmd, NULL, 0, 0);
+ }
ExitThread(0);
return 1;
}
+
+BOOL ShowSplash(BOOL bpreview)
+{
+ if (bpreview && bpreviewruns) return 0;
+
+ if (bpreview) bpreviewruns = true;
+ unsigned long timeout = 0;
+
+ SplashBmp = new MyBitmap;
+
+ #ifdef _DEBUG
+ logMessage(_T("Loading splash file"), szSplashFile);
+ #endif
+
+ SplashBmp->loadFromFile(szSplashFile, NULL);
+
+ DWORD threadID;
+
+ #ifdef _DEBUG
+ logMessage(_T("Thread"), _T("start"));
+ #endif
+
+ if (bpreview)
+ {
+ ShowWindow(hwndSplash, SW_HIDE);
+ DestroyWindow(hwndSplash);
+
+ timeout = 2000;
+ #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
+ }
+
+ hSplashThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SplashThread, (LPVOID)timeout, 0, &threadID);
+
+ #ifdef _DEBUG
+ logMessage(_T("Thread"), _T("end"));
+ #endif
+
+ CloseHandle(hSplashThread);
+ hSplashThread = NULL;
+
+ return 1;
+}
\ No newline at end of file |