Привет, вот надо код переделать, кто может помочь ?
Прога: при запуске крутятся 2 квадрата в разные стороны.
/*
ssaver.cpp - simpliest screensaver.
Especially for "MyComputer" readers :-)
-------------------------------------
Programmed by Ivan Gavrilyuk on Aug, 2002
mailto:
ivg@hotbox.ru best chat:
http://chat.chat.ru, channel "Programmers" :-)
*/
#include <windows.h>
#include <scrnsave.h>
#include <math.h>
double pi = 3.1415926;
double pi2 = 2*pi;
double hpi = pi/2;
//screensaver message cycle. Works like WinMain in clean Win32API application
LRESULT WINAPI ScreenSaverProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static PAINTSTRUCT ps = {NULL};
static HDC hDC = NULL;
static HPEN hPen1;
static UINT uTimer = 0;
static int x_max, y_max;
static double step = 0.01, angle = 0;
static int center_x, center_y;
switch(message)
{
case WM_CREATE:
x_max = GetSystemMetrics(SM_CXSCREEN);
y_max = GetSystemMetrics(SM_CYSCREEN);
center_x = x_max / 2;
center_y = y_max / 2;
uTimer = SetTimer(hWnd, 1, 10, NULL);
hPen1 = (HPEN)GetStockObject(WHITE_PEN);
break;
case WM_DESTROY:
if(uTimer) KillTimer(hWnd, uTimer);
PostQuitMessage(0);
break;
case WM_TIMER:
angle += step;
if(angle > pi2) angle = 0;
RECT lpr;
lpr.left = center_x - 102;
lpr.top = center_y - 102;
lpr.right = center_x + 102;
lpr.bottom = center_y + 102;;
InvalidateRect(hWnd, &lpr, true);
break;
case WM_PAINT:
x_max = GetSystemMetrics(SM_CXSCREEN);
y_max = GetSystemMetrics(SM_CYSCREEN);
center_x = x_max / 2;
center_y = y_max / 2;
hDC = BeginPaint(hWnd, &ps);
if(fChildPreview)
{
SetBkColor(hDC, RGB(0, 0, 0));
SetTextColor(hDC, RGB(255, 255, 0));
char szPreview[] = "Мои квадратики :-)";
TextOut(hDC, 15, 45, szPreview, strlen(szPreview));
}
else
{
SetBkColor(hDC, RGB(1, 0, 0));
SetTextColor(hDC, RGB(120, 120, 120));
SelectObject(hDC, hPen1);
MoveToEx(hDC, center_x + (int)(cos(angle)*(double)100), center_y + (int)(sin(angle)*(double)(-100)), NULL);
LineTo(hDC, center_x + (int)(cos(hpi + angle)*(double)100), center_y + (int)(sin(hpi + angle)*(double)(-100)));
LineTo(hDC, center_x + (int)(cos(pi + angle)*(double)100), center_y + (int)(sin(pi + angle)*(double)(-100)));
LineTo(hDC, center_x + (int)(cos(hpi + pi + angle)*(double)100), center_y + (int)(sin(hpi + pi + angle)*(double)(-100)));
LineTo(hDC, center_x + (int)(cos(angle)*(double)100), center_y + (int)(sin(angle)*(double)(-100)));
MoveToEx(hDC, center_x + (int)(cos(-angle)*(double)50), center_y + (int)(sin(-angle)*(double)(-50)), NULL);
LineTo(hDC, center_x + (int)(cos(hpi - angle)*(double)50), center_y + (int)(sin(hpi - angle)*(double)(-50)));
LineTo(hDC, center_x + (int)(cos(pi - angle)*(double)50), center_y + (int)(sin(pi - angle)*(double)(-50)));
LineTo(hDC, center_x + (int)(cos(hpi + pi - angle)*(double)50), center_y + (int)(sin(hpi + pi - angle)*(double)(-50)));
LineTo(hDC, center_x + (int)(cos(-angle)*(double)50), center_y + (int)(sin(-angle)*(double)(-50)));
static char szAuthor[] = "Programmed by Evgeniy";
TextOut(hDC, 0, y_max - 20, szAuthor, strlen(szAuthor));
}
EndPaint(hWnd, &ps);
break;
default:
return DefScreenSaverProc(hWnd, message, wParam, lParam);
}
return 0;
}
BOOL WINAPI ScreenSaverConfigureDialog (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
return true;
}
BOOL WINAPI RegisterDialogClasses (HANDLE hInst)
{
return true;
}
//That's all, folks!