clock: Make the window round in no title bar mode, to exercise SetWindowRgn.

This commit is contained in:
Alexandre Julliard 2007-03-05 16:42:30 +01:00
parent 69299c7738
commit 366dbd2f81
3 changed files with 25 additions and 7 deletions

View File

@ -180,6 +180,7 @@ static VOID CLOCK_ToggleTitle(VOID)
else {
style = (style & ~(WS_POPUP|WS_THICKFRAME)) | WS_OVERLAPPEDWINDOW;
SetMenu(Globals.hMainWnd, Globals.hMainMenu);
SetWindowRgn(Globals.hMainWnd, 0, TRUE);
}
SetWindowLong(Globals.hMainWnd, GWL_STYLE, style);
SetWindowPos(Globals.hMainWnd, 0,0,0,0,0,
@ -311,7 +312,7 @@ static VOID CLOCK_Paint(HWND hWnd)
FillRect(dcMem, &ps.rcPaint, GetStockObject(LTGRAY_BRUSH));
if(Globals.bAnalog)
AnalogClock(dcMem, Globals.MaxX, Globals.MaxY, Globals.bSeconds);
AnalogClock(dcMem, Globals.MaxX, Globals.MaxY, Globals.bSeconds, Globals.bWithoutTitle);
else
DigitalClock(dcMem, Globals.MaxX, Globals.MaxY, Globals.bSeconds, Globals.hFont);
@ -361,6 +362,19 @@ static LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM
case WM_SIZE: {
Globals.MaxX = LOWORD(lParam);
Globals.MaxY = HIWORD(lParam);
if (Globals.bAnalog && Globals.bWithoutTitle)
{
RECT rect;
INT diameter = min( Globals.MaxX, Globals.MaxY );
HRGN hrgn = CreateEllipticRgn( (Globals.MaxX - diameter) / 2,
(Globals.MaxY - diameter) / 2,
(Globals.MaxX + diameter) / 2,
(Globals.MaxY + diameter) / 2 );
GetWindowRect( hWnd, &rect );
MapWindowPoints( 0, hWnd, (LPPOINT)&rect, 2 );
OffsetRgn( hrgn, -rect.left, -rect.top );
SetWindowRgn( Globals.hMainWnd, hrgn, TRUE );
}
CLOCK_ResetFont();
break;
}

View File

@ -82,7 +82,7 @@ static void DrawTicks(HDC dc, const POINT* centre, int radius)
}
}
static void DrawFace(HDC dc, const POINT* centre, int radius)
static void DrawFace(HDC dc, const POINT* centre, int radius, int border)
{
/* Ticks */
SelectObject(dc, CreatePen(PS_SOLID, 2, ShadowColor));
@ -91,8 +91,12 @@ static void DrawFace(HDC dc, const POINT* centre, int radius)
DeleteObject(SelectObject(dc, CreatePen(PS_SOLID, 2, TickColor)));
OffsetWindowOrgEx(dc, SHADOW_DEPTH, SHADOW_DEPTH, NULL);
DrawTicks(dc, centre, radius);
DeleteObject(SelectObject(dc, GetStockObject(NULL_BRUSH)));
if (border)
{
SelectObject(dc, GetStockObject(NULL_BRUSH));
DeleteObject(SelectObject(dc, CreatePen(PS_SOLID, 5, ShadowColor)));
Ellipse(dc, centre->x - radius, centre->y - radius, centre->x + radius, centre->y + radius);
}
DeleteObject(SelectObject(dc, GetStockObject(NULL_PEN)));
}
@ -159,7 +163,7 @@ static void PositionHands(const POINT* centre, int radius, BOOL bSeconds)
PositionHand(centre, radius * 0.79, second/60 * 2*M_PI, &SecondHand);
}
void AnalogClock(HDC dc, int x, int y, BOOL bSeconds)
void AnalogClock(HDC dc, int x, int y, BOOL bSeconds, BOOL border)
{
POINT centre;
int radius;
@ -171,7 +175,7 @@ void AnalogClock(HDC dc, int x, int y, BOOL bSeconds)
centre.x = x/2;
centre.y = y/2;
DrawFace(dc, &centre, radius);
DrawFace(dc, &centre, radius, border);
PositionHands(&centre, radius, bSeconds);
DrawHands(dc, bSeconds);

View File

@ -21,6 +21,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
void AnalogClock(HDC dc, int X, int Y, BOOL bSeconds);
void AnalogClock(HDC dc, int X, int Y, BOOL bSeconds, BOOL border);
HFONT SizeFont(HDC dc, int x, int y, BOOL bSeconds, const LOGFONT* font);
void DigitalClock(HDC dc, int X, int Y, BOOL bSeconds, HFONT font);