home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP8.ZIP / FASTWFRM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-11  |  2.2 KB  |  95 lines

  1. /*
  2.     FASTWFRM.C -- Uses FastWindowFrame for a crude exploding window
  3.  
  4.     From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
  5.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  6.  
  7.     Build using: WINIOBC FASTWFRM (for Borland C++ v3.00)
  8.                  WINIOMS FASTWFRM (for Microsoft C/SDK)
  9. */
  10.  
  11. #include <windows.h>
  12. #include "wmhandlr.h"
  13. #include "winio.h"
  14.  
  15. /* Undocumented functions */
  16. extern BOOL FAR PASCAL FastWindowFrame(HDC hDC, LPRECT lpRect, int xWidth, int yWidth, DWORD dwROP3);
  17.  
  18. #define HOWOFTEN    5
  19. #define FRAMEWIDTH    3
  20.  
  21. WMHANDLER wmsize_old;
  22. HDC hDC;
  23. int i;
  24. FARPROC lpfnDDA;
  25.  
  26. #include "checkord.c"
  27.  
  28. void FAR PASCAL fnDDA(int x, int y, LPSTR dummy)
  29.     {
  30.     RECT rect;
  31.  
  32.     if (++i != HOWOFTEN) return;
  33.     i = 0;
  34.  
  35.     GetClientRect(winio_current(), &rect);
  36.     rect.left += x;
  37.     rect.right -= x;
  38.     rect.top += y;
  39.     rect.bottom -= y;
  40.     FastWindowFrame(hDC, &rect, FRAMEWIDTH, FRAMEWIDTH, DSTINVERT);
  41.     
  42.     // Waste a bit of time by doing it all again
  43.     GetClientRect(winio_current(), &rect);
  44.     rect.left += x;
  45.     rect.right -= x;
  46.     rect.top += y;
  47.     rect.bottom -= y;
  48.     FastWindowFrame(hDC, &rect, FRAMEWIDTH, FRAMEWIDTH, DSTINVERT);
  49.     }
  50.  
  51. long my_wmsize(HWND hwnd, WORD wMsg, WORD wParam, DWORD lParam)
  52.     {
  53.     RECT rect;
  54.     int xMax, yMax;
  55.     
  56.     GetClientRect(hwnd, &rect);
  57.     
  58.     yMax = ((rect.bottom - rect.top) / 2) - 1;
  59.     xMax = ((rect.right - rect.left) / 2) - 1;
  60.     i = 0;
  61.     
  62.     hDC = GetDC(hwnd);
  63.     
  64.     LineDDA(xMax, yMax, 0, 0, lpfnDDA, NULL);
  65.     
  66.     ReleaseDC(hwnd, hDC);
  67.     
  68.     return (*wmsize_old)(hwnd, wMsg, wParam, lParam);
  69.     }
  70.  
  71. int main()
  72.     {
  73.     winio_about("FASTWFRM"
  74.         "\nUses FastWindowFrame for a crude exploding window"
  75.         "\n\nFrom Chapter 6 of"
  76.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  77.         "\nby Andrew Schulman, David Maxey and Matt Pietrek"
  78.         );
  79.  
  80.     if (! CheckOrdName("FastWindowFrame", "GDI", 400))
  81.         return 1;
  82.  
  83.     if (! (lpfnDDA = MakeProcInstance((FARPROC) fnDDA, __hInst)))
  84.         fail("Could not MakeProcInstance!!!\n");
  85.     
  86.     wmsize_old = wmhandler_set(__hMainWnd, WM_SIZE, (WMHANDLER) my_wmsize);
  87.     
  88.     printf("Resize this window, and\n"
  89.             "an exloding frame will fill it out!\n\n"
  90.             "Close the window to exit\n");
  91.     
  92.     return 0;
  93.     }
  94.  
  95.