mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 06:52:56 +00:00
- Compile screensavers as UNICODE applications + minor fixes (Part 2/2)
svn path=/trunk/; revision=29966
This commit is contained in:
parent
e985f75055
commit
47f240c7fb
8 changed files with 646 additions and 652 deletions
|
@ -236,26 +236,25 @@ void InitSaver(HWND hwndParent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseCommandLine(PSTR szCmdLine, int *chOption, HWND *hwndParent)
|
//
|
||||||
|
// Look for any options Windows has passed to us:
|
||||||
|
//
|
||||||
|
// -a <hwnd> (set password)
|
||||||
|
// -s (screensave)
|
||||||
|
// -p <hwnd> (preview)
|
||||||
|
// -c <hwnd> (configure)
|
||||||
|
//
|
||||||
|
VOID ParseCommandLine(LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
|
||||||
{
|
{
|
||||||
int ch;
|
UCHAR ch = *szCmdLine++;
|
||||||
|
|
||||||
if (!strlen(szCmdLine))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ch = *szCmdLine++;
|
|
||||||
|
|
||||||
if(ch == '-' || ch == '/')
|
if(ch == '-' || ch == '/')
|
||||||
ch = *szCmdLine++;
|
ch = *szCmdLine++;
|
||||||
|
|
||||||
if(ch >= 'A' && ch <= 'Z')
|
if(ch >= 'A' && ch <= 'Z')
|
||||||
ch += 'a' - 'A';
|
ch += 'a' - 'A'; //convert to lower case
|
||||||
|
|
||||||
*chOption = ch;
|
*chOption = ch;
|
||||||
|
|
||||||
if (ch == 's' || ch == 'c')
|
|
||||||
return;
|
|
||||||
|
|
||||||
ch = *szCmdLine++;
|
ch = *szCmdLine++;
|
||||||
|
|
||||||
if(ch == ':')
|
if(ch == ':')
|
||||||
|
@ -266,11 +265,11 @@ void ParseCommandLine(PSTR szCmdLine, int *chOption, HWND *hwndParent)
|
||||||
|
|
||||||
if(isdigit(ch))
|
if(isdigit(ch))
|
||||||
{
|
{
|
||||||
unsigned int i = atoi(szCmdLine - 1);
|
unsigned int i = _wtoi(szCmdLine - 1);
|
||||||
*hwndParent = (HWND)i;
|
*hwndParent = (HWND)i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*hwndParent = 0;
|
*hwndParent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configure(void)
|
void Configure(void)
|
||||||
|
@ -294,13 +293,13 @@ void Configure(void)
|
||||||
MB_OK | MB_ICONWARNING);
|
MB_OK | MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI WinMain (HINSTANCE hInst,
|
int CALLBACK wWinMain (HINSTANCE hInst,
|
||||||
HINSTANCE hPrev,
|
HINSTANCE hPrev,
|
||||||
LPSTR lpCmdLine,
|
LPWSTR lpCmdLine,
|
||||||
int iCmdShow)
|
int iCmdShow)
|
||||||
{
|
{
|
||||||
HWND hwndParent = 0;
|
HWND hwndParent = 0;
|
||||||
int chOption = 0;
|
UCHAR chOption;
|
||||||
MSG Message;
|
MSG Message;
|
||||||
|
|
||||||
hInstance = hInst;
|
hInstance = hInst;
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
||||||
<module name="cylfrac" type="win32scr" installbase="system32" installname="cylfrac.scr">
|
<module name="cylfrac" type="win32scr" installbase="system32" installname="cylfrac.scr" unicode="true">
|
||||||
<define name="UNICODE" />
|
|
||||||
<define name="_UNICODE" />
|
|
||||||
|
|
||||||
<library>kernel32</library>
|
<library>kernel32</library>
|
||||||
<library>user32</library>
|
<library>user32</library>
|
||||||
<library>gdi32</library>
|
<library>gdi32</library>
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
||||||
<module name="matrix" type="win32scr" installbase="system32" installname="matrix2.scr" allowwarnings="true">
|
<module name="matrix" type="win32scr" installbase="system32" installname="matrix2.scr" allowwarnings="true" unicode="true">
|
||||||
<include base="matrix">.</include>
|
<include base="matrix">.</include>
|
||||||
|
|
||||||
<define name="_WIN32_IE">0x0501</define>
|
<define name="_WIN32_IE">0x0501</define>
|
||||||
<define name="_WIN32_WINNT">0x0501</define>
|
<define name="_WIN32_WINNT">0x0501</define>
|
||||||
<define name="UNICODE" />
|
|
||||||
<define name="_UNICODE" />
|
|
||||||
|
|
||||||
<library>kernel32</library>
|
<library>kernel32</library>
|
||||||
<library>user32</library>
|
<library>user32</library>
|
||||||
<library>gdi32</library>
|
<library>gdi32</library>
|
||||||
|
|
|
@ -100,7 +100,7 @@ BOOL ScreenSaver(HWND hwndParent)
|
||||||
// -p <hwnd> (preview)
|
// -p <hwnd> (preview)
|
||||||
// -c <hwnd> (configure)
|
// -c <hwnd> (configure)
|
||||||
//
|
//
|
||||||
VOID ParseCommandLine(LPSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
|
VOID ParseCommandLine(LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
|
||||||
{
|
{
|
||||||
UCHAR ch = *szCmdLine++;
|
UCHAR ch = *szCmdLine++;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ VOID ParseCommandLine(LPSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
|
||||||
|
|
||||||
if(isdigit(ch))
|
if(isdigit(ch))
|
||||||
{
|
{
|
||||||
unsigned int i = atoi(szCmdLine - 1);
|
unsigned int i = _wtoi(szCmdLine - 1);
|
||||||
*hwndParent = (HWND)i;
|
*hwndParent = (HWND)i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -131,7 +131,7 @@ VOID ParseCommandLine(LPSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
|
||||||
//
|
//
|
||||||
// Entrypoint for screen-saver: it's just a normal win32 app!
|
// Entrypoint for screen-saver: it's just a normal win32 app!
|
||||||
//
|
//
|
||||||
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int iCmdShow)
|
int CALLBACK wWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int iCmdShow)
|
||||||
{
|
{
|
||||||
HWND hwndParent;
|
HWND hwndParent;
|
||||||
UCHAR chOption;
|
UCHAR chOption;
|
||||||
|
|
|
@ -1,215 +1,215 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003 J Brown
|
* Copyright 2003 J Brown
|
||||||
* Copyright 2006 Eric Kohl
|
* Copyright 2006 Eric Kohl
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define APPNAME _T("Scrnsave")
|
#define APPNAME _T("Scrnsave")
|
||||||
|
|
||||||
|
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
|
|
||||||
BOOL fullscreen = FALSE;
|
BOOL fullscreen = FALSE;
|
||||||
|
|
||||||
|
|
||||||
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static POINT ptLast;
|
static POINT ptLast;
|
||||||
static POINT ptCursor;
|
static POINT ptCursor;
|
||||||
static BOOL fFirstTime = TRUE;
|
static BOOL fFirstTime = TRUE;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
ShowCursor(TRUE);
|
ShowCursor(TRUE);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// break out of screen-saver if any keyboard activity
|
// break out of screen-saver if any keyboard activity
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// break out of screen-saver if any mouse activity
|
// break out of screen-saver if any mouse activity
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
// If we've got a parent then we must be a preview
|
// If we've got a parent then we must be a preview
|
||||||
if(GetParent(hwnd) != 0)
|
if(GetParent(hwnd) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(fFirstTime)
|
if(fFirstTime)
|
||||||
{
|
{
|
||||||
GetCursorPos(&ptLast);
|
GetCursorPos(&ptLast);
|
||||||
fFirstTime = FALSE;
|
fFirstTime = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCursorPos(&ptCursor);
|
GetCursorPos(&ptCursor);
|
||||||
|
|
||||||
// if the mouse has moved more than 3 pixels then exit
|
// if the mouse has moved more than 3 pixels then exit
|
||||||
if(abs(ptCursor.x - ptLast.x) >= 3 || abs(ptCursor.y - ptLast.y) >= 3)
|
if(abs(ptCursor.x - ptLast.x) >= 3 || abs(ptCursor.y - ptLast.y) >= 3)
|
||||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||||
|
|
||||||
ptLast = ptCursor;
|
ptLast = ptCursor;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitSaver(HWND hwndParent)
|
void InitSaver(HWND hwndParent)
|
||||||
{
|
{
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
ZeroMemory(&wc, sizeof(wc));
|
ZeroMemory(&wc, sizeof(wc));
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
wc.lpfnWndProc = WndProc;
|
wc.lpfnWndProc = WndProc;
|
||||||
wc.lpszClassName = APPNAME;
|
wc.lpszClassName = APPNAME;
|
||||||
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||||
RegisterClass(&wc);
|
RegisterClass(&wc);
|
||||||
|
|
||||||
if (hwndParent != 0)
|
if (hwndParent != 0)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(hwndParent, &rect);
|
GetClientRect(hwndParent, &rect);
|
||||||
CreateWindow(APPNAME, APPNAME,
|
CreateWindow(APPNAME, APPNAME,
|
||||||
WS_VISIBLE | WS_CHILD,
|
WS_VISIBLE | WS_CHILD,
|
||||||
0, 0,
|
0, 0,
|
||||||
rect.right,
|
rect.right,
|
||||||
rect.bottom,
|
rect.bottom,
|
||||||
hwndParent, 0,
|
hwndParent, 0,
|
||||||
hInstance, NULL);
|
hInstance, NULL);
|
||||||
fullscreen = FALSE;
|
fullscreen = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
hwnd = CreateWindowEx(WS_EX_TOPMOST,
|
hwnd = CreateWindowEx(WS_EX_TOPMOST,
|
||||||
APPNAME,
|
APPNAME,
|
||||||
APPNAME,
|
APPNAME,
|
||||||
WS_VISIBLE | WS_POPUP,
|
WS_VISIBLE | WS_POPUP,
|
||||||
0, 0,
|
0, 0,
|
||||||
GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
||||||
HWND_DESKTOP, 0,
|
HWND_DESKTOP, 0,
|
||||||
hInstance, NULL);
|
hInstance, NULL);
|
||||||
|
|
||||||
SetWindowPos(hwnd,
|
SetWindowPos(hwnd,
|
||||||
0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0,
|
||||||
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_SHOWWINDOW);
|
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_SHOWWINDOW);
|
||||||
|
|
||||||
ShowCursor(FALSE);
|
ShowCursor(FALSE);
|
||||||
fullscreen = TRUE;
|
fullscreen = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseCommandLine(PSTR szCmdLine, int *chOption, HWND *hwndParent)
|
VOID ParseCommandLine(LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
|
||||||
{
|
{
|
||||||
int ch = *szCmdLine++;
|
UCHAR ch = *szCmdLine++;
|
||||||
|
|
||||||
if(ch == '-' || ch == '/')
|
if(ch == '-' || ch == '/')
|
||||||
ch = *szCmdLine++;
|
ch = *szCmdLine++;
|
||||||
|
|
||||||
if(ch >= 'A' && ch <= 'Z')
|
if(ch >= 'A' && ch <= 'Z')
|
||||||
ch += 'a' - 'A';
|
ch += 'a' - 'A'; //convert to lower case
|
||||||
|
|
||||||
*chOption = ch;
|
*chOption = ch;
|
||||||
ch = *szCmdLine++;
|
ch = *szCmdLine++;
|
||||||
|
|
||||||
if(ch == ':')
|
if(ch == ':')
|
||||||
ch = *szCmdLine++;
|
ch = *szCmdLine++;
|
||||||
|
|
||||||
while(ch == ' ' || ch == '\t')
|
while(ch == ' ' || ch == '\t')
|
||||||
ch = *szCmdLine++;
|
ch = *szCmdLine++;
|
||||||
|
|
||||||
if(isdigit(ch))
|
if(isdigit(ch))
|
||||||
{
|
{
|
||||||
unsigned int i = atoi(szCmdLine - 1);
|
unsigned int i = _wtoi(szCmdLine - 1);
|
||||||
*hwndParent = (HWND)i;
|
*hwndParent = (HWND)i;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*hwndParent = 0;
|
*hwndParent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configure(void)
|
void Configure(void)
|
||||||
{
|
{
|
||||||
TCHAR szTitle[256];
|
TCHAR szTitle[256];
|
||||||
TCHAR szText[256];
|
TCHAR szText[256];
|
||||||
|
|
||||||
LoadString(hInstance,
|
LoadString(hInstance,
|
||||||
IDS_TITLE,
|
IDS_TITLE,
|
||||||
szTitle,
|
szTitle,
|
||||||
256);
|
256);
|
||||||
|
|
||||||
LoadString(hInstance,
|
LoadString(hInstance,
|
||||||
IDS_TEXT,
|
IDS_TEXT,
|
||||||
szText,
|
szText,
|
||||||
256);
|
256);
|
||||||
|
|
||||||
MessageBox(0,
|
MessageBox(0,
|
||||||
szText,
|
szText,
|
||||||
szTitle,
|
szTitle,
|
||||||
MB_OK | MB_ICONWARNING);
|
MB_OK | MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int WINAPI WinMain (HINSTANCE hInst,
|
int CALLBACK wWinMain (HINSTANCE hInst,
|
||||||
HINSTANCE hPrev,
|
HINSTANCE hPrev,
|
||||||
LPSTR lpCmdLine,
|
LPWSTR lpCmdLine,
|
||||||
int iCmdShow)
|
int iCmdShow)
|
||||||
{
|
{
|
||||||
HWND hwndParent;
|
HWND hwndParent;
|
||||||
UINT nPreviousState;
|
UINT nPreviousState;
|
||||||
int chOption;
|
UCHAR chOption;
|
||||||
MSG Message;
|
MSG Message;
|
||||||
|
|
||||||
hInstance = hInst;
|
hInstance = hInst;
|
||||||
|
|
||||||
ParseCommandLine(lpCmdLine, &chOption, &hwndParent);
|
ParseCommandLine(lpCmdLine, &chOption, &hwndParent);
|
||||||
|
|
||||||
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
|
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
|
||||||
|
|
||||||
switch (chOption)
|
switch (chOption)
|
||||||
{
|
{
|
||||||
case 's':
|
case 's':
|
||||||
InitSaver(0);
|
InitSaver(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
InitSaver(hwndParent);
|
InitSaver(hwndParent);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
default:
|
default:
|
||||||
Configure();
|
Configure();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (GetMessage(&Message, 0, 0, 0))
|
while (GetMessage(&Message, 0, 0, 0))
|
||||||
DispatchMessage(&Message);
|
DispatchMessage(&Message);
|
||||||
|
|
||||||
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
|
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
|
||||||
|
|
||||||
return Message.wParam;
|
return Message.wParam;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
||||||
<module name="scrnsave" type="win32scr" installbase="system32" installname="scrnsave.scr">
|
<module name="scrnsave" type="win32scr" installbase="system32" installname="scrnsave.scr" unicode="true">
|
||||||
<define name="UNICODE" />
|
<library>kernel32</library>
|
||||||
<define name="_UNICODE" />
|
<library>user32</library>
|
||||||
|
<library>gdi32</library>
|
||||||
<library>kernel32</library>
|
<library>opengl32</library>
|
||||||
<library>user32</library>
|
<library>glu32</library>
|
||||||
<library>gdi32</library>
|
<library>winmm</library>
|
||||||
<library>opengl32</library>
|
|
||||||
<library>glu32</library>
|
<file>scrnsave.c</file>
|
||||||
<library>winmm</library>
|
<file>scrnsave.rc</file>
|
||||||
|
</module>
|
||||||
<file>scrnsave.c</file>
|
|
||||||
<file>scrnsave.rc</file>
|
|
||||||
</module>
|
|
||||||
|
|
|
@ -1,377 +1,385 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2003 J Brown
|
* Copyright 2003 J Brown
|
||||||
* Copyright 2006 Eric Kohl
|
* Copyright 2006 Eric Kohl
|
||||||
* Copyright 2007 Marc Piulachs (marc.piulachs@codexchange.net)
|
* Copyright 2007 Marc Piulachs (marc.piulachs@codexchange.net)
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#define RANDOM( min, max ) ((rand() % (int)(((max)+1) - (min))) + (min))
|
#define RANDOM( min, max ) ((rand() % (int)(((max)+1) - (min))) + (min))
|
||||||
|
|
||||||
#define MAX_LOADSTRING 100
|
#define MAX_LOADSTRING 100
|
||||||
#define MAX_STARS 1000
|
#define MAX_STARS 1000
|
||||||
|
|
||||||
#define APPNAME _T("Starfield")
|
#define APPNAME _T("Starfield")
|
||||||
#define APP_TIMER 1
|
#define APP_TIMER 1
|
||||||
#define APP_TIMER_INTERVAL 20
|
#define APP_TIMER_INTERVAL 20
|
||||||
|
|
||||||
#define MAX_STARS 1000
|
#define MAX_STARS 1000
|
||||||
|
|
||||||
// Details of each individual star
|
// Details of each individual star
|
||||||
typedef struct star
|
typedef struct star
|
||||||
{
|
{
|
||||||
int m_nXPos, m_nYPos, m_nZPos;
|
int m_nXPos, m_nYPos, m_nZPos;
|
||||||
int m_nOldX, m_nOldY;
|
int m_nOldX, m_nOldY;
|
||||||
} STAR;
|
} STAR;
|
||||||
|
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
BOOL fullscreen = FALSE;
|
BOOL fullscreen = FALSE;
|
||||||
|
|
||||||
STAR *stars;
|
STAR *stars;
|
||||||
|
|
||||||
int m_nTotStars;
|
int m_nTotStars;
|
||||||
int m_nCenterX, m_nCenterY;
|
int m_nCenterX, m_nCenterY;
|
||||||
|
|
||||||
void DrawStarField (HDC pDC)
|
void DrawStarField (HDC pDC)
|
||||||
{
|
{
|
||||||
int nX, nY;
|
int nX, nY;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < m_nTotStars; i++)
|
for (i = 0; i < m_nTotStars; i++)
|
||||||
{
|
{
|
||||||
// Clear last position of this star
|
// Clear last position of this star
|
||||||
SetPixel (
|
SetPixel (
|
||||||
pDC,
|
pDC,
|
||||||
stars[i].m_nOldX,
|
stars[i].m_nOldX,
|
||||||
stars[i].m_nOldY,
|
stars[i].m_nOldY,
|
||||||
RGB (0, 0, 0));
|
RGB (0, 0, 0));
|
||||||
|
|
||||||
nX = (int)((((long)stars[i].m_nXPos << 7) / (long)stars[i].m_nZPos) + m_nCenterX);
|
nX = (int)((((long)stars[i].m_nXPos << 7) / (long)stars[i].m_nZPos) + m_nCenterX);
|
||||||
nY = (int)((((long)stars[i].m_nYPos << 7) / (long)stars[i].m_nZPos) + m_nCenterY);
|
nY = (int)((((long)stars[i].m_nYPos << 7) / (long)stars[i].m_nZPos) + m_nCenterY);
|
||||||
|
|
||||||
// Draw star
|
// Draw star
|
||||||
SetPixel (
|
SetPixel (
|
||||||
pDC,
|
pDC,
|
||||||
nX,
|
nX,
|
||||||
nY,
|
nY,
|
||||||
RGB (255, 255, 255));
|
RGB (255, 255, 255));
|
||||||
|
|
||||||
// Remember current position for clearing later
|
// Remember current position for clearing later
|
||||||
stars[i].m_nOldX = nX;
|
stars[i].m_nOldX = nX;
|
||||||
stars[i].m_nOldY = nY;
|
stars[i].m_nOldY = nY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL SetUpStars (int nNumStars)
|
BOOL SetUpStars (int nNumStars)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (nNumStars > MAX_STARS)
|
if (nNumStars > MAX_STARS)
|
||||||
{
|
{
|
||||||
MessageBox (0,
|
MessageBox (0,
|
||||||
_T("Too many stars! Aborting!"),
|
_T("Too many stars! Aborting!"),
|
||||||
_T("Error"),
|
_T("Error"),
|
||||||
MB_OK | MB_ICONWARNING);
|
MB_OK | MB_ICONWARNING);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stars)
|
if (stars)
|
||||||
free (stars);
|
free (stars);
|
||||||
|
|
||||||
m_nTotStars = nNumStars;
|
m_nTotStars = nNumStars;
|
||||||
|
|
||||||
stars = (STAR*)malloc(nNumStars * sizeof(STAR));
|
stars = (STAR*)malloc(nNumStars * sizeof(STAR));
|
||||||
|
|
||||||
if (!stars)
|
if (!stars)
|
||||||
{
|
{
|
||||||
MessageBox (0,
|
MessageBox (0,
|
||||||
_T("Unable to allocate memory! Aborting!"),
|
_T("Unable to allocate memory! Aborting!"),
|
||||||
_T("Error"),
|
_T("Error"),
|
||||||
MB_OK | MB_ICONWARNING);
|
MB_OK | MB_ICONWARNING);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < m_nTotStars; i++)
|
for (i = 0; i < m_nTotStars; i++)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
stars[i].m_nXPos = RANDOM (-320, 320);
|
stars[i].m_nXPos = RANDOM (-320, 320);
|
||||||
stars[i].m_nYPos = RANDOM (-200, 200);
|
stars[i].m_nYPos = RANDOM (-200, 200);
|
||||||
stars[i].m_nZPos = i+1;
|
stars[i].m_nZPos = i+1;
|
||||||
stars[i].m_nOldX = -1;
|
stars[i].m_nOldX = -1;
|
||||||
stars[i].m_nOldY = -1;
|
stars[i].m_nOldY = -1;
|
||||||
} while ((stars[i].m_nXPos == 0) || (stars[i].m_nYPos == 0));
|
} while ((stars[i].m_nXPos == 0) || (stars[i].m_nYPos == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveStarField (int nXofs, int nYofs, int nZofs)
|
void MoveStarField (int nXofs, int nYofs, int nZofs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < m_nTotStars; i++)
|
for (i = 0; i < m_nTotStars; i++)
|
||||||
{
|
{
|
||||||
stars[i].m_nXPos += nXofs;
|
stars[i].m_nXPos += nXofs;
|
||||||
stars[i].m_nYPos += nYofs;
|
stars[i].m_nYPos += nYofs;
|
||||||
stars[i].m_nZPos += nZofs;
|
stars[i].m_nZPos += nZofs;
|
||||||
|
|
||||||
if (stars[i].m_nZPos > m_nTotStars)
|
if (stars[i].m_nZPos > m_nTotStars)
|
||||||
stars[i].m_nZPos -= m_nTotStars;
|
stars[i].m_nZPos -= m_nTotStars;
|
||||||
if (stars[i].m_nZPos < 1)
|
if (stars[i].m_nZPos < 1)
|
||||||
stars[i].m_nZPos += m_nTotStars;
|
stars[i].m_nZPos += m_nTotStars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDimensions (int nWidth, int nHeight)
|
void SetDimensions (int nWidth, int nHeight)
|
||||||
{
|
{
|
||||||
m_nCenterX = nWidth / 2;
|
m_nCenterX = nWidth / 2;
|
||||||
m_nCenterY = nHeight / 2;
|
m_nCenterY = nHeight / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static POINT ptLast;
|
static POINT ptLast;
|
||||||
static POINT ptCursor;
|
static POINT ptCursor;
|
||||||
static BOOL fFirstTime = TRUE;
|
static BOOL fFirstTime = TRUE;
|
||||||
static HDC pDC;
|
static HDC pDC;
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_CREATE :
|
case WM_CREATE :
|
||||||
{
|
{
|
||||||
SetTimer (
|
SetTimer (
|
||||||
hwnd,
|
hwnd,
|
||||||
APP_TIMER,
|
APP_TIMER,
|
||||||
APP_TIMER_INTERVAL,
|
APP_TIMER_INTERVAL,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_PAINT :
|
case WM_PAINT :
|
||||||
{
|
{
|
||||||
PAINTSTRUCT PtStr;
|
PAINTSTRUCT PtStr;
|
||||||
HDC pDC = BeginPaint (hwnd, &PtStr);
|
HDC pDC = BeginPaint (hwnd, &PtStr);
|
||||||
DrawStarField (pDC);
|
DrawStarField (pDC);
|
||||||
EndPaint (hwnd, &PtStr);
|
EndPaint (hwnd, &PtStr);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_TIMER :
|
case WM_TIMER :
|
||||||
{
|
{
|
||||||
if (wParam == APP_TIMER)
|
if (wParam == APP_TIMER)
|
||||||
{
|
{
|
||||||
MoveStarField (0, 0, -3);
|
MoveStarField (0, 0, -3);
|
||||||
pDC = GetDC(hwnd);
|
pDC = GetDC(hwnd);
|
||||||
DrawStarField (pDC);
|
DrawStarField (pDC);
|
||||||
ReleaseDC(hwnd, pDC);
|
ReleaseDC(hwnd, pDC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_SIZE :
|
case WM_SIZE :
|
||||||
{
|
{
|
||||||
// Change the center point of the starfield
|
// Change the center point of the starfield
|
||||||
SetDimensions (
|
SetDimensions (
|
||||||
LOWORD(lParam),
|
LOWORD(lParam),
|
||||||
HIWORD(lParam));
|
HIWORD(lParam));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_DESTROY :
|
case WM_DESTROY :
|
||||||
{
|
{
|
||||||
KillTimer (hwnd, APP_TIMER);
|
KillTimer (hwnd, APP_TIMER);
|
||||||
free(stars);
|
free(stars);
|
||||||
ShowCursor(TRUE);
|
ShowCursor(TRUE);
|
||||||
PostQuitMessage (0);
|
PostQuitMessage (0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// break out of screen-saver if any keyboard activity
|
// break out of screen-saver if any keyboard activity
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
{
|
{
|
||||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// break out of screen-saver if any mouse activity
|
// break out of screen-saver if any mouse activity
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
{
|
{
|
||||||
// If we've got a parent then we must be a preview
|
// If we've got a parent then we must be a preview
|
||||||
if(GetParent(hwnd) != 0)
|
if(GetParent(hwnd) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(fFirstTime)
|
if(fFirstTime)
|
||||||
{
|
{
|
||||||
GetCursorPos(&ptLast);
|
GetCursorPos(&ptLast);
|
||||||
fFirstTime = FALSE;
|
fFirstTime = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCursorPos(&ptCursor);
|
GetCursorPos(&ptCursor);
|
||||||
|
|
||||||
// if the mouse has moved more than 3 pixels then exit
|
// if the mouse has moved more than 3 pixels then exit
|
||||||
if( (abs(ptCursor.x - ptLast.x) >= 3) ||
|
if( (abs(ptCursor.x - ptLast.x) >= 3) ||
|
||||||
(abs(ptCursor.y - ptLast.y) >= 3))
|
(abs(ptCursor.y - ptLast.y) >= 3))
|
||||||
{
|
{
|
||||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptLast = ptCursor;
|
ptLast = ptCursor;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InitSaver(HWND hwndParent)
|
void InitSaver(HWND hwndParent)
|
||||||
{
|
{
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
ZeroMemory(&wc, sizeof(wc));
|
ZeroMemory(&wc, sizeof(wc));
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
wc.lpfnWndProc = WndProc;
|
wc.lpfnWndProc = WndProc;
|
||||||
wc.lpszClassName = APPNAME;
|
wc.lpszClassName = APPNAME;
|
||||||
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||||
RegisterClass(&wc);
|
RegisterClass(&wc);
|
||||||
|
|
||||||
if (hwndParent != 0)
|
if (hwndParent != 0)
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(hwndParent, &rect);
|
GetClientRect(hwndParent, &rect);
|
||||||
CreateWindow(APPNAME, APPNAME,
|
CreateWindow(APPNAME, APPNAME,
|
||||||
WS_VISIBLE | WS_CHILD,
|
WS_VISIBLE | WS_CHILD,
|
||||||
0, 0,
|
0, 0,
|
||||||
rect.right,
|
rect.right,
|
||||||
rect.bottom,
|
rect.bottom,
|
||||||
hwndParent, 0,
|
hwndParent, 0,
|
||||||
hInstance, NULL);
|
hInstance, NULL);
|
||||||
fullscreen = FALSE;
|
fullscreen = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
hwnd = CreateWindowEx(WS_EX_TOPMOST,
|
hwnd = CreateWindowEx(WS_EX_TOPMOST,
|
||||||
APPNAME,
|
APPNAME,
|
||||||
APPNAME,
|
APPNAME,
|
||||||
WS_VISIBLE | WS_POPUP,
|
WS_VISIBLE | WS_POPUP,
|
||||||
0, 0,
|
0, 0,
|
||||||
GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
||||||
HWND_DESKTOP, 0,
|
HWND_DESKTOP, 0,
|
||||||
hInstance, NULL);
|
hInstance, NULL);
|
||||||
|
|
||||||
SetWindowPos(hwnd,
|
SetWindowPos(hwnd,
|
||||||
0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0,
|
||||||
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_SHOWWINDOW);
|
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_SHOWWINDOW);
|
||||||
|
|
||||||
ShowCursor(FALSE);
|
ShowCursor(FALSE);
|
||||||
fullscreen = TRUE;
|
fullscreen = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUpStars(250);
|
SetUpStars(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseCommandLine(PSTR szCmdLine, int *chOption, HWND *hwndParent)
|
//
|
||||||
{
|
// Look for any options Windows has passed to us:
|
||||||
int ch = *szCmdLine++;
|
//
|
||||||
|
// -a <hwnd> (set password)
|
||||||
if(ch == '-' || ch == '/')
|
// -s (screensave)
|
||||||
ch = *szCmdLine++;
|
// -p <hwnd> (preview)
|
||||||
|
// -c <hwnd> (configure)
|
||||||
if(ch >= 'A' && ch <= 'Z')
|
//
|
||||||
ch += 'a' - 'A';
|
VOID ParseCommandLine(LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
|
||||||
|
{
|
||||||
*chOption = ch;
|
UCHAR ch = *szCmdLine++;
|
||||||
ch = *szCmdLine++;
|
|
||||||
|
if(ch == '-' || ch == '/')
|
||||||
if(ch == ':')
|
ch = *szCmdLine++;
|
||||||
ch = *szCmdLine++;
|
|
||||||
|
if(ch >= 'A' && ch <= 'Z')
|
||||||
while(ch == ' ' || ch == '\t')
|
ch += 'a' - 'A'; //convert to lower case
|
||||||
ch = *szCmdLine++;
|
|
||||||
|
*chOption = ch;
|
||||||
if(isdigit(ch))
|
ch = *szCmdLine++;
|
||||||
{
|
|
||||||
unsigned int i = atoi(szCmdLine - 1);
|
if(ch == ':')
|
||||||
*hwndParent = (HWND)i;
|
ch = *szCmdLine++;
|
||||||
}
|
|
||||||
else
|
while(ch == ' ' || ch == '\t')
|
||||||
*hwndParent = 0;
|
ch = *szCmdLine++;
|
||||||
}
|
|
||||||
|
if(isdigit(ch))
|
||||||
void Configure(void)
|
{
|
||||||
{
|
unsigned int i = _wtoi(szCmdLine - 1);
|
||||||
TCHAR szTitle[256];
|
*hwndParent = (HWND)i;
|
||||||
TCHAR szText[256];
|
}
|
||||||
|
else
|
||||||
LoadString(hInstance,
|
*hwndParent = NULL;
|
||||||
IDS_TITLE,
|
}
|
||||||
szTitle,
|
|
||||||
256);
|
void Configure(void)
|
||||||
|
{
|
||||||
LoadString(hInstance,
|
TCHAR szTitle[256];
|
||||||
IDS_TEXT,
|
TCHAR szText[256];
|
||||||
szText,
|
|
||||||
256);
|
LoadString(hInstance,
|
||||||
|
IDS_TITLE,
|
||||||
MessageBox(0,
|
szTitle,
|
||||||
szText,
|
256);
|
||||||
szTitle,
|
|
||||||
MB_OK | MB_ICONWARNING);
|
LoadString(hInstance,
|
||||||
}
|
IDS_TEXT,
|
||||||
|
szText,
|
||||||
int WINAPI WinMain (HINSTANCE hInst,
|
256);
|
||||||
HINSTANCE hPrev,
|
|
||||||
LPSTR lpCmdLine,
|
MessageBox(0,
|
||||||
int iCmdShow)
|
szText,
|
||||||
{
|
szTitle,
|
||||||
HWND hwndParent;
|
MB_OK | MB_ICONWARNING);
|
||||||
UINT nPreviousState;
|
}
|
||||||
int chOption;
|
|
||||||
MSG Message;
|
int CALLBACK wWinMain (HINSTANCE hInst,
|
||||||
|
HINSTANCE hPrev,
|
||||||
hInstance = hInst;
|
LPWSTR lpCmdLine,
|
||||||
|
int iCmdShow)
|
||||||
ParseCommandLine(lpCmdLine, &chOption, &hwndParent);
|
{
|
||||||
|
HWND hwndParent;
|
||||||
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
|
UINT nPreviousState;
|
||||||
|
UCHAR chOption;
|
||||||
switch (chOption)
|
MSG Message;
|
||||||
{
|
|
||||||
case 's':
|
hInstance = hInst;
|
||||||
InitSaver(0);
|
|
||||||
break;
|
ParseCommandLine(lpCmdLine, &chOption, &hwndParent);
|
||||||
|
|
||||||
case 'p':
|
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
|
||||||
InitSaver(hwndParent);
|
|
||||||
break;
|
switch (chOption)
|
||||||
|
{
|
||||||
case 'c':
|
case 's':
|
||||||
default:
|
InitSaver(0);
|
||||||
Configure();
|
break;
|
||||||
return 0;
|
|
||||||
}
|
case 'p':
|
||||||
|
InitSaver(hwndParent);
|
||||||
while (GetMessage(&Message, 0, 0, 0))
|
break;
|
||||||
DispatchMessage(&Message);
|
|
||||||
|
case 'c':
|
||||||
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
|
default:
|
||||||
|
Configure();
|
||||||
return Message.wParam;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (GetMessage(&Message, 0, 0, 0))
|
||||||
|
DispatchMessage(&Message);
|
||||||
|
|
||||||
|
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
|
||||||
|
|
||||||
|
return Message.wParam;
|
||||||
|
}
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
|
||||||
<module name="starfield" type="win32scr" installbase="system32" installname="starfield.scr">
|
<module name="starfield" type="win32scr" installbase="system32" installname="starfield.scr" unicode="true">
|
||||||
<define name="UNICODE" />
|
<library>kernel32</library>
|
||||||
<define name="_UNICODE" />
|
<library>user32</library>
|
||||||
|
<library>gdi32</library>
|
||||||
<library>kernel32</library>
|
|
||||||
<library>user32</library>
|
<metadata description = "Starfield simulation screensaver" />
|
||||||
<library>gdi32</library>
|
|
||||||
|
<file>screensaver.c</file>
|
||||||
<metadata description = "Starfield simulation screensaver" />
|
<file>starfield.rc</file>
|
||||||
|
</module>
|
||||||
<file>screensaver.c</file>
|
|
||||||
<file>starfield.rc</file>
|
|
||||||
</module>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue