|
|
Microsoft OS/2 SDK PM 08-08-1988
PMCOMM is a small port of the TERMINAL application found in the
OS/2 1.02 SDK. It turns out that only about 5% of the code was
ported. Modem support was commented out. For a person who wants
to do more with this, all they have to do is bring in the MODEM.C
file found with the TERMINAL sources and update it to the latest
os/2 release.
This program was made to reflect the following items in a PM
application.
o use of a thread to read a Comm Port.
o how to display and hide the scroll bars on the Window FRAME.
o how to set the menu attributes in one section of your code.
o use of changing the caption bar.
o use of accelerator keys.
o use of button controls in a dialog box.
o use of the WinQueryQueueStatus fucntion to check the queue
for interesting messages.
o use of the peek message function
o changing the cursor
Due to time constraints here is a TO DO / WISH list.
A lot more needs to be added to make it more functional.
------------------------
Make the write fucntion a separate thread.
Move the WM_BLAST routine to another thread or put at the bottom
of the urrent read thread.
Allow for making the code more modual so that everything does not
need to be resident when running.
Allow for clipboard - both ways.
Allow a dialog for the desired display buffer size.
It is now set by #define MAXWIDTH and MAXLINES.
Make the Settings dialog more robust.
Fix pause scrolling.
Make the paint routine smarter. I keep the line length so that
an offset can be provided. The array of pointers for the display,
pStartLine is not necessary due to the fact that each line is a
fixed length from the start.
Also see if you can scroll two or three lines at a time.
Any more than three might be too much of a flicker.
Scroll bar ranges are not correct.
Time and consideration was provided for adding more functionality.
That is why you will see flags and variables saved that are not used.
Here is the flow of PMCOMM.
MAIN
--------------------------------
Creates a window.
WM_CREATE message:
Gets font metrics
Gets handles to scroll bars.
Hides scroll bars.
Creates the ReadComm thread.
Checks to see if an *.INI file was supplied.
Calls ReadINIFile.
Reads the supplied or default INI file.
Builds the caption bar with the current file name.
Goes into normal Windows message loop.
MENU ITEMS follow:
--------------------------------
SETTINGS:
Dialog comes up to prompt the user for comm settings.
START:
InitBuffers();
Initializes all necessary flags to be used.
Initializes all buffers.
InitCommPort();
Opens comm port with settings provided.
(Should I flush the queses at this poing also?)
Clears ReadComm thread.
Sets the focus to the window.
Enables and disables correct menu items.
CAPTURE:
Sets a flag to pass all characters to a file.
Displays a simple dialog asking for a file name
to append to.
Sets the "c" in the caption bar.
PAUSE:
Enables and disables:
arrow keys
menu item
scroll bars are made in/visible.
TEST:
Dumps current contents of display buffer to a file.
Displays the characters in a MessageBox as they come in.
BREAK:
Sends a BREAK character to the host.
ECHO:
Enables and disables echo to local terminal.
STOP:
Flushes and then closes the comm port.
Enables and disables correct menu items.
If any changes were made to the Comm Settings
the user is asked if they wish to save
the changes.
READ THREAD
--------------------------------
Checks the buffer to determine the # of characters to read.
DosReads the comm port with the # of characters from previous step.
After read, sets Read Semiphore not to read.
Posts a message, WM_BLAST,
OTHER EVENTS
--------------------------------
WM_CHAR:
These are passed to the WriteCommPort().
WM_INITMENU:
This message is sent before a menu is displayed.
This provides an easy way to set the menu items
in one place depending on flags you set up.
WM_SIZE:
Determines displayable area and calls WM_PAINT routine.
WM_PAINT:
Determines displayable area and displays from a circular
display buffer.
WM_BLAST: does the following:
Formats the characters into a display buffer.
Displays the characters to the screen.
Clears Read Semiphore.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.