📄 settings.c
字号:
{
case IDOK:
SaveCommEventsDlg(hdlg);
//
// FALL THROUGH
//
case IDCANCEL:
EndDialog(hdlg, LOWORD(wparam));
return TRUE;
case IDC_DEFAULTSBTN:
InitCommEventsDlg(hdlg, EVENTFLAGS_DEFAULT);
return TRUE;
case IDC_EVRXFLAGBTN:
EnableWindow(GetDlgItem(hdlg, IDC_FLAGEDIT), IsDlgButtonChecked(hdlg, IDC_EVRXFLAGBTN));
EnableWindow(GetDlgItem(hdlg, IDC_FLAGCHAR), IsDlgButtonChecked(hdlg, IDC_EVRXFLAGBTN));
return TRUE;
case IDC_FLAGEDIT:
GetHexControl(hdlg, IDC_FLAGEDIT, IDC_FLAGCHAR);
return TRUE;
}
break;
}
return FALSE;
}
/*-----------------------------------------------------------------------------
FUNCTION: SaveFlowControlDlg(HWND)
PURPOSE: Sets TTY flow control settings based on dlg controls
PARAMETERS:
hdlg - Dialog window handle
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void SaveFlowControlDlg(HWND hdlg)
{
BOOL fNewCTSOut, fNewDSROut, fNewDSRIn, fNewXOut, fNewXIn, fNewTXafterXoffSent;
DWORD dwNewDTRControl, dwNewRTSControl;
WORD wNewXONLimit, wNewXOFFLimit;
char chNewXON, chNewXOFF;
BOOL fSuccess;
BOOL fUpdateDCB = FALSE;
//
// update DTR and RTS control if needed
//
dwNewDTRControl = GetdwTTYItem( hdlg, IDC_DTRCONTROLCOMBO,
szDTRControlStrings, DTRControlTable,
sizeof(DTRControlTable)/sizeof(DTRControlTable[0]));
dwNewRTSControl = GetdwTTYItem( hdlg, IDC_RTSCONTROLCOMBO,
szRTSControlStrings, RTSControlTable,
sizeof(RTSControlTable)/sizeof(RTSControlTable[0]));
if (dwNewRTSControl != RTSCONTROL(TTYInfo) ||
dwNewDTRControl != DTRCONTROL(TTYInfo)) {
RTSCONTROL(TTYInfo) = dwNewRTSControl;
DTRCONTROL(TTYInfo) = dwNewDTRControl;
fUpdateDCB = TRUE;
}
//
// update XON/XOFF limits if needed
//
wNewXONLimit = GetDlgItemInt(hdlg, IDC_XONLIMITEDIT, &fSuccess, FALSE);
wNewXOFFLimit = GetDlgItemInt(hdlg, IDC_XOFFLIMITEDIT, &fSuccess, FALSE);
if (wNewXOFFLimit != XOFFLIMIT(TTYInfo) ||
wNewXONLimit != XONLIMIT(TTYInfo)) {
XOFFLIMIT(TTYInfo) = wNewXOFFLimit;
XONLIMIT(TTYInfo) = wNewXONLimit;
fUpdateDCB = TRUE;
}
//
// update XON/XOFF chars if needed
//
chNewXON = GetHexControl(hdlg, IDC_XONCHAREDIT, IDC_XONCHARDISP);
chNewXOFF = GetHexControl(hdlg, IDC_XOFFCHAREDIT, IDC_XOFFCHARDISP);
if (chNewXOFF != XOFFCHAR(TTYInfo) ||
chNewXON != XONCHAR(TTYInfo)) {
XOFFCHAR(TTYInfo) = chNewXOFF;
XONCHAR(TTYInfo) = chNewXON;
fUpdateDCB = TRUE;
}
//
// update booleans from check boxes
//
fNewTXafterXoffSent = IsDlgButtonChecked(hdlg, IDC_TXAFTERXOFFSENTCHK);
fNewCTSOut = IsDlgButtonChecked(hdlg, IDC_CTSOUTCHK);
fNewDSROut = IsDlgButtonChecked(hdlg, IDC_DSROUTCHK);
fNewDSRIn = IsDlgButtonChecked(hdlg, IDC_DSRINCHK);
fNewXOut = IsDlgButtonChecked(hdlg, IDC_XONXOFFOUTCHK);
fNewXIn = IsDlgButtonChecked(hdlg, IDC_XONXOFFINCHK);
if (fNewTXafterXoffSent != TXAFTERXOFFSENT(TTYInfo) ||
fNewCTSOut != CTSOUTFLOW(TTYInfo) ||
fNewDSROut != DSROUTFLOW(TTYInfo) ||
fNewDSRIn != DSRINFLOW(TTYInfo) ||
fNewXOut != XONXOFFOUTFLOW(TTYInfo) ||
fNewXIn != XONXOFFINFLOW(TTYInfo) ) {
CTSOUTFLOW(TTYInfo) = fNewCTSOut;
DSROUTFLOW(TTYInfo) = fNewDSROut;
DSRINFLOW(TTYInfo) = fNewDSRIn;
XONXOFFOUTFLOW(TTYInfo) = fNewXOut;
XONXOFFINFLOW(TTYInfo) = fNewXIn;
TXAFTERXOFFSENT(TTYInfo) = fNewTXafterXoffSent;
fUpdateDCB = TRUE;
}
//
// update current settings if they have actually changed
//
if (fUpdateDCB)
UpdateTTYInfo();
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: InitFlowControlDlg(HWND)
PURPOSE: Sets controls based on current tty flow control settings
PARAMETERS:
hdlg - Dialog window handle
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void InitFlowControlDlg(HWND hdlg)
{
//
// fill and init DTR control combo
//
FillComboBox( GetDlgItem( hdlg, IDC_DTRCONTROLCOMBO ),
szDTRControlStrings, DTRControlTable,
sizeof( DTRControlTable) / sizeof( DTRControlTable[0] ),
DTRCONTROL( TTYInfo ) );
//
// fill and init RTS control combo
//
FillComboBox( GetDlgItem( hdlg, IDC_RTSCONTROLCOMBO ),
szRTSControlStrings, RTSControlTable,
sizeof( RTSControlTable) / sizeof( RTSControlTable[0] ),
RTSCONTROL( TTYInfo ) );
//
// XON/XOFF characters
//
InitHexControl(hdlg, IDC_XONCHAREDIT, IDC_XONCHARDISP, XONCHAR(TTYInfo));
InitHexControl(hdlg, IDC_XOFFCHAREDIT, IDC_XOFFCHARDISP, XOFFCHAR(TTYInfo));
//
// XON/XOFF limits
//
SetDlgItemInt(hdlg, IDC_XONLIMITEDIT, XONLIMIT(TTYInfo), FALSE);
SetDlgItemInt(hdlg, IDC_XOFFLIMITEDIT, XOFFLIMIT(TTYInfo), FALSE);
//
// check boxes
//
CheckDlgButton(hdlg, IDC_CTSOUTCHK, CTSOUTFLOW(TTYInfo));
CheckDlgButton(hdlg, IDC_DSROUTCHK, DSROUTFLOW(TTYInfo));
CheckDlgButton(hdlg, IDC_DSRINCHK, DSRINFLOW(TTYInfo));
CheckDlgButton(hdlg, IDC_XONXOFFOUTCHK, XONXOFFOUTFLOW(TTYInfo));
CheckDlgButton(hdlg, IDC_XONXOFFINCHK, XONXOFFINFLOW(TTYInfo));
CheckDlgButton(hdlg, IDC_TXAFTERXOFFSENTCHK, TXAFTERXOFFSENT(TTYInfo));
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: FlowDefault(HWND, WORD)
PURPOSE: Sets controls based on hardware or software flow control
PARAMETERS:
hdlg - Dialog window handle
wId - ID of button used to set the default:
IDC_DTRDSRBTN - DTR/DSR hardware flow-control
IDC_RTSCTSBTN - RTS/CTS hardware flow-control
IDC_XOFFXONBTNBTN - XOFF/XON software flow control
IDC_NONEBTN - no flow control
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void FlowDefault(HWND hdlg, WORD wId)
{
//
// set dtr control to handshake if using DTR/DSR flow-control
//
SetComboBox( GetDlgItem( hdlg, IDC_DTRCONTROLCOMBO ),
sizeof( DTRControlTable) / sizeof( DTRControlTable[0] ),
wId == IDC_DTRDSRBTN ? DTR_CONTROL_HANDSHAKE : DTR_CONTROL_ENABLE);
//
// set rts control to handshake if using RTS/CTS flow-control
//
SetComboBox( GetDlgItem( hdlg, IDC_RTSCONTROLCOMBO ),
sizeof( RTSControlTable) / sizeof( RTSControlTable[0] ),
wId == IDC_RTSCTSBTN ? RTS_CONTROL_HANDSHAKE : RTS_CONTROL_ENABLE);
//
// set check boxes according to wId
//
switch(wId)
{
case IDC_RTSCTSBTN:
case IDC_DTRDSRBTN:
CheckDlgButton(hdlg, IDC_CTSOUTCHK, wId == IDC_RTSCTSBTN);
CheckDlgButton(hdlg, IDC_DSROUTCHK, wId == IDC_DTRDSRBTN);
CheckDlgButton(hdlg, IDC_XONXOFFOUTCHK, FALSE);
CheckDlgButton(hdlg, IDC_XONXOFFINCHK, FALSE);
break;
case IDC_XOFFXONBTN:
case IDC_NONEBTN:
CheckDlgButton(hdlg, IDC_CTSOUTCHK, FALSE);
CheckDlgButton(hdlg, IDC_DSROUTCHK, FALSE);
CheckDlgButton(hdlg, IDC_XONXOFFOUTCHK, wId == IDC_XOFFXONBTN);
CheckDlgButton(hdlg, IDC_XONXOFFINCHK, wId == IDC_XOFFXONBTN);
break;
}
//
// settings that are disabled when any 'default' flow-control is used
//
CheckDlgButton(hdlg, IDC_DSRINCHK, FALSE);
CheckDlgButton(hdlg, IDC_TXAFTERXOFFSENTCHK, FALSE);
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: FlowControlProc(HWND, UINT, WPARAM, LPARAM)
PURPOSE: Dialog Procedure for Flow Control Settings Dialog
PARAMETERS:
hdlg - Dialog window handle
uMessage - window message
wparam - message parameter (depends on message)
lparam - message parameter (depends on message)
RETURN:
TRUE if message is handled
FALSE if message is not handled
Exception is WM_INITDIALOG: returns FALSE since focus is not set
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
BOOL CALLBACK FlowControlProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
switch(uMessage)
{
case WM_INITDIALOG: // init controls
InitFlowControlDlg(hdlg);
break;
case WM_COMMAND:
switch(LOWORD(wparam))
{
case IDOK:
SaveFlowControlDlg(hdlg);
//
// FALL THROUGH
//
case IDCANCEL:
EndDialog(hdlg, LOWORD(wparam));
return TRUE;
case IDC_RTSCTSBTN:
case IDC_DTRDSRBTN:
case IDC_XOFFXONBTN:
case IDC_NONEBTN:
FlowDefault(hdlg, LOWORD(wparam));
return TRUE;
case IDC_XONCHAREDIT:
GetHexControl(hdlg, IDC_XONCHAREDIT, IDC_XONCHARDISP);
return TRUE;
case IDC_XOFFCHAREDIT:
GetHexControl(hdlg, IDC_XOFFCHAREDIT, IDC_XOFFCHARDISP);
return TRUE;
}
break;
}
return FALSE;
}
/*-----------------------------------------------------------------------------
FUNCTION: InitTimeoutsDlg(HWND, COMMTIMEOUTS)
PURPOSE: Initializes timeouts dialog controls based on parameter
PARAMETERS:
hdlg - Dialog window handle
ct - COMMTIMEOUTS used to set the dialog controls
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void InitTimeoutsDlg(HWND hdlg, COMMTIMEOUTS ct)
{
SetDlgItemInt(hdlg, IDC_READINTERVALEDIT, ct.ReadIntervalTimeout, FALSE);
SetDlgItemInt(hdlg, IDC_READMULTIPLIEREDIT, ct.ReadTotalTimeoutMultiplier, FALSE);
SetDlgItemInt(hdlg, IDC_READCONSTANTEDIT, ct.ReadTotalTimeoutConstant, FALSE);
SetDlgItemInt(hdlg, IDC_WRITEMULTIPLIEREDIT, ct.WriteTotalTimeoutMultiplier, FALSE);
SetDlgItemInt(hdlg, IDC_WRITECONSTANTEDIT, ct.WriteTotalTimeoutConstant, FALSE);
CheckDlgButton(hdlg, IDC_DISPLAYTIMEOUTS, SHOWTIMEOUTS(TTYInfo));
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: SaveTimeoutsDlg(HWND)
PURPOSE: Saves values from controls into tty timeout settings
PARAMETERS:
hdlg - Dialog window handle
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
void SaveTimeoutsDlg(HWND hdlg)
{
COMMTIMEOUTS ctNew;
//
// get new timeouts from dialog controls
//
ctNew.ReadIntervalTimeout = GetDlgItemInt(hdlg, IDC_READINTERVALEDIT, NULL, FALSE);
ctNew.ReadTotalTimeoutMultiplier = GetDlgItemInt(hdlg, IDC_READMULTIPLIEREDIT, NULL, FALSE);
ctNew.ReadTotalTimeoutConstant = GetDlgItemInt(hdlg, IDC_READCONSTANTEDIT, NULL, FALSE);
ctNew.WriteTotalTimeoutMultiplier = GetDlgItemInt(hdlg, IDC_WRITEMULTIPLIEREDIT, NULL, FALSE);
ctNew.WriteTotalTimeoutConstant = GetDlgItemInt(hdlg, IDC_WRITECONSTANTEDIT, NULL, FALSE);
SHOWTIMEOUTS(TTYInfo) = IsDlgButtonChecked(hdlg, IDC_DISPLAYTIMEOUTS);
//
// set new timeouts if they are different
//
if (memcmp(&ctNew, &(TIMEOUTSNEW(TTYInfo)), sizeof(COMMTIMEOUTS))) {
//
// if connected, set new time outs and purge pending operations
//
if (CONNECTED(TTYInfo)) {
if (!SetCommTimeouts(COMDEV(TTYInfo), &ctNew)) {
ErrorReporter("SetCommTimeouts");
return;
}
if (!PurgeComm(COMDEV(TTYInfo), PURGE_TXABORT | PURGE_RXABORT))
ErrorReporter("PurgeComm");
}
//
// save timeouts in the tty info structure
//
TIMEOUTSNEW(TTYInfo) = ctNew;
}
return;
}
/*-----------------------------------------------------------------------------
FUNCTION: TimeoutsProc(HWND, UINT, WPARAM, LPARAM)
PURPOSE: Dialog Procedure for comm timeouts
PARAMETERS:
hdlg - Dialog window handle
uMessage - window message
wparam - message parameter (depends on message)
lparam - message parameter (depends on message)
RETURN:
TRUE if message is handled
FALSE if message is not handled
Exception is WM_INITDIALOG: returns FALSE since focus is not set
HISTORY: Date: Author: Comment:
10/27/95 AllenD Wrote it
-----------------------------------------------------------------------------*/
BOOL CALLBACK TimeoutsProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam)
{
switch(uMessage)
{
case WM_INITDIALOG: // init controls
InitTimeoutsDlg(hdlg, TIMEOUTSNEW(TTYInfo));
break;
case WM_COMMAND:
switch(LOWORD(wparam))
{
case IDOK:
SaveTimeoutsDlg(hdlg);
//
// FALL THROUGH
//
case IDCANCEL:
EndDialog(hdlg, LOWORD(wparam));
return TRUE;
case IDC_DEFAULTSBTN:
InitTimeoutsDlg(hdlg, gTimeoutsDefault);
return TRUE;
}
break;
}
return FALSE;
}
BOOL CALLBACK GetADWORDProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
int iRet = 0;
if (uMessage == WM_COMMAND) {
switch(LOWORD(wParam)) {
case IDOK:
iRet = GetDlgItemInt(hDlg, IDC_DWORDEDIT, NULL, FALSE);
//
// FALL THROUGH
//
case IDCANCEL:
EndDialog(hDlg, iRet);
return TRUE;
}
}
return FALSE;
}
DWORD GetAFrequency()
{
return ((DWORD) DialogBox(ghInst, MAKEINTRESOURCE(IDD_GETADWORD), ghwndMain, GetADWORDProc));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -