2004-01-17 21:34:54 +00:00
|
|
|
//
|
|
|
|
// Contributor(s):
|
2004-01-18 19:36:50 +00:00
|
|
|
// DirectX 8.1 Screen Saver Framework from Microsoft.
|
|
|
|
// Microsoft Knowledge Base Article - 79212
|
2004-01-17 21:34:54 +00:00
|
|
|
//
|
|
|
|
|
2007-08-14 17:23:30 +00:00
|
|
|
#ifndef _SCREENSAVER_WIN_H
|
|
|
|
#define _SCREENSAVER_WIN_H
|
2004-11-14 08:29:32 +00:00
|
|
|
|
2004-01-17 21:34:54 +00:00
|
|
|
|
2007-10-05 13:28:11 +00:00
|
|
|
#include <multimon.h>
|
2004-01-17 21:34:54 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Constants
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-11-18 04:09:10 +00:00
|
|
|
#define MAX_DISPLAYS 9
|
|
|
|
#define NO_ADAPTER 0xffffffff
|
|
|
|
#define NO_MONITOR 0xffffffff
|
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
#define BSF_ALLOWSFW 0x00000080
|
2004-11-18 04:09:10 +00:00
|
|
|
|
2004-12-03 19:47:54 +00:00
|
|
|
#define BOINC_WINDOW_CLASS_NAME _T("BOINC_app")
|
2004-01-17 21:34:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
//***************************************************************************************
|
|
|
|
// Modes of operation for screensaver
|
|
|
|
enum SaverMode
|
|
|
|
{
|
|
|
|
sm_config, // Config dialog box
|
|
|
|
sm_preview, // Mini preview window in Display Properties dialog
|
|
|
|
sm_full, // Full-on screensaver mode
|
|
|
|
sm_test, // Test mode
|
|
|
|
sm_passwordchange // Change password
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: struct INTERNALMONITORINFO
|
|
|
|
// Desc: Structure for holding information about a monitor
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
struct INTERNALMONITORINFO
|
|
|
|
{
|
|
|
|
TCHAR strDeviceName[128];
|
|
|
|
TCHAR strMonitorName[128];
|
|
|
|
HMONITOR hMonitor;
|
|
|
|
RECT rcScreen;
|
|
|
|
HWND hWnd;
|
|
|
|
|
2006-07-25 10:19:27 +00:00
|
|
|
DWORD dwTimeLastUpdate;
|
|
|
|
|
2004-01-17 21:34:54 +00:00
|
|
|
// Error message state
|
|
|
|
FLOAT xError;
|
|
|
|
FLOAT yError;
|
|
|
|
FLOAT widthError;
|
|
|
|
FLOAT heightError;
|
|
|
|
FLOAT xVelError;
|
|
|
|
FLOAT yVelError;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: struct LASTINPUTINFO
|
|
|
|
// Desc: Structure for holding input idle detection values on Win2k+
|
|
|
|
// systems.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
typedef struct tagLASTINPUTINFO {
|
|
|
|
UINT cbSize;
|
|
|
|
DWORD dwTime;
|
|
|
|
} LASTINPUTINFO, *PLASTINPUTINFO;
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: struct INTERNALMONITORINFO
|
|
|
|
// Desc: Use the following structure rather than DISPLAY_DEVICE, since some
|
|
|
|
// old versions of DISPLAY_DEVICE are missing the last two fields and
|
|
|
|
// this can cause problems with EnumDisplayDevices on Windows 2000.
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-01-17 21:34:54 +00:00
|
|
|
struct DISPLAY_DEVICE_FULL
|
|
|
|
{
|
|
|
|
DWORD cb;
|
|
|
|
TCHAR DeviceName[32];
|
|
|
|
TCHAR DeviceString[128];
|
|
|
|
DWORD StateFlags;
|
|
|
|
TCHAR DeviceID[128];
|
|
|
|
TCHAR DeviceKey[128];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
// Prototype for VerifyScreenSavePwd() in password.cpl, used on Win9x
|
2006-04-13 00:28:31 +00:00
|
|
|
typedef BOOL (WINAPI *VERIFYPWDPROC)(HWND);
|
2006-04-12 02:28:50 +00:00
|
|
|
|
|
|
|
// Prototype for GetLastInputInto() in user32.dll, used on Win2k or better.
|
|
|
|
typedef BOOL (WINAPI *MYGETLASTINPUTINFO)(PLASTINPUTINFO);
|
|
|
|
|
|
|
|
// Prototype for GetLastInputInto() in user32.dll, used on Win2k or better.
|
|
|
|
typedef BOOL (WINAPI *MYISHUNGAPPWINDOW)(HWND hWnd);
|
|
|
|
|
|
|
|
// Prototype for BroadcastSystemMessage() in user32.dll.
|
|
|
|
typedef long (WINAPI *MYBROADCASTSYSTEMMESSAGE)(DWORD dwFlags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
2006-04-13 00:28:31 +00:00
|
|
|
// Prototype for SHGetFolderPath() in shlwapi.dll.
|
|
|
|
typedef HRESULT (WINAPI *MYSHGETFOLDERPATH)(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPSTR pszPath);
|
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
|
2004-01-17 21:34:54 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Name: class CScreensaver
|
|
|
|
// Desc: Screensaver class
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class CScreensaver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CScreensaver();
|
|
|
|
|
|
|
|
virtual HRESULT Create( HINSTANCE hInstance );
|
|
|
|
virtual INT Run();
|
|
|
|
HRESULT DisplayErrorMsg( HRESULT hr );
|
|
|
|
|
|
|
|
|
2005-04-05 10:23:15 +00:00
|
|
|
//
|
|
|
|
// Infrastructure layer
|
|
|
|
//
|
2004-01-17 21:34:54 +00:00
|
|
|
protected:
|
|
|
|
SaverMode ParseCommandLine( TCHAR* pstrCommandLine );
|
|
|
|
VOID EnumMonitors( VOID );
|
2004-01-19 19:45:52 +00:00
|
|
|
|
2005-04-05 10:23:15 +00:00
|
|
|
int UtilGetRegKey(LPCTSTR name, DWORD &keyval);
|
|
|
|
int UtilSetRegKey(LPCTSTR name, DWORD value);
|
|
|
|
int UtilGetRegStartupStr(LPCTSTR name, LPTSTR str);
|
|
|
|
|
|
|
|
BOOL IsConfigStartupBOINC();
|
|
|
|
|
|
|
|
BOOL CreateInfrastructureMutexes();
|
|
|
|
|
|
|
|
BOOL GetError( BOOL& bErrorMode, HRESULT& hrError, TCHAR* pszError, size_t iErrorSize );
|
|
|
|
BOOL SetError( BOOL bErrorMode, HRESULT hrError );
|
|
|
|
VOID UpdateErrorBoxText();
|
|
|
|
virtual BOOL GetTextForError( HRESULT hr, TCHAR* pszError, DWORD dwNumChars );
|
|
|
|
|
|
|
|
|
|
|
|
// Variables for non-fatal error management
|
|
|
|
HANDLE m_hErrorManagementMutex;
|
|
|
|
BOOL m_bErrorMode; // Whether to display an error
|
|
|
|
HRESULT m_hrError; // Error code to display
|
|
|
|
TCHAR m_szError[400]; // Error message text
|
|
|
|
|
|
|
|
BOOL m_bBOINCConfigChecked;
|
|
|
|
BOOL m_bBOINCStartupConfigured;
|
|
|
|
DWORD m_dwBlankScreen;
|
|
|
|
DWORD m_dwBlankTime;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Data management layer
|
|
|
|
//
|
|
|
|
protected:
|
|
|
|
BOOL CreateDataManagementThread();
|
2007-10-09 10:01:27 +00:00
|
|
|
BOOL DestroyDataManagementThread();
|
2005-04-05 10:23:15 +00:00
|
|
|
|
|
|
|
DWORD WINAPI DataManagementProc();
|
|
|
|
static DWORD WINAPI DataManagementProcStub( LPVOID lpParam );
|
2007-10-05 13:28:11 +00:00
|
|
|
void CheckForegroundWindow();
|
|
|
|
int terminate_screensaver(HANDLE& graphics_application, RESULT *worker_app);
|
|
|
|
int launch_screensaver(RESULT* rp, HANDLE& graphics_application);
|
|
|
|
void HandleRPCError(void);
|
|
|
|
|
|
|
|
// Determine if two RESULT pointers refer to the same task
|
|
|
|
bool is_same_task(RESULT* taska, RESULT* taskb);
|
2005-04-05 10:23:15 +00:00
|
|
|
|
2007-10-05 13:28:11 +00:00
|
|
|
// Count the number of active graphics-capable apps
|
|
|
|
int count_active_graphic_apps(RESULTS& results, RESULT* exclude = NULL);
|
|
|
|
|
|
|
|
// Choose a ramdom graphics application from the vector that
|
|
|
|
// was passed in.
|
|
|
|
|
|
|
|
RESULT* get_random_graphics_app(RESULTS& results, RESULT* exclude = NULL);
|
|
|
|
|
|
|
|
RPC_CLIENT* rpc;
|
2005-04-05 10:23:15 +00:00
|
|
|
CC_STATE state;
|
2007-08-14 17:23:30 +00:00
|
|
|
RESULTS results;
|
2007-09-26 10:17:43 +00:00
|
|
|
RESULT m_running_result;
|
2007-10-05 13:28:11 +00:00
|
|
|
bool m_updating_results;
|
2005-04-05 10:23:15 +00:00
|
|
|
|
|
|
|
HANDLE m_hDataManagementThread;
|
2007-08-14 17:23:30 +00:00
|
|
|
HANDLE m_hGraphicsApplication;
|
2005-04-05 10:23:15 +00:00
|
|
|
BOOL m_bResetCoreState;
|
2007-10-05 13:28:11 +00:00
|
|
|
bool m_QuitDataManagementProc;
|
2008-01-30 02:47:06 +00:00
|
|
|
bool m_bV5_GFX_app_is_running;
|
2007-10-02 21:44:14 +00:00
|
|
|
int m_iLastResultShown;
|
|
|
|
time_t m_tLastResultChangeTime;
|
2007-10-05 13:28:11 +00:00
|
|
|
time_t m_tThreadCreateTime;
|
2005-04-05 10:23:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Presentation layer
|
|
|
|
//
|
|
|
|
protected:
|
2004-01-19 19:45:52 +00:00
|
|
|
HRESULT CreateSaverWindow();
|
|
|
|
VOID UpdateErrorBox();
|
|
|
|
VOID InterruptSaver();
|
|
|
|
VOID ShutdownSaver();
|
2004-01-17 21:34:54 +00:00
|
|
|
VOID ChangePassword();
|
|
|
|
|
|
|
|
VOID DoConfig();
|
|
|
|
HRESULT DoSaver();
|
2006-07-25 10:19:27 +00:00
|
|
|
VOID DoPaint( HWND hwnd, HDC hdc, LPPAINTSTRUCT lpps );
|
2004-01-17 21:34:54 +00:00
|
|
|
|
2004-01-19 19:45:52 +00:00
|
|
|
void DrawTransparentBitmap(HDC hdc, HBITMAP hBitmap, LONG xStart, LONG yStart, COLORREF cTransparentColor);
|
2004-01-17 21:34:54 +00:00
|
|
|
|
2005-03-23 00:16:58 +00:00
|
|
|
LRESULT SaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2005-01-13 01:52:56 +00:00
|
|
|
INT_PTR ConfigureDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2004-01-17 21:34:54 +00:00
|
|
|
|
2005-03-23 00:16:58 +00:00
|
|
|
static LRESULT CALLBACK SaverProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2004-01-17 21:34:54 +00:00
|
|
|
static INT_PTR CALLBACK ConfigureDialogProcStub( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SaverMode m_SaverMode; // sm_config, sm_full, sm_preview, etc.
|
|
|
|
BOOL m_bAllScreensSame; // If TRUE, show same image on all screens
|
|
|
|
HWND m_hWnd; // Focus window and device window on primary
|
|
|
|
HWND m_hWndParent;
|
|
|
|
HINSTANCE m_hInstance;
|
|
|
|
BOOL m_bWaitForInputIdle; // Used to pause when preview starts
|
|
|
|
DWORD m_dwSaverMouseMoveCount;
|
|
|
|
BOOL m_bIs9x;
|
|
|
|
BOOL m_bCheckingSaverPassword;
|
|
|
|
BOOL m_bWindowed;
|
|
|
|
|
|
|
|
INTERNALMONITORINFO m_Monitors[MAX_DISPLAYS];
|
|
|
|
DWORD m_dwNumMonitors;
|
|
|
|
RECT m_rcRenderTotal; // Rect of entire area to be rendered
|
|
|
|
RECT m_rcRenderCurDevice; // Rect of render area of current device
|
|
|
|
BOOL m_bPaintingInitialized;
|
|
|
|
|
|
|
|
TCHAR m_strWindowTitle[200]; // Title for the app's window
|
2005-04-05 10:23:15 +00:00
|
|
|
|
2006-04-12 02:28:50 +00:00
|
|
|
DWORD m_dwLastInputTimeAtStartup;
|
2004-01-17 21:34:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|