home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / os2pm / pckermit.mod < prev    next >
Text File  |  2020-01-01  |  5KB  |  120 lines

  1. MODULE PCKermit;
  2. (**************************************************************************)
  3. (*                                                                        *)
  4. (*                  PCKermit  --  by Brian R. Anderson                    *)
  5. (*                         Copyright (c) 1990                             *)
  6. (*                                                                        *)
  7. (*  PCKermit is an implementation of the Kermit file transfer protocol    *)
  8. (*  developed at Columbia University.  This (OS/2 PM) version is a        *)
  9. (*  port from the DOS version of Kermit that I wrote two years ago.       *)
  10. (*  My original DOS version appeared in the May 1989 issue of DDJ.        *)
  11. (*                                                                        *)
  12. (*  The current version includes emulation of the TVI950 Video Display    *)
  13. (*  Terminal for interaction with IBM mainframes (through the IBM 7171).  *)
  14. (*                                                                        *)
  15. (**************************************************************************)
  16.  
  17.    FROM SYSTEM IMPORT
  18.       ADR;
  19.  
  20.    FROM OS2DEF IMPORT
  21.       HAB, HWND, HPS, NULL, ULONG;
  22.  
  23.    FROM PMWIN IMPORT
  24.       MPARAM, HMQ, QMSG, CS_SIZEREDRAW,  WS_VISIBLE, FS_ICON,
  25.       FCF_TITLEBAR, FCF_SYSMENU, FCF_SIZEBORDER, FCF_MINMAX, FCF_ACCELTABLE,
  26.       FCF_SHELLPOSITION, FCF_TASKLIST, FCF_MENU, FCF_ICON,
  27.       SWP_MOVE, SWP_SIZE, SWP_MAXIMIZE,
  28.       HWND_DESKTOP, FID_SYSMENU, SC_CLOSE, MIA_DISABLED, MM_SETITEMATTR,
  29.       WinInitialize, WinCreateMsgQueue, WinGetMsg, WinDispatchMsg, WinSendMsg,
  30.       WinRegisterClass, WinCreateStdWindow, WinDestroyWindow, WinWindowFromID,
  31.       WinDestroyMsgQueue, WinTerminate, WinSetWindowText,
  32.       WinSetWindowPos, WinQueryWindowPos;
  33.  
  34.    FROM KH IMPORT
  35.       IDM_KERMIT;
  36.  
  37.    FROM Shell IMPORT
  38.       Class, Title, Child, WindowProc, ChildWindowProc,
  39.       FrameWindow, ClientWindow, SetPort, Pos;
  40.  
  41.  
  42.    CONST
  43.       QUEUE_SIZE = 1024;   (* Large message queue for async events *)
  44.  
  45.    VAR
  46.       AnchorBlock : HAB;
  47.       MessageQueue : HMQ;
  48.       Message : QMSG;
  49.       FrameFlags : ULONG;
  50.       hsys : HWND;
  51.       MP1, MP2 : MPARAM;
  52.  
  53.  
  54. BEGIN   (* main *)
  55.    AnchorBlock := WinInitialize(0);
  56.  
  57.    IF AnchorBlock # 0 THEN
  58.       MessageQueue := WinCreateMsgQueue (AnchorBlock, QUEUE_SIZE);
  59.  
  60.       IF MessageQueue # 0 THEN
  61.          (* Register the parent window class *)
  62.          WinRegisterClass (
  63.              AnchorBlock,
  64.              ADR (Class),
  65.              WindowProc,
  66.              CS_SIZEREDRAW, 0);
  67.  
  68.          (* Register a child window class *)
  69.          WinRegisterClass (
  70.              AnchorBlock,
  71.              ADR (Child),
  72.              ChildWindowProc,
  73.              CS_SIZEREDRAW, 0);
  74.  
  75.          (* Create a standard window *)
  76.          FrameFlags := FCF_TITLEBAR + FCF_MENU + FCF_MINMAX +
  77.                        FCF_SYSMENU + FCF_SIZEBORDER + FCF_TASKLIST +
  78.                        FCF_ICON + FCF_SHELLPOSITION + FCF_ACCELTABLE;
  79.  
  80.          FrameWindow := WinCreateStdWindow (
  81.                   HWND_DESKTOP,           (* handle of the parent window *)
  82.                   WS_VISIBLE + FS_ICON,   (* the window style *)
  83.                   FrameFlags,             (* the window flags *)
  84.                   ADR(Class),             (* the window class *)
  85.                   NULL,                   (* the title bar text *)
  86.                   WS_VISIBLE,             (* client window style *)
  87.                   NULL,                   (* handle of resource module *)
  88.                   IDM_KERMIT,             (* resource id *)
  89.                   ClientWindow            (* returned client window handle *)
  90.          );
  91.  
  92.          IF FrameWindow # 0 THEN
  93.             (* Disable the CLOSE item on the system menu *)
  94.             hsys := WinWindowFromID (FrameWindow, FID_SYSMENU);
  95.             MP1.W1 := SC_CLOSE;   MP1.W2 := 1;
  96.             MP2.W1 := MIA_DISABLED;   MP2.W2 := MIA_DISABLED;
  97.             WinSendMsg (hsys, MM_SETITEMATTR, MP1, MP2);
  98.  
  99.             (* Expand Window to Nearly Full Size, And Display the Title *)
  100.             WinQueryWindowPos (HWND_DESKTOP, Pos);
  101.             WinSetWindowPos (FrameWindow, 0,
  102.                Pos.x + 3, Pos.y + 3, Pos.cx - 6, Pos.cy - 6,
  103.                SWP_MOVE + SWP_SIZE);
  104.             WinSetWindowText (FrameWindow, ADR (Title));
  105.  
  106.             SetPort;   (* Try to initialize communications port *)
  107.  
  108.             WHILE WinGetMsg(AnchorBlock, Message, NULL, 0, 0) # 0 DO
  109.                WinDispatchMsg(AnchorBlock, Message);
  110.             END;
  111.  
  112.             WinDestroyWindow(FrameWindow);
  113.          END;
  114.          WinDestroyMsgQueue(MessageQueue);
  115.       END;
  116.       WinTerminate(AnchorBlock);
  117.    END;
  118. END PCKermit.
  119.  
  120.