home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / wsftp2.zip / WS_DEBUG.C < prev    next >
C/C++ Source or Header  |  1994-04-07  |  5KB  |  159 lines

  1. /***************************************************************************
  2.   Windows Sockets Client Application Support Module
  3.  
  4.   Written by:
  5.       John A. Junod             Internet: <junodj@gordon-emh2.army.mil>
  6.       267 Hillwood Street                 <zj8549@trotter.usma.edu>
  7.       Martinez, GA 30907      Compuserve: 72321,366 
  8.  
  9.   This program executable and all source code is released into the public
  10.   domain.  It would be nice (but is not required) to give me a little 
  11.   credit for any use of this code.  
  12.  
  13.   THE INFORMATION AND CODE PROVIDED IS PROVIDED AS IS WITHOUT WARRANTY 
  14.   OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  15.   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  16.   PURPOSE. IN NO EVENT SHALL JOHN A. JUNOD BE LIABLE FOR ANY DAMAGES 
  17.   WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS 
  18.   OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF JOHN A. JUNOD HAS BEEN 
  19.   ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  20.  
  21. *****************************************************************************/
  22.  
  23. /*
  24.   MODULE: WS_DEBUG.C (debug routines)
  25. */
  26.  
  27. #include "ws_glob.h"
  28. #include "ws_ftp.h"
  29.  
  30. struct win_info DBUGWINDOW;
  31.  
  32. HWND hWndDbg;
  33.  
  34. int CreateDebugWindow(HWND hMainWnd,HWND hInst)
  35. {
  36.   static WNDCLASS wndclass;
  37.   long       nWndunits;     // window units for size and location
  38.   int        nWndx;         // the x axis multiplier
  39.   int        nWndy;         // the y axis multiplier
  40.   int        nX;            // the resulting starting point (x, y)
  41.   int        nY;
  42.   int        nWidth;        // the resulting width and height for this
  43.   int        nHeight;       // window
  44.  
  45.   wndclass.style        =CS_VREDRAW | CS_PARENTDC;
  46.   wndclass.lpfnWndProc  =DebugWndProc;
  47.   wndclass.cbClsExtra   =0;
  48.   wndclass.cbWndExtra   =0;
  49.   wndclass.hInstance    =hInst;
  50.   wndclass.hIcon        =LoadIcon(hInst,"WS_XBUG");
  51.   wndclass.hCursor      =LoadCursor(NULL,IDC_ARROW);
  52.   wndclass.hbrBackground=GetStockObject(LTGRAY_BRUSH);
  53.   wndclass.lpszMenuName =szAppName;
  54.   wndclass.lpszClassName=DBUGWNDCLASS;
  55.  
  56.   // Create a device independant size and location
  57.   nWndunits = GetDialogBaseUnits();
  58.   nWndx = LOWORD(nWndunits);
  59.   nWndy = HIWORD(nWndunits);
  60.   nX = ((40 * nWndx) / 4);
  61.   nY = ((40 * nWndy) / 8);
  62.   nWidth = ((200 * nWndx) / 4);
  63.   nHeight = ((200 * nWndy) / 8);
  64.  
  65.   RegisterClass(&wndclass);
  66.  
  67.   hWndDbg=CreateWindow(DBUGWNDCLASS,"WS_FTP Debug",
  68.       WS_OVERLAPPEDWINDOW,
  69.       nX,nY,nWidth,nHeight,NULL,NULL,hInst,NULL);
  70.   ShowWindow(hWndDbg,SW_SHOWMINIMIZED);
  71.   return(TRUE);
  72. }
  73.  
  74. LRESULT CALLBACK DebugWndProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)
  75. {
  76.  
  77.   switch (Message)
  78.   {
  79.     case WM_CREATE:
  80.       DBUGWINDOW.hWnd=hWnd;
  81.       DBUGWINDOW.nVpos=0;
  82.       DBUGWINDOW.nMemPtr=0;
  83.       DBUGWINDOW.nLineHeight=8;
  84.       DBUGWINDOW.nScreenRows=20;
  85.  
  86.       SetScrollRange(hWnd, SB_VERT, 0, 100, FALSE);
  87.       break;
  88.  
  89.  
  90.     case WM_COMMAND:
  91.       if(LOWORD(wParam)==BTN_CLOSE || LOWORD(wParam)==BTN_EXIT ||
  92.          LOWORD(wParam)==CMD_CLOSE || LOWORD(wParam)==IDM_EXIT) {
  93.       } else if(bCmdInProgress) return(FALSE);
  94.      
  95.       switch (LOWORD(wParam))
  96.       {
  97.  
  98. #include "ws_debug.inc"
  99.  
  100.         case IDM_EXIT:
  101.         case IDM_ABOUT:
  102.              SendMessage(hWndMain,Message,wParam,lParam);
  103.              break;
  104.  
  105.         default:
  106.           return DefWindowProc(hWnd, Message, wParam, lParam);
  107.       }
  108.       break;
  109.  
  110.     case WM_SETCURSOR:
  111.       if(bCmdInProgress)
  112.         SetCursor(hWaitCursor);
  113.       else
  114.         return DefWindowProc(hWnd, Message, wParam, lParam);
  115.       break;
  116.  
  117.     case WM_PAINT:
  118.       DoWindowPaint(&DBUGWINDOW);
  119.       break;
  120.  
  121.     case WM_VSCROLL:
  122.       
  123.       switch(LOWORD(wParam))
  124.       {
  125.         case SB_LINEDOWN:
  126.           if(DBUGWINDOW.nVpos<(DBUGWINDOW.nMemPtr-1))
  127.             DBUGWINDOW.nVpos++;
  128.           break;
  129.         case SB_LINEUP:
  130.           if(DBUGWINDOW.nVpos>0)
  131.             --DBUGWINDOW.nVpos;
  132.           break;
  133.         case SB_THUMBPOSITION:
  134.           DBUGWINDOW.nVpos = min(DBUGWINDOW.nMemPtr, LOWORD(lParam));
  135.           break;
  136.         case SB_PAGEUP:
  137.           if(DBUGWINDOW.nVpos>10)
  138.             DBUGWINDOW.nVpos-=10;
  139.           else DBUGWINDOW.nVpos=0;
  140.           break;
  141.         case SB_PAGEDOWN:
  142.           if(DBUGWINDOW.nVpos<(DBUGWINDOW.nMemPtr-10))
  143.             DBUGWINDOW.nVpos+=10;
  144.           else DBUGWINDOW.nVpos=DBUGWINDOW.nMemPtr;
  145.           break;
  146.         default:
  147.           return FALSE;
  148.       }
  149.       SetScrollPos(hWnd,SB_VERT,DBUGWINDOW.nVpos,TRUE);
  150.       InvalidateRect(hWnd,NULL,TRUE);
  151.       break;
  152.  
  153.     default:
  154.       return DefWindowProc(hWnd, Message, wParam, lParam);
  155.   }
  156.   return 0L;
  157.  
  158.