home *** CD-ROM | disk | FTP | other *** search
- /*
- RSIN.C -- Demonstrates use of 3.0 functions RSin and RCos
-
- From Chapter 9 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC RSIN (for Borland C++ v3.00)
- WINIOMS RSIN (for Microsoft C/SDK)
-
- NOTE: the above functions are only available in version 3.0
- */
-
- #include <windows.h>
- #include "winio.h"
-
- /* Undocumented functions */
- extern int FAR PASCAL RSin(int nRadius, int n10thDegrees);
- extern int FAR PASCAL RCos(int nRadius, int n10thDegrees);
-
- #include "checkord.c"
-
- BOOL DrawStar(HWND hwnd, HDC hDC, PAINTSTRUCT *pps, PWINIOINFO pwi)
- {
- RECT rectClient;
- POINT middle;
- int nRadius;
- int d;
- HPEN hPen, hPenOld;
-
- hPen = CreatePen(PS_SOLID, 1, RED);
-
- hPenOld = SelectObject(hDC, GetStockObject(BLACK_PEN));
-
- GetClientRect(hwnd, (LPRECT) &rectClient);
-
- middle.x = (rectClient.right - rectClient.left) / 2;
- middle.y = (rectClient.bottom - (rectClient.top + pwi->dimChar.y)) / 2;
- nRadius = min(middle.x, middle.y) - 2;
- middle.x -= pwi->rectView.left * pwi->dimChar.x;
- middle.y -= pwi->dimChar.y * pwi->rectView.top;
-
- for (d = 0; d < 90; d++)
- {
- MoveTo(hDC, middle.x, middle.y);
- LineTo(hDC, middle.x + RSin(nRadius, d * 40),
- middle.y + RCos(nRadius, d * 40));
- }
-
- SelectObject(hDC, hPenOld);
-
- DeleteObject(hPen);
-
- return TRUE;
- }
-
-
- int main()
- {
- winio_about("RSIN"
- "\nDemonstrates use of 3.0 functions RSin and RCos"
- "\n\nFrom Chapter 9 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek"
- );
-
- if ((! CheckOrdName("RCos", "GDI", 177)) ||
- (! CheckOrdName("RSin", "GDI", 178)))
- return 1;
-
- winio_onpaintentry(__hMainWnd, (PAINT_FUNC) DrawStar);
-
- InvalidateRect(__hMainWnd, NULL, TRUE);
-
- printf("The star is drawn using RSin and RCos.");
-
- return 0;
- }
-
-