MODULE PCKermit; (**************************************************************************) (* *) (* PCKermit -- by Brian R. Anderson *) (* Copyright (c) 1990 *) (* *) (* PCKermit is an implementation of the Kermit file transfer protocol *) (* developed at Columbia University. This (OS/2 PM) version is a *) (* port from the DOS version of Kermit that I wrote two years ago. *) (* My original DOS version appeared in the May 1989 issue of DDJ. *) (* *) (* The current version includes emulation of the TVI950 Video Display *) (* Terminal for interaction with IBM mainframes (through the IBM 7171). *) (* *) (**************************************************************************) FROM SYSTEM IMPORT ADR; FROM OS2DEF IMPORT HAB, HWND, HPS, NULL, ULONG; FROM PMWIN IMPORT MPARAM, HMQ, QMSG, CS_SIZEREDRAW, WS_VISIBLE, FS_ICON, FCF_TITLEBAR, FCF_SYSMENU, FCF_SIZEBORDER, FCF_MINMAX, FCF_ACCELTABLE, FCF_SHELLPOSITION, FCF_TASKLIST, FCF_MENU, FCF_ICON, SWP_MOVE, SWP_SIZE, SWP_MAXIMIZE, HWND_DESKTOP, FID_SYSMENU, SC_CLOSE, MIA_DISABLED, MM_SETITEMATTR, WinInitialize, WinCreateMsgQueue, WinGetMsg, WinDispatchMsg, WinSendMsg, WinRegisterClass, WinCreateStdWindow, WinDestroyWindow, WinWindowFromID, WinDestroyMsgQueue, WinTerminate, WinSetWindowText, WinSetWindowPos, WinQueryWindowPos; FROM KH IMPORT IDM_KERMIT; FROM Shell IMPORT Class, Title, Child, WindowProc, ChildWindowProc, FrameWindow, ClientWindow, SetPort, Pos; CONST QUEUE_SIZE = 1024; (* Large message queue for async events *) VAR AnchorBlock : HAB; MessageQueue : HMQ; Message : QMSG; FrameFlags : ULONG; hsys : HWND; MP1, MP2 : MPARAM; BEGIN (* main *) AnchorBlock := WinInitialize(0); IF AnchorBlock # 0 THEN MessageQueue := WinCreateMsgQueue (AnchorBlock, QUEUE_SIZE); IF MessageQueue # 0 THEN (* Register the parent window class *) WinRegisterClass ( AnchorBlock, ADR (Class), WindowProc, CS_SIZEREDRAW, 0); (* Register a child window class *) WinRegisterClass ( AnchorBlock, ADR (Child), ChildWindowProc, CS_SIZEREDRAW, 0); (* Create a standard window *) FrameFlags := FCF_TITLEBAR + FCF_MENU + FCF_MINMAX + FCF_SYSMENU + FCF_SIZEBORDER + FCF_TASKLIST + FCF_ICON + FCF_SHELLPOSITION + FCF_ACCELTABLE; FrameWindow := WinCreateStdWindow ( HWND_DESKTOP, (* handle of the parent window *) WS_VISIBLE + FS_ICON, (* the window style *) FrameFlags, (* the window flags *) ADR(Class), (* the window class *) NULL, (* the title bar text *) WS_VISIBLE, (* client window style *) NULL, (* handle of resource module *) IDM_KERMIT, (* resource id *) ClientWindow (* returned client window handle *) ); IF FrameWindow # 0 THEN (* Disable the CLOSE item on the system menu *) hsys := WinWindowFromID (FrameWindow, FID_SYSMENU); MP1.W1 := SC_CLOSE; MP1.W2 := 1; MP2.W1 := MIA_DISABLED; MP2.W2 := MIA_DISABLED; WinSendMsg (hsys, MM_SETITEMATTR, MP1, MP2); (* Expand Window to Nearly Full Size, And Display the Title *) WinQueryWindowPos (HWND_DESKTOP, Pos); WinSetWindowPos (FrameWindow, 0, Pos.x + 3, Pos.y + 3, Pos.cx - 6, Pos.cy - 6, SWP_MOVE + SWP_SIZE); WinSetWindowText (FrameWindow, ADR (Title)); SetPort; (* Try to initialize communications port *) WHILE WinGetMsg(AnchorBlock, Message, NULL, 0, 0) # 0 DO WinDispatchMsg(AnchorBlock, Message); END; WinDestroyWindow(FrameWindow); END; WinDestroyMsgQueue(MessageQueue); END; WinTerminate(AnchorBlock); END; END PCKermit.