home *** CD-ROM | disk | FTP | other *** search
- /*
- FASTWFRM.C -- Uses FastWindowFrame for a crude exploding window
-
- From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC FASTWFRM (for Borland C++ v3.00)
- WINIOMS FASTWFRM (for Microsoft C/SDK)
- */
-
- #include <windows.h>
- #include "wmhandlr.h"
- #include "winio.h"
-
- /* Undocumented functions */
- extern BOOL FAR PASCAL FastWindowFrame(HDC hDC, LPRECT lpRect, int xWidth, int yWidth, DWORD dwROP3);
-
- #define HOWOFTEN 5
- #define FRAMEWIDTH 3
-
- WMHANDLER wmsize_old;
- HDC hDC;
- int i;
- FARPROC lpfnDDA;
-
- #include "checkord.c"
-
- void FAR PASCAL fnDDA(int x, int y, LPSTR dummy)
- {
- RECT rect;
-
- if (++i != HOWOFTEN) return;
- i = 0;
-
- GetClientRect(winio_current(), &rect);
- rect.left += x;
- rect.right -= x;
- rect.top += y;
- rect.bottom -= y;
- FastWindowFrame(hDC, &rect, FRAMEWIDTH, FRAMEWIDTH, DSTINVERT);
-
- // Waste a bit of time by doing it all again
- GetClientRect(winio_current(), &rect);
- rect.left += x;
- rect.right -= x;
- rect.top += y;
- rect.bottom -= y;
- FastWindowFrame(hDC, &rect, FRAMEWIDTH, FRAMEWIDTH, DSTINVERT);
- }
-
- long my_wmsize(HWND hwnd, WORD wMsg, WORD wParam, DWORD lParam)
- {
- RECT rect;
- int xMax, yMax;
-
- GetClientRect(hwnd, &rect);
-
- yMax = ((rect.bottom - rect.top) / 2) - 1;
- xMax = ((rect.right - rect.left) / 2) - 1;
- i = 0;
-
- hDC = GetDC(hwnd);
-
- LineDDA(xMax, yMax, 0, 0, lpfnDDA, NULL);
-
- ReleaseDC(hwnd, hDC);
-
- return (*wmsize_old)(hwnd, wMsg, wParam, lParam);
- }
-
- int main()
- {
- winio_about("FASTWFRM"
- "\nUses FastWindowFrame for a crude exploding window"
- "\n\nFrom Chapter 6 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek"
- );
-
- if (! CheckOrdName("FastWindowFrame", "GDI", 400))
- return 1;
-
- if (! (lpfnDDA = MakeProcInstance((FARPROC) fnDDA, __hInst)))
- fail("Could not MakeProcInstance!!!\n");
-
- wmsize_old = wmhandler_set(__hMainWnd, WM_SIZE, (WMHANDLER) my_wmsize);
-
- printf("Resize this window, and\n"
- "an exloding frame will fill it out!\n\n"
- "Close the window to exit\n");
-
- return 0;
- }
-
-