WinComm/vbx/mscomm.h
2026-02-23 20:53:02 -06:00

141 lines
5.7 KiB
C

// mscomm.h - MSComm VBX control definitions
//
// Property/event IDs, comm event constants, and control instance data.
#ifndef MSCOMM_H
#define MSCOMM_H
#include "vbapi.h"
#include "serial.h"
// -----------------------------------------------------------------------
// stdint types for MSVC 1.52 (shared with serial.h)
// -----------------------------------------------------------------------
#ifndef _STDINT_DEFINED
typedef short int16_t;
typedef unsigned short uint16_t;
typedef long int32_t;
typedef unsigned long uint32_t;
typedef unsigned char uint8_t;
typedef signed char int8_t;
#define _STDINT_DEFINED
#endif
// -----------------------------------------------------------------------
// Resource IDs
// -----------------------------------------------------------------------
#define IDB_MSCOMM 8000
// -----------------------------------------------------------------------
// Property indices (position in npproplist array)
// -----------------------------------------------------------------------
#define IPROP_CTLNAME 0
#define IPROP_INDEX 1
#define IPROP_TAG 2
#define IPROP_COMMPORT 3
#define IPROP_SETTINGS 4
#define IPROP_PORTOPEN 5
#define IPROP_INPUT 6
#define IPROP_OUTPUT 7
#define IPROP_INBUFFERSIZE 8
#define IPROP_OUTBUFFERSIZE 9
#define IPROP_INBUFFERCOUNT 10
#define IPROP_OUTBUFFERCOUNT 11
#define IPROP_RTHRESHOLD 12
#define IPROP_STHRESHOLD 13
#define IPROP_HANDSHAKING 14
#define IPROP_INPUTLEN 15
#define IPROP_INPUTMODE 16
#define IPROP_DTRENABLE 17
#define IPROP_RTSENABLE 18
#define IPROP_CDHOLDING 19
#define IPROP_CTSHOLDING 20
#define IPROP_DSRHOLDING 21
#define IPROP_BREAK 22
#define IPROP_COMMEVENT 23
#define IPROP_NULLDISCARD 24
#define IPROP_EOFENABLE 25
#define IPROP_PARITYREPLACE 26
// -----------------------------------------------------------------------
// Event indices (position in npeventlist array)
// -----------------------------------------------------------------------
#define IEVENT_ONCOMM 0
// -----------------------------------------------------------------------
// CommEvent constants - Communication events
// -----------------------------------------------------------------------
#define COM_EV_RECEIVE 1 // Received RThreshold bytes
#define COM_EV_SEND 2 // Transmit buffer has SThreshold space
#define COM_EV_CTS 3 // CTS line changed
#define COM_EV_DSR 4 // DSR line changed
#define COM_EV_CD 5 // CD (RLSD) line changed
#define COM_EV_RING 6 // Ring indicator detected
#define COM_EV_EOF 7 // EOF character received
// -----------------------------------------------------------------------
// CommEvent constants - Error events
// -----------------------------------------------------------------------
#define COM_EVT_BREAK 1001 // Break signal received
#define COM_EVT_FRAME 1004 // Framing error
#define COM_EVT_OVERRUN 1006 // Hardware overrun
#define COM_EVT_RXOVER 1008 // Receive buffer overflow
#define COM_EVT_RXPARITY 1009 // Parity error
#define COM_EVT_TXFULL 1010 // Transmit buffer full
// -----------------------------------------------------------------------
// Handshaking enum values
// -----------------------------------------------------------------------
#define HS_NONE 0
#define HS_XONXOFF 1
#define HS_RTSCTS 2
#define HS_BOTH 3
// -----------------------------------------------------------------------
// InputMode enum values
// -----------------------------------------------------------------------
#define INPUT_TEXT 0
#define INPUT_BINARY 1
// -----------------------------------------------------------------------
// Control instance data
//
// Allocated by VB as cbCtlExtra bytes per control instance.
// Accessed via VBDerefControl(hctl).
// -----------------------------------------------------------------------
typedef struct {
int16_t commId; // OpenComm handle (-1 = closed)
HWND hwndNotify; // Hidden notification window
int16_t commPort; // COM port number (1-16)
HSZ hszSettings; // Settings string "baud,parity,data,stop"
int16_t inBufferSize; // Receive buffer size in bytes
int16_t outBufferSize; // Transmit buffer size in bytes
int16_t rThreshold; // Receive event threshold (0=disabled)
int16_t sThreshold; // Send event threshold (0=disabled)
int16_t handshaking; // Handshaking mode (HS_*)
int16_t inputLen; // Bytes to read per Input (0=all)
int16_t inputMode; // Input mode (INPUT_TEXT/INPUT_BINARY)
int16_t commEvent; // Last comm event code
BOOL portOpen; // Port open state
BOOL dtrEnable; // DTR line enable
BOOL rtsEnable; // RTS line enable
BOOL breakState; // Break signal active
BOOL nullDiscard; // Discard null characters
BOOL eofEnable; // Watch for EOF character
BOOL ctsState; // Shadow state: CTS line level
BOOL dsrState; // Shadow state: DSR line level
BOOL cdState; // Shadow state: CD (RLSD) line level
HSZ hszParityReplace; // Parity error replacement character
} MsCommDataT;
// -----------------------------------------------------------------------
// Hidden notification window class name
// -----------------------------------------------------------------------
#define NOTIFY_CLASS "MsCommNotify"
// -----------------------------------------------------------------------
// Global instance handle (set in LibMain)
// -----------------------------------------------------------------------
extern HANDLE ghInstance;
#endif // MSCOMM_H