--- mstools/samples/gdidemo/poly.c 2018/08/09 18:20:01 1.1 +++ mstools/samples/gdidemo/poly.c 2018/08/09 18:23:49 1.1.1.3 @@ -1,12 +1,17 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + /*---------------------------------------------------------------------------*\ | POLYBEZIER MODULE | This module contains the routines for demo -| -| segment: _TEXT (DOS16) -| created: 19-Oct-90 -| history: 19-Oct-90 created original polybezier effect. -| 20-May-91 adapted for use in MDI application. -| \*---------------------------------------------------------------------------*/ #include @@ -16,10 +21,6 @@ /*---------------------------------------------------------------------------*\ | CREATE BEZIER WINDOW PROCEDURE | Create the bezier MDI-child window. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ HWND FAR CreatePolyWindow(HWND hWndClient, int nItem) { @@ -35,25 +36,21 @@ HWND FAR CreatePolyWindow(HWND hWndClien */ mcs.szClass = POLYCLASS; mcs.szTitle = POLYTITLE; - mcs.hOwner = hInstance; + mcs.hOwner = hInstance; mcs.x = CW_USEDEFAULT; mcs.y = CW_USEDEFAULT; mcs.cx = CW_USEDEFAULT; mcs.cy = CW_USEDEFAULT; - mcs.style = 0l; + mcs.style = 0l; mcs.lParam = (LONG)nItem; - return((HWND)SendMessage(hWndClient,WM_MDICREATE,NULL,(LONG)(LPMDICREATESTRUCT)&mcs)); + return((HWND)SendMessage(hWndClient,WM_MDICREATE,0,(LONG)(LPMDICREATESTRUCT)&mcs)); } /*---------------------------------------------------------------------------*\ | POLYBEZIER WINDOW PROCEDURE | This is the main window function for the polybezier demo window. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ LONG APIENTRY PolyProc(HWND hWnd, UINT wMsg, WPARAM wParam, LONG lParam) { @@ -100,10 +97,6 @@ LONG APIENTRY PolyProc(HWND hWnd, UINT w | Create the polybezier window for the demo application. This is a child | of the MDI client window. Allocate the extra object information for | handling of the polybezier demo. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ BOOL PolyCreateProc(HWND hWnd) { @@ -136,10 +129,6 @@ BOOL PolyCreateProc(HWND hWnd) | POLYBEZIER COMMAND PROCEDURE | Process polybezier commands. This is a NOP for now. But who knows what | tomorrow may bring. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ BOOL PolyCommandProc(HWND hWnd, WPARAM wParam, LONG lParam) { @@ -155,10 +144,6 @@ BOOL PolyCommandProc(HWND hWnd, WPARAM w | POLYBEZIER PAINT PROCEDURE | Repaint the bezier window. All we really do here is validate our window, | and reset the array of bezier objects. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ VOID PolyPaintProc(HWND hWnd) { @@ -179,10 +164,6 @@ VOID PolyPaintProc(HWND hWnd) | POLYBEZIER DESTROY PROCEDURE | Kill the polybezier demo. Free up the resources allocated on behalf of | this object. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ VOID PolyDestroyProc(HWND hWnd) { @@ -206,10 +187,6 @@ VOID PolyDestroyProc(HWND hWnd) | This routine creates a new velocity for the bezier points. Each bezier | point is randomly chosen. The two inside points should have a speed | less then the endpoints (most of the time-better effect). -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ int PolyNewVel(int i) { @@ -229,10 +206,6 @@ int PolyNewVel(int i) | INITIALIZE POLYBEZIER POINTS | This routine initializes the polybezier points for the first object. This | is performed on startup of the window. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ VOID PolyInitPoints(HWND hWnd) { @@ -248,7 +221,7 @@ VOID PolyInitPoints(HWND hWnd) { GetClientRect(hWnd,&rect); - for(idx=0; idx < 4; idx++) + for(idx=0; idx < BEZ_PTS-1; idx++) { lpBez->pPts[idx].x = lRandom() % rect.right; lpBez->pPts[idx].y = lRandom() % rect.bottom; @@ -268,10 +241,6 @@ VOID PolyInitPoints(HWND hWnd) | POLYBEZIER REDRAW | This routine resets the bezier curves and redraws the poly-bezier client | area. -| -| created: 20-May-91 -| history: 20-May-91 created. -| \*---------------------------------------------------------------------------*/ VOID PolyRedraw(HWND hWnd) { @@ -303,7 +272,7 @@ VOID PolyRedraw(HWND hWnd) */ for(j=1; j < ppd->nBezTotal; j++) { - for(i=0; i < 4; i++) + for(i=0; i < BEZ_PTS; i++) { (lpBez+j)->pPts[i].x = -1; (lpBez+j)->pPts[i].y = 0; @@ -322,10 +291,10 @@ VOID PolyRedraw(HWND hWnd) /* ** Draw the first curve in the bezier array. */ -#ifdef WIN32 - PolyBezier(hDC,lpBez->pPts,4); +#if defined(_WIN32) && defined(WIN32) + PolyBezier(hDC,lpBez->pPts,BEZ_PTS); #else - Polyline(hDC,lpBez->pPts,4); + Polyline(hDC,lpBez->pPts,BEZ_PTS); #endif ReleaseDC(hWnd,hDC); } @@ -378,15 +347,15 @@ static COLORREF crColor[] = {0x000000FF, if(lpCurr->pPts[0].x != -1) { hPen = SelectObject(hDC,GetStockObject(BLACK_PEN)); -#ifdef WIN32 - PolyBezier(hDC,lpCurr->pPts,4); +#if defined(_WIN32) && defined(WIN32) + PolyBezier(hDC,lpCurr->pPts,BEZ_PTS); #else - Polyline(hDC,lpCurr->pPts,4); + Polyline(hDC,lpCurr->pPts,BEZ_PTS); #endif SelectObject(hDC,hPen); } - for(idx=0; idx < 4; idx++) + for(idx=0; idx < BEZ_PTS; idx++) { x = lpPrev->pPts[idx].x; y = lpPrev->pPts[idx].y; @@ -419,17 +388,18 @@ static COLORREF crColor[] = {0x000000FF, lpCurr->pPts[idx].x = x; lpCurr->pPts[idx].y = y; + } hPen = SelectObject(hDC,CreatePen(PS_SOLID,1,crColor[ppd->nColor])); -#ifdef WIN32 - PolyBezier(hDC,lpCurr->pPts,4); +#if defined(_WIN32) && defined(WIN32) + PolyBezier(hDC,lpCurr->pPts,BEZ_PTS); #else - Polyline(hDC,lpCurr->pPts,4); + Polyline(hDC,lpCurr->pPts,BEZ_PTS); #endif DeleteObject(SelectObject(hDC,hPen)); -#ifdef WIN32 +#if defined(_WIN32) && defined(WIN32) SetROP2(hDC,R2_COPYPEN); #endif ReleaseDC(hWnd,hDC);