home *** CD-ROM | disk | FTP | other *** search
/ The Best Internet Programs / BESTINTERNET.bin / internet / winftp / ws_debug.c < prev    next >
C/C++ Source or Header  |  1993-12-14  |  3KB  |  110 lines

  1. /*
  2.   MODULE: WS_DEBUG.C (debug routines)
  3. */
  4.  
  5. #include "ws_glob.h"
  6. #include "winftp.h"
  7.  
  8. int CreateDebugWindow(HWND hMainWnd,HWND hInst)
  9. {
  10.   static WNDCLASS wndclass;
  11.   long       nWndunits;     // window units for size and location
  12.   int        nWndx;         // the x axis multiplier
  13.   int        nWndy;         // the y axis multiplier
  14.   int        nX;            // the resulting starting point (x, y)
  15.   int        nY;
  16.   int        nWidth;        // the resulting width and height for this
  17.   int        nHeight;       // window
  18.  
  19.   wndclass.style        = CS_VREDRAW | CS_PARENTDC;
  20.   wndclass.lpfnWndProc  = DebugWndProc;
  21.   wndclass.cbClsExtra   = 0;
  22.   wndclass.cbWndExtra   = 0;
  23.   wndclass.hInstance    = hInst;
  24.   wndclass.hIcon        = LoadIcon (hInst,"WINFTPD");
  25.   wndclass.hCursor      = LoadCursor ((HINSTANCE) NULL, IDC_ARROW);
  26.   wndclass.hbrBackground= GetStockObject(LTGRAY_BRUSH);
  27.   wndclass.lpszMenuName = NULL;
  28.   wndclass.lpszClassName= DBUGWNDCLASS;
  29.  
  30.   // Create a device independant size and location
  31.   nWndunits = GetDialogBaseUnits();
  32.   nWndx = LOWORD(nWndunits);
  33.   nWndy = HIWORD(nWndunits);
  34.   nX = ((40 * nWndx) / 4);
  35.   nY = ((40 * nWndy) / 8);
  36.   nWidth = ((200 * nWndx) / 4);
  37.   nHeight = ((200 * nWndy) / 8);
  38.  
  39.   RegisterClass(&wndclass);
  40.  
  41.   hWndDbg=CreateWindow (DBUGWNDCLASS, lpDebugWindow, WS_OVERLAPPEDWINDOW,
  42.       nX,nY,nWidth,nHeight, (HWND) NULL,(HMENU) NULL,hInst,NULL);
  43.   ShowWindow (hWndDbg, SW_HIDE);
  44.   return(TRUE);
  45. }
  46.  
  47. //*******************************************************************
  48. //*******************************************************************
  49. void SetDebugWindowText (LPSTR lpsz)
  50. {
  51.   SetWindowText (hWndDbg, lpsz);
  52. }
  53.  
  54. //*******************************************************************
  55. //*******************************************************************
  56. LRESULT CALLBACK DebugWndProc (HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
  57. {
  58.   // int nRC;
  59.  
  60.   switch (Message)
  61.   {
  62.     case WM_CREATE:
  63.       SetScrollRange(hWnd, SB_VERT, 0, 100, FALSE);
  64.       CheckMenuItem (GetMenu (hWnd), IDM_LOGTOFILE, nLogFlag);
  65.       sVPos = 0;
  66.       break;
  67.  
  68.     case WM_SETCURSOR:
  69.       if(bCmdInProgress)
  70.         SetCursor(hWaitCursor);
  71.       else
  72.         return DefWindowProc(hWnd, Message, wParam, lParam);
  73.       break;
  74.  
  75.     case WM_PAINT:
  76.       DoPaint((HWND)hWnd);
  77.       break;
  78.  
  79.     case WM_VSCROLL:
  80.       switch(wParam)
  81.       {
  82.         case SB_LINEDOWN:
  83.           if(sVPos<((UINT) ptrhGMem-1)) sVPos++;
  84.           break;
  85.         case SB_LINEUP:
  86.           if(sVPos>0) --sVPos;
  87.           break;
  88.         case SB_THUMBPOSITION:
  89.           sVPos = (UINT) min((WORD) ptrhGMem, LOWORD(lParam));
  90.           break;
  91.         case SB_PAGEUP:
  92.           if(sVPos>10) sVPos-=10; else sVPos=0;
  93.           break;
  94.         case SB_PAGEDOWN:
  95.           if(sVPos<(UINT) (ptrhGMem-10)) sVPos+=10; else sVPos=ptrhGMem;
  96.           break;
  97.         default:
  98.           return FALSE;
  99.       }
  100.       SetScrollPos(hWnd,SB_VERT,sVPos,TRUE);
  101.       InvalidateRect(hWnd,NULL,TRUE);
  102.       break;
  103.     default:
  104.       return DefWindowProc(hWnd, Message, wParam, lParam);
  105.   }
  106.   return 0L;
  107.  
  108.  
  109.