home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / dde / ddespy / ddespy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-09  |  26.7 KB  |  637 lines

  1. /*----------------------------------------------------------------------------*\
  2. |   ddespy.c      - Windows message spy application                              |
  3. |                                                                              |
  4. |   Notes:                                                                     |
  5. |       "->" means "a pointer to", "->>" means "a handle to"                   |
  6. |                                                                              |
  7. |   History:                                                                   |
  8. |       01/01/87 Created                                                       |
  9. |                                                                              |
  10. \*----------------------------------------------------------------------------*/
  11.  
  12. /*----------------------------------------------------------------------------*\
  13. |                                                                              |
  14. |   g e n e r a l   c o n s t a n t s                                          |
  15. |                                                                              |
  16. \*----------------------------------------------------------------------------*/
  17.  
  18. #define DEBUGDX   100    /* Window sizes */
  19. #define DEBUGDY   100
  20. #define DEBUGX    50
  21. #define DEBUGY    50
  22. #define DEBUGXINC 10
  23. #define DEBUGYINC 30
  24.  
  25. /*----------------------------------------------------------------------------*\
  26. |                                                                              |
  27. |   i n c l u d e   f i l e s                                                  |
  28. |                                                                              |
  29. \*----------------------------------------------------------------------------*/
  30.  
  31. #include <windows.h>
  32. #include <winexp.h>
  33. #include "ddespy.h"
  34. #include "dde.h"
  35.  
  36. /*----------------------------------------------------------------------------*\
  37. |                                                                              |
  38. |   g l o b a l   v a r i a b l e s                                            |
  39. |                                                                              |
  40. \*----------------------------------------------------------------------------*/
  41.  
  42. static  char    acAppName[]="DDE SPY";
  43.  
  44. static  HANDLE  hInst;
  45. HWND    hSpyApp;
  46. HWND    hSpyChild;
  47. static  FARPROC fpxProcAbout;
  48. static  FARPROC fpxProcSpySet;
  49. static  FARPROC fpxSpyProc;
  50. /* static  FARPROC fpxMsgHook1;
  51.    static  FARPROC fpxMsgHook2;
  52.    static  FARPROC fpxOldHook1;
  53.    static  FARPROC fpxOldHook2;
  54.  */
  55.  
  56. /* Global variables describing the state of the window being spyied on */
  57. static  BOOL    gbSpyOn  = FALSE;
  58. static  HWND    ghSpyWnd = NULL;
  59. static  BOOL    gbHook   = FALSE;
  60. static  FARPROC OldSpyProc;
  61.  
  62. BOOL gbMouse = TRUE;          /* TRUE if mouse messages are to be ignored */
  63. BOOL gbNC    = TRUE;
  64.  
  65. static BOOL bDisableMessages; /*  TRUE if all messages are to be ignored */
  66.  
  67.  
  68. struct TEXT_STRUCT {
  69.     int  iFirst;                  /* First line in que */
  70.     int  iCount;                  /* Number of lines in que */
  71.     int  iTop;                    /* Line at top of window */
  72.     int  iLeft;                   /* X offset of the window */
  73.     char *Text[MAXLINES];         /* Que of Text in window */
  74.     int  Len[MAXLINES];           /* String Length of text */
  75.     int  MaxLen;                  /* Max String Length */
  76. };
  77.  
  78. typedef struct TEXT_STRUCT *PTXT; /* pointer to a text struct */
  79. typedef PTXT               *HTXT; /* Handle to a text struct */
  80.  
  81. static int Tdx = 0;        /* Text font size */
  82. static int Tdy = 0;
  83.  
  84. static HWND hERROR;
  85.  
  86. /*----------------------------------------------------------------------------*\
  87. |                                                                              |
  88. |   f u n c t i o n   d e f i n i t i o n s                                    |
  89. |                                                                              |
  90. \*----------------------------------------------------------------------------*/
  91.  
  92. long FAR PASCAL MyWndProc(HWND, unsigned, WORD, LONG);
  93. long FAR PASCAL SpyProc(HWND, unsigned, WORD, LONG);
  94.  
  95. /* HWND CreateDebugWindow (HWND,char *,BOOL); */
  96. void Error (char *);
  97. BOOL SSEqualToDS (void);
  98.  
  99. /*
  100.   long FAR PASCAL MsgHook1(WORD, WORD, LPMSG);
  101.   long FAR PASCAL MsgHook2(WORD, WORD, LPMSG);
  102.  */
  103.  
  104. extern void FAR PASCAL KillHook();
  105. extern BOOL FAR PASCAL InitHook( HWND );
  106. extern long FAR PASCAL DebugWndProc(HWND, unsigned, WORD, LONG);
  107. extern HWND FAR PASCAL CreateDebugWin (HANDLE, HWND);
  108.  
  109. extern void FAR PASCAL PassFileToDLL(int);
  110.  
  111. /*----------------------------------------------------------------------------*\
  112. |   DlgAbout( hDlg, uiMessage, wParam, lParam )                                |
  113. |                                                                              |
  114. |   Description:                                                               |
  115. |       This function handles messages belonging to the "About" dialog box.    |
  116. |       The only message that it looks for is WM_COMMAND, indicating the use   |
  117. |       has pressed the "OK" button.  When this happens, it takes down         |
  118. |       the dialog box.                                                        |
  119. |                                                                              |
  120. |   Arguments:                                                                 |
  121. |       hDlg            window handle of about dialog window                   |
  122. |       uiMessage       message number                                         |
  123. |       wParam          message-dependent                                      |
  124. |       lParam          message-dependent                                      |
  125. |                                                                              |
  126. |   Returns:                                                                   |
  127. |       TRUE if message has been processed, else FALSE                         |
  128. |                                                                              |
  129. \*----------------------------------------------------------------------------*/
  130.  
  131. BOOL FAR PASCAL DlgAbout( hDlg, uiMessage, wParam, lParam )
  132. HWND     hDlg;
  133. unsigned uiMessage;
  134. WORD     wParam;
  135. long     lParam;
  136. {
  137.     switch (uiMessage) {
  138.         case WM_COMMAND:
  139.             EndDialog(hDlg,TRUE);
  140.             return(TRUE);
  141.         case WM_INITDIALOG:
  142.             return(TRUE);
  143.     }
  144.     return(FALSE);
  145. }
  146.  
  147.  
  148. VOID SetDlgText (hDlg,hWnd)
  149.   HWND hDlg;
  150.   HWND hWnd;
  151. {
  152.   static char acCaption[100];
  153.   HWND hParent;
  154.  
  155.   if (IsWindow(hWnd)) {
  156.      acCaption[0] = '\0';
  157.      GetWindowText (hWnd,(LPSTR)acCaption,100);
  158.      SetDlgItemText(hDlg,ID_CAPTION,(LPSTR)acCaption);
  159.      hParent = GetParent(hWnd);
  160.      if (IsWindow(hParent)) {
  161.         GetWindowText (hParent,(LPSTR)acCaption,100);
  162.         SetDlgItemText(hDlg,ID_PARENT,(LPSTR)acCaption);
  163.      }
  164.      else {
  165.         SetDlgItemText(hDlg,ID_PARENT,(LPSTR)"<NO PARENT>");
  166.      }
  167.  
  168.      GetModuleFileName(GetWindowWord(hWnd,GWW_HINSTANCE),
  169.                        (LPSTR)acCaption,100 );
  170.   }
  171.   else {
  172.      SetDlgItemText(hDlg,ID_CAPTION,(LPSTR)"<Undefined>");
  173.      SetDlgItemText(hDlg,ID_MODULE, (LPSTR)"<Undefined>");
  174.      SetDlgItemText(hDlg,ID_PARENT, (LPSTR)"<Undefined>");
  175.   }
  176. }
  177.  
  178. /*----------------------------------------------------------------------------*\
  179. |   DlgSpySet( hDlg, uiMessage, wParam, lParam )                               |
  180. |                                                                              |
  181. |   Description:                                                               |
  182. |       This function handles messages belonging to the SpySet dialog box.     |
  183. |                                                                              |
  184. |   Arguments:                                                                 |
  185. |       hDlg            window handle of about dialog window                   |
  186. |       uiMessage       message number                                         |
  187. |       wParam          message-dependent                                      |
  188. |       lParam          message-dependent                                      |
  189. |                                                                              |
  190. |   Returns:                                                                   |
  191. |       TRUE if message has been processed, else FALSE                         |
  192. |                                                                              |
  193. \*----------------------------------------------------------------------------*/
  194.  
  195. BOOL FAR PASCAL DlgSpySet( hDlg, uiMessage, wParam, lParam )
  196. HWND     hDlg;
  197. unsigned uiMessage;
  198. WORD     wParam;
  199. long     lParam;
  200. {
  201.     static BOOL bNC;
  202.     static BOOL bMouse;
  203.     static HWND hSpyWnd;
  204.     static BOOL bHook;
  205.     static int  iCaptureState;  /* 0 = not captured, 1 = captured */
  206.  
  207.     POINT  pCursor;
  208.  
  209.     switch (uiMessage) {
  210.         case WM_COMMAND:
  211.             switch (wParam) {
  212.  
  213.               case ID_OK:
  214.                 SendMessage (hSpyApp,WM_COMMAND,SPYOFF,0L);
  215.                 gbNC     = bNC;
  216.                 gbMouse  = bMouse;
  217.                 ghSpyWnd = hSpyWnd;
  218.                 gbHook   = bHook;
  219.                 if (gbHook) hSpyWnd = NULL;
  220.                 SendMessage (hSpyApp,WM_COMMAND,SPYON,0L);
  221.  
  222.                 /* Fall through to cancel */
  223.               case ID_CANCEL:
  224.                 iCaptureState++;
  225.                 EndDialog(hDlg,TRUE);
  226.                 return TRUE;
  227.  
  228.               case ID_MOUSE:
  229.                 SendDlgItemMessage(hDlg,ID_MOUSE,BM_SETCHECK,bMouse ^= 1,0L);
  230.                 return TRUE;
  231.  
  232.               case ID_NC:
  233.                 SendDlgItemMessage(hDlg,ID_NC,BM_SETCHECK,bNC ^= 1,0L);
  234.                 return TRUE;
  235.  
  236.  
  237. /*              case ID_ALL:
  238.  *               SendDlgItemMessage(hDlg,ID_ALL,BM_SETCHECK,bHook ^= 1,0L);
  239.  *               if (bHook) hSpyWnd = NULL;
  240.  *               SetDlgText (hDlg,hSpyWnd);
  241.  *               return TRUE;
  242.  */
  243.             }
  244.             break;
  245.  
  246.         case WM_INITDIALOG:
  247.             SendDlgItemMessage(hDlg,ID_NC   ,BM_SETCHECK,bNC   =gbNC,0L);
  248.             SendDlgItemMessage(hDlg,ID_MOUSE,BM_SETCHECK,bMouse=gbMouse,0L);
  249.             SendDlgItemMessage(hDlg,ID_ALL  ,BM_SETCHECK,bHook =gbHook,0L);
  250.             hSpyWnd = ghSpyWnd;
  251.             if (bHook) hSpyWnd = NULL;
  252.             SetDlgText (hDlg,hSpyWnd);
  253.             iCaptureState=0;
  254.             return TRUE;
  255.  
  256.         /*
  257.          * When the dialog box is being deactivated by the user clicking
  258.          * in a window of another application find out what window and
  259.          * steal the focus back.  If the user tries to spy on the same
  260.          * window two times the focus is not stolen back.
  261.          */
  262.  
  263.         case WM_ACTIVATEAPP:
  264.             if (wParam == 0 && !iCaptureState) {
  265.                HWND hWnd;
  266.                GetCursorPos((LPPOINT)&pCursor);
  267.                hWnd = WindowFromPoint(pCursor);
  268.                if (hWnd != hSpyWnd) {
  269.                   SetDlgText (hDlg,hWnd);
  270.                   PostMessage(hDlg,WM_ACTIVATE,1,0L);/* Trick used to get the */
  271.                   hSpyWnd = hWnd;                    /* focus back */
  272.                   bHook   = FALSE;
  273.                   SendDlgItemMessage(hDlg,ID_ALL,BM_SETCHECK,bHook,0L);
  274.                }
  275.                return TRUE;
  276.             }
  277.             return FALSE;
  278.  
  279.         default:
  280.             return FALSE;
  281.      }
  282.  }
  283.  
  284.  
  285. /*----------------------------------------------------------------------------*\
  286. |   MyInit( hInstance )                                                        |
  287. |                                                                              |
  288. |   Description:                                                               |
  289. |       This is called when the application is first loaded into               |
  290. |       memory.  It performs all initialization that doesn't need to be done   |
  291. |       once per instance.                                                     |
  292. |                                                                              |
  293. |   Arguments:                                                                 |
  294. |       hInstance       instance handle of current instance                    |
  295. |                                                                              |
  296. |   Returns:                                                                   |
  297. |       TRUE if successful, FALSE if not                                       |
  298. |                                                                              |
  299. \*----------------------------------------------------------------------------*/
  300.  
  301. BOOL MyInit(hInstance,hPrevInstance)
  302.    HANDLE hInstance;
  303.    HANDLE hPrevInstance;
  304. {
  305.     WNDCLASS rClass;
  306.  
  307. /* Register a class for the main application window */
  308.  
  309.     if (!hPrevInstance) {
  310.        rClass.hCursor        = LoadCursor(NULL,IDC_ARROW);
  311.        rClass.hIcon          = LoadIcon(hInstance,(LPSTR)"AppIcon");
  312.        rClass.lpszMenuName   = (LPSTR)"MyMenu";
  313.        rClass.lpszClassName  = (LPSTR)acAppName;
  314.        rClass.hbrBackground  = (HBRUSH)COLOR_WINDOW + 1;
  315.        rClass.hInstance      = hInstance;
  316.        rClass.style          = CS_HREDRAW | CS_VREDRAW;
  317.        rClass.lpfnWndProc    = MyWndProc;
  318.        rClass.cbWndExtra     = 0;
  319.        rClass.cbClsExtra     = 0;
  320.  
  321.        return RegisterClass((LPWNDCLASS)&rClass);
  322.     }
  323.     return TRUE;
  324. }
  325.  
  326. /*----------------------------------------------------------------------------*\
  327. |                                                                              |
  328. |   w i n m a i n                                                              |
  329. |                                                                              |
  330. \*----------------------------------------------------------------------------*/
  331.  
  332.  
  333. /*----------------------------------------------------------------------------*\
  334. |   WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )                  |
  335. |                                                                              |
  336. |   Description:                                                               |
  337. |       The main procedure for the App.  After initializing, it just goes      |
  338. |       into a message-processing loop until it gets a WM_QUIT message         |
  339. |       (meaning the app was closed).                                          |
  340. |                                                                              |
  341. |   Arguments:                                                                 |
  342. |       hInstance       instance handle of this instance of the app            |
  343. |       hPrevInstance   instance handle of previous instance, NULL if first    |
  344. |       lpszCmdLine     ->null-terminated command line                         |
  345. |       cmdShow         specifies how the window is initially displayed        |
  346. |                                                                              |
  347. |   Returns:                                                                   |
  348. |       The exit code as specified in the WM_QUIT message.                     |
  349. |                                                                              |
  350. \*----------------------------------------------------------------------------*/
  351.  
  352. int PASCAL WinMain( hInstance, hPrevInstance, fpcCmdLine, iCmdShow )
  353. HANDLE  hInstance, hPrevInstance;
  354. LPSTR   fpcCmdLine;
  355. int     iCmdShow;
  356. {
  357.     MSG   rMsg;
  358.     HWND  hWnd;
  359.     HMENU hMenu;
  360.     HDC   hdc;
  361.     int   dxpScreen;
  362.     int   dypScreen;
  363.  
  364.     /* Call initialization procedure */
  365.     if (!MyInit(hInstance,hPrevInstance))
  366.         return FALSE;
  367.  
  368. /* create initial tiled window */
  369.  
  370.         hdc = CreateDC((LPSTR)"DISPLAY", NULL, NULL, NULL);
  371.         dxpScreen = GetDeviceCaps(hdc, HORZRES);
  372.         dypScreen = GetDeviceCaps(hdc, VERTRES);
  373.         DeleteDC(hdc);
  374.  
  375.     /* Save instance handle for DialogBoxs */
  376.     hInst = hInstance;
  377.  
  378.     hSpyApp = CreateWindow ((LPSTR)acAppName,
  379.                             (LPSTR)acAppName,
  380.                             WS_TILEDWINDOW,
  381.                             0,           /*  x */
  382.                             dypScreen/2, /*  y */
  383.                             dxpScreen,   /* cx */
  384.                             dypScreen/2, /* cy */
  385.                             (HWND)NULL,        /* no parent */
  386.                             (HMENU)NULL,       /* use class menu */
  387.                             (HANDLE)hInstance, /* handle to window instance */
  388.                             (LPSTR)NULL        /* no params to pass on */
  389.                            );
  390.  
  391.     ShowWindow (hSpyApp,iCmdShow);
  392.  
  393.     /* Bind callback function with module instance */
  394.     fpxProcAbout  = MakeProcInstance((FARPROC)DlgAbout,hInstance);
  395.     fpxProcSpySet = MakeProcInstance((FARPROC)DlgSpySet,hInstance);
  396.     fpxSpyProc    = MakeProcInstance((FARPROC)SpyProc,hInstance);
  397.  /*
  398.     fpxMsgHook1   = MakeProcInstance((FARPROC)MsgHook1,hInstance);
  399.     fpxMsgHook2   = MakeProcInstance((FARPROC)MsgHook2,hInstance);
  400.  */
  401.     /* Insert "About..." into system menu */
  402.     hMenu = GetSystemMenu(hSpyApp,FALSE);
  403.     ChangeMenu(hMenu,0,NULL,999,MF_APPEND | MF_SEPARATOR);
  404.     ChangeMenu(hMenu,0,(LPSTR)"About...",CMDABOUT,MF_APPEND | MF_STRING);
  405.  
  406.     /*
  407.      * Polling messages from event queue
  408.      */
  409.  
  410.     while (GetMessage((LPMSG)&rMsg,NULL,0,0))  {
  411.         TranslateMessage((LPMSG)&rMsg);
  412.         DispatchMessage((LPMSG)&rMsg);
  413.     }
  414.  
  415.     FreeProcInstance (fpxProcAbout);
  416.     FreeProcInstance (fpxProcSpySet);
  417.     FreeProcInstance (fpxSpyProc);
  418.  /*
  419.     FreeProcInstance (fpxMsgHook1);
  420.     FreeProcInstance (fpxMsgHook2);
  421.   */
  422.     return((int)rMsg.wParam);
  423. }
  424.  
  425. /*----------------------------------------------------------------------------*\
  426. |                                                                              |
  427. |   w i n d o w   p r o c s                                                    |
  428. |                                                                              |
  429. \*----------------------------------------------------------------------------*/
  430.  
  431. /*----------------------------------------------------------------------------*\
  432. |   MyWndProc( hWnd, uiMessage, wParam, lParam )                               |
  433. |                                                                              |
  434. |   Description:                                                               |
  435. |       The window proc for the app's main (tiled) window.  This processes all |
  436. |       of the parent window's messages.                                       |
  437. |                                                                              |
  438. |   Arguments:                                                                 |
  439. |       hWnd            window handle for the parent window                    |
  440. |       uiMessage       message number                                         |
  441. |       wParam          message-dependent                                      |
  442. |       lParam          message-dependent                                      |
  443. |                                                                              |
  444. |   Returns:                                                                   |
  445. |       0 if processed, nonzero if ignored                                     |
  446. |                                                                              |
  447. \*----------------------------------------------------------------------------*/
  448.  
  449. long FAR PASCAL MyWndProc( hWnd, uiMessage, wParam, lParam )
  450. HWND     hWnd;
  451. unsigned uiMessage;
  452. WORD     wParam;
  453. long     lParam;
  454. {
  455.         HANDLE hqel;
  456.         QEL *pqel;
  457.         HMENU hMenu;
  458.         RECT  rRect;
  459.         char rgch[32];
  460.         char rgch2[32];
  461.  
  462.     /*
  463.      *  if the message is less than WM_USER then it is a message to
  464.      *  be proccessed
  465.      */
  466.  
  467.     switch (uiMessage) {
  468.  
  469.         case WM_CREATE:
  470.             hSpyChild = CreateDebugWin(hInst, hWnd); 
  471.             return 0L;
  472.  
  473.         case WM_INITMENU:
  474.             return 0L;
  475.  
  476.         case WM_COMMAND:
  477.             if (lParam == 0) {
  478.                 switch (wParam) {
  479.                     case SPYOFF:
  480.                         if (gbSpyOn) {
  481.  
  482.                            KillHook();
  483.                          /*
  484.                            SetWindowsHook(WH_GETMESSAGE, fpxOldHook1);
  485.                            SetWindowsHook(WH_CALLWNDPROC, fpxOldHook2);
  486.                           */
  487.                            gbSpyOn = FALSE;
  488.                            hMenu = GetMenu (hWnd);
  489.                            ChangeMenu (hMenu,SPYOFF,(LPSTR)"Spy On",SPYON,
  490.                                        MF_CHANGE | MF_ENABLED);
  491.                         }
  492.                         return(0L);
  493.  
  494.                     case SPYON:
  495.                         if (!gbSpyOn) {
  496.                            InitHook(hSpyChild);
  497.                          /*
  498.                            fpxOldHook1 = SetWindowsHook(WH_GETMESSAGE, fpxMsgHook1);
  499.                            fpxOldHook2 = SetWindowsHook(WH_CALLWNDPROC,fpxMsgHook2);
  500.                           */
  501.                            gbSpyOn = TRUE;
  502.                            hMenu = GetMenu (hWnd);
  503.                            ChangeMenu (hMenu,SPYON,(LPSTR)"Spy Off",SPYOFF,
  504.                                        MF_CHANGE | MF_ENABLED);
  505.                         }
  506.                         return(0L);
  507.  
  508.                     case SPYSET:
  509.                         DialogBox(hInst,MAKEINTRESOURCE(DLGSPY),hWnd,fpxProcSpySet);
  510.                         return (0L);
  511.                 }
  512.             }
  513.             break;
  514.  
  515.         case WM_SYSCOMMAND:
  516.             if (wParam == CMDABOUT) {
  517.                 DialogBox(hInst,MAKEINTRESOURCE(ABOUTBOX),hWnd,fpxProcAbout);
  518.                 return(0L);
  519.             }
  520.             break;
  521.  
  522.         case WM_SIZE:
  523.             MoveWindow (hSpyChild,0,0,LOWORD (lParam),HIWORD(lParam),TRUE);
  524.             return 0L;
  525.  
  526.         case WM_DESTROY:
  527.             SendMessage (hSpyApp,WM_COMMAND,SPYOFF,0L);
  528.  
  529.             PostQuitMessage(0L);   /* Kill the main window */
  530.             return 0L;
  531.     }
  532.     return DefWindowProc (hWnd,uiMessage,wParam,lParam);
  533. }
  534.  
  535.  
  536. /*----------------------------------------------------------------------------*\
  537. |   SpyProc( hWnd, uiMessage, wParam, lParam )                                 |
  538. |                                                                              |
  539. |   Description:                                                               |
  540. |       The window proc for the app being spied on                             |
  541. |                                                                              |
  542. |   Arguments:                                                                 |
  543. |       hWnd            window handle for the parent window                    |
  544. |       uiMessage       message number                                         |
  545. |       wParam          message-dependent                                      |
  546. |       lParam          message-dependent                                      |
  547. |                                                                              |
  548. |   Returns:                                                                   |
  549. |       0 if processed, nonzero if ignored                                     |
  550. |                                                                              |
  551. \*----------------------------------------------------------------------------*/
  552.  
  553. long FAR PASCAL SpyProc( hWnd, uiMessage, wParam, lParam )
  554. HWND     hWnd;
  555. unsigned uiMessage;
  556. WORD     wParam;
  557. long     lParam;
  558. {
  559.     /*
  560.      *  This procedure is called from another task through a Data thunk and
  561.      *  SS != DS (the SS is for the other task).  Watch out!!
  562.      */
  563.  
  564.     PostMessage (hSpyApp,uiMessage + WM_USER,wParam,lParam);
  565.     if (uiMessage == WM_DESTROY) {
  566.        /*
  567.         * The user is quitting the application being spyed on.
  568.         * unhook the spy procedure or funny things may happen.
  569.         */
  570.        SendMessage (hSpyApp,WM_COMMAND,SPYOFF,0L);
  571.        ghSpyWnd = NULL;
  572.     }
  573.     return CallWindowProc(OldSpyProc,hWnd,uiMessage,wParam,lParam);
  574. }
  575.  
  576.  
  577.  
  578. /*----------------------------------------------------------------------------*\
  579. |                                                                              |
  580. |   w i n d o w   p r o c s                                                    |
  581. |                                                                              |
  582. \*----------------------------------------------------------------------------*/
  583.  
  584.  
  585. /*----------------------------------------------------------------------------*\
  586. |  THIS IS NEVER CALLED.                                                                               |
  587. |  CreateDebugWindow (hWnd, pcText,bTiled)                                     |
  588. |                                                                              |
  589. |   Description:                                                               |
  590. |     Creates a tiled window for the depositing of debuging messages.          |
  591. |                                                                              |
  592. |   Arguments:                                                                 |
  593. |     hWnd   - Window handle of the parent window.                             |
  594. |     pcText - String to appear in the caption bar of the debuging window      |
  595. |     bTiled - FALSE => window is a popup,  Tiled otherwise.                   |
  596. |                                                                              |
  597. |   Returns:                                                                   |
  598. |     A window handle of the debuging window, or NULL if a error occured.      |
  599. |                                                                              |
  600. \*----------------------------------------------------------------------------*/
  601.  
  602. HWND CreateDebugWindow (hParent,pchName,bTiled)
  603.     HWND   hParent;
  604.     char   *pchName;
  605.     BOOL   bTiled;
  606. {
  607.     static int  iNextX = DEBUGX;
  608.     static int  iNextY = DEBUGY;
  609.     HWND        hWnd;
  610.  
  611.     MessageBeep(1);
  612.     MessageBox( hParent, "We're here", NULL, MB_OK);
  613.  /*
  614.     hWnd = CreateDebugWin( hParent,
  615.                            pchName,
  616.                            (bTiled ? WS_TILED : WS_POPUP) |
  617.                            WS_VSCROLL | WS_HSCROLL |
  618.                            WS_CAPTION | WS_SYSMENU | WS_SIZEBOX,
  619.                            iNextX,
  620.                            iNextY,
  621.                            DEBUGDX,
  622.                            DEBUGDY 
  623.                          );
  624.  */
  625.     iNextX += DEBUGXINC;
  626.     iNextY += DEBUGYINC;
  627.  
  628.     return hWnd;
  629. }
  630.  
  631. static void Error (str)
  632. char *str;
  633. {
  634.   int a = MessageBox (hERROR,(LPSTR)str,(LPSTR)NULL,MB_OKCANCEL);
  635.   if (a == IDCANCEL) PostQuitMessage(0);
  636. }
  637.