📄 inter.c
字号:
case ID_ACTION_STOP: // "terminate" the call control threads and ungray menu items
// terminate the call control threads
SetEvent(hExitEvent);
StopDialogic();
// disable the Action/Stop menu item
EnableMenuItem(GetMenu(hWnd), ID_ACTION_STOP, MF_DISABLED | MF_GRAYED);
// enable the Options and Action/Start menu items
EnableMenuItem(GetMenu(hWnd), ID_OPTIONS_CSETTINGS, MF_ENABLED );
break;
default:
return;
} // switch (id)
}
/*************************************************************************************
* NAME : CSET_WndProc()
* DESCRIPTION : Message Handler for Options/channel settings menu item dialog box
* CAUTIONS : none.
*************************************************************************************/
BOOL CALLBACK CSET_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
BOOL fProcessed = TRUE;
switch(uMsg) {
HANDLE_MSG(hwnd, WM_INITDIALOG, CSET_OnInitDialog);
HANDLE_MSG(hwnd, WM_COMMAND, CSET_OnCommand);
default:
fProcessed = FALSE;
break;
}
return(fProcessed);
}
/*************************************************************************************
* NAME : CSET_OnCommand()
* DESCRIPTION : Message Handler for Option/channel setting messages
* CAUTIONS : none.
*************************************************************************************/
void CSET_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
char msg[ 128 ];
int index;
HANDLE hCBDti;
// return TRUE if DefDlgProc() should handle the dialog message
switch ( id )
{
case IDC_RADIO_DIGITAL:
if ( frontend == CT_NTANALOG )
{
dtibdnum = GetDigitalBoard();
if ( dtibdnum < 0 )
break;
hCBDti = GetDlgItem( hwnd, IDC_COMBO_DTI );
// Set the current selection of dti board
if ( dtibdnum )
{
sprintf( msg, "dtiB%d", dtibdnum + 1 );
index = SendMessage( hCBDti, CB_FINDSTRING, 0, (LPARAM) (LPCSTR)msg );
}
else
index = 0;
SendMessage( hCBDti, CB_SETCURSEL, index, 0 );
frontend = Dti.frontend[ dtibdnum ];
CheckBoxes( hwnd );
}
break;
case IDC_RADIO_ANALOG:
frontend = CT_NTANALOG;
CheckBoxes( hwnd );
break;
case IDC_SCBUS_ROUTE:
// save current routeag setting, user has not pressed OK button yet
routeag = !( routeag );
break;
case IDC_COMBO_DTI:
dtibdnum = SendDlgItemMessage( hwnd, IDC_COMBO_DTI, CB_GETCURSEL, 0, 0 );
frontend = Dti.frontend[ dtibdnum ];
CheckBoxes( hwnd );
break;
case IDC_COMBO_VOX:
d4xbdnum = SendDlgItemMessage( hwnd, IDC_COMBO_VOX, CB_GETCURSEL, 0, 0 );
d4xbdnum = SendDlgItemMessage( hwnd, IDC_COMBO_VOX, CB_GETITEMDATA, d4xbdnum, 0 );
CheckBoxes( hwnd );
break;
case IDOK:
// get values from the dialog box
// get number of channels needed, if selected number exceeds MAXCHANS,
// allow MAXCHANS to be used
maxchans = GetDlgItemInt( hwnd, IDC_NUM_CHN, NULL, FALSE );
if (maxchans > MAXCHANS)
{
sprintf(msg, "Maximum of %d can be used, you selected %d", MAXCHANS, maxchans);
MessageBox(hwnd, msg, "Caution", MB_OK | MB_ICONINFORMATION);
maxchans = MAXCHANS;
EndDialog( hwnd, id );
break;
}
if ( IsWindowEnabled( GetDlgItem( hwnd, IDC_PRO_NAME ) ) )
{
// This can be sure that the board is DM3
// get name of protocol needed
GetDlgItemText( hwnd, IDC_PRO_NAME, protocol, MAX_PRO_NAME );
routeag = FALSE;
}
// get SCbus route check box state
if ( SendDlgItemMessage( hwnd, IDC_SCBUS_ROUTE, BM_GETSTATE, 0, 0L ) == 0 )
routeag = FALSE;
else
routeag = TRUE;
EndDialog( hwnd, id );
break;
case IDCANCEL:
EndDialog( hwnd, id );
break;
}
}
/*************************************************************************************
* NAME : CSET_InitDialog()
* DESCRIPTION : Initializes the options/channel settings dialog box
* CAUTIONS : none.
*************************************************************************************/
BOOL CSET_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
HANDLE hCBVox = GetDlgItem( hwnd, IDC_COMBO_VOX );
HANDLE hCBDti = GetDlgItem( hwnd, IDC_COMBO_DTI );
int i;
LPARAM index;
char tmpbuff[ 30 ];
if ( dtibdnum == -1 )
{
// disable T1/E1 radio buttons if no Dti boards present
EnableWindow( GetDlgItem( hwnd, IDC_RADIO_DIGITAL ), FALSE );
}
CheckBoxes( hwnd );
// fill the VOX board combo box with board names
if ( Vox.NumBrdDevs )
{
SendMessage( hCBVox, CB_RESETCONTENT, 0, 0L );
for ( i = 0; i < Vox.NumBrdDevs; i++ )
{
if ( Vox.frontend[ i ] != CT_NTDM3 )
{
index = SendMessage( hCBVox, CB_ADDSTRING, 0, ( DWORD )( LPSTR )Vox.BrdNames[ i ] );
SendMessage( hCBVox, CB_SETITEMDATA, index, i );
}
}
// Set the current selection of vox board
if ( d4xbdnum )
{
sprintf( tmpbuff, "dxxxB%d", d4xbdnum + 1 );
index = SendMessage( hCBVox, CB_FINDSTRING, 0, (LPARAM) (LPCSTR)tmpbuff );
}
else
index = 0;
SendMessage( hCBVox, CB_SETCURSEL, index, 0 );
}
else
EnableWindow( hCBVox, FALSE ); // gray out the vox board combo box if no voice boards
// fill the DTI board combo box with board names
if ( Dti.NumBrdDevs )
{
SendMessage( hCBDti, CB_RESETCONTENT, 0, 0L );
for ( i = 0; i < Dti.NumBrdDevs; i++ )
{
index = SendMessage( hCBDti, CB_ADDSTRING, 0, ( DWORD )( LPSTR )Dti.BrdNames[ i ] );
SendMessage( hCBDti, CB_SETITEMDATA, index, i );
}
SendMessage( hCBDti, CB_SETCURSEL, dtibdnum, 0 );
}
else
EnableWindow(hCBDti, FALSE); // gray out the dti board combo box if no dti boards
// set number of channels to use
SetDlgItemInt( hwnd, IDC_NUM_CHN, maxchans, TRUE );
return TRUE;
}
/************************************************************
* NAME: BuildChanName(HANDLE)
*
************************************************************/
BOOL BuildChanName(HANDLE hWnd)
{
int index;
int chdev, tsdev; // For dx_open and dt_open
char dev_name[ 100 ];
char tmpbuff[ 100 ];
CT_DEVINFO ct_devinfo; // Device information structure
//dx_libinit(DLGC_MT); // link in multi threaded dxx dll
//dt_libinit(DLGC_MT); // link in multi threaded dti dll
//sr_libinit(DLGC_MT); // link in multi threaded srl dll
// get number of dti boards in system
if ( sr_getboardcnt( DEV_CLASS_DTI, &Dti.NumBrdDevs ) == -1 )
{
MessageBox(hWnd, "Error in retrieving voice board count", szAppName, MB_OK|MB_APPLMODAL);
return FALSE;
}
// make board and channel names for DTI devices
if ( Dti.NumBrdDevs )
{
for ( index = 0; index < Dti.NumBrdDevs; index++ )
{
sprintf( Dti.BrdNames[ index ], "dtiB%d\0", index + 1 );
sprintf( dev_name, "dtiB%dT1\0", index + 1 );
OutputDebugString( "dt_open() begin...\n" );
if ( ( tsdev = dt_open( dev_name, 0 ) ) == -1 )
{
sprintf( tmpbuff, "Cannot open channel %s. errno = %d", dev_name, errno );
MessageBox( hWnd, tmpbuff, szAppName, MB_OK|MB_APPLMODAL );
return FALSE;
}
OutputDebugString( "dt_open end!!!\n" );
// Get Device Information
if ( dt_getctinfo( tsdev, &ct_devinfo ) == -1 )
{
sprintf( tmpbuff, "Error message = %s", ATDV_ERRMSGP( tsdev ) );
MessageBox( hWnd, tmpbuff, szAppName, MB_OK|MB_APPLMODAL );
return FALSE;
}
if ( dt_close( tsdev ) == -1 )
{
sprintf( tmpbuff, "Cannot close channel %s. errno = %d", dev_name, errno );
MessageBox( hWnd, tmpbuff, szAppName, MB_OK|MB_APPLMODAL );
return FALSE;
}
if ( ct_devinfo.ct_devfamily == CT_DFDM3 )
Dti.frontend[ index ] = CT_NTDM3;
else
Dti.frontend[ index ] = ct_devinfo.ct_nettype;
}
dtibdnum = 0; // show dtiB1 as default dti board in Options Dti board selections combo box
frontend = Dti.frontend[ dtibdnum ];
}
// get number of voice boards in system
if ( sr_getboardcnt( DEV_CLASS_VOICE, &( Vox.NumBrdDevs ) ) == -1)
{
MessageBox( hWnd, "Error in retrieving voice board count", szAppName, MB_OK|MB_APPLMODAL );
return FALSE;
}
// make board and channel names for VOX devices
if ( Vox.NumBrdDevs )
{
for ( index = 0; index < Vox.NumBrdDevs; index++ )
{
sprintf( Vox.BrdNames[ index ], "dxxxB%d\0", index + 1 );
sprintf( dev_name, "dxxxB%dC1\0", index + 1 );
if ( ( chdev = dx_open( dev_name, 0 ) ) == -1 )
{
sprintf( tmpbuff, "Cannot open channel %s. errno = %d", dev_name, errno );
MessageBox( hWnd, tmpbuff, szAppName, MB_OK|MB_APPLMODAL );
return FALSE;
}
// Get Device Information
if ( dx_getctinfo( chdev, &ct_devinfo ) == -1 )
{
sprintf( tmpbuff, "Error message = %s", ATDV_ERRMSGP( chdev ) );
MessageBox( hWnd, tmpbuff, szAppName, MB_OK|MB_APPLMODAL );
return FALSE;
}
if ( dx_close( chdev ) == -1 )
{
sprintf( tmpbuff, "Cannot close channel %s. errno = %d", dev_name, errno );
MessageBox( hWnd, tmpbuff, szAppName, MB_OK|MB_APPLMODAL );
return FALSE;
}
if ( ct_devinfo.ct_devfamily == CT_DFDM3 )
Vox.frontend[ index ] = CT_NTDM3;
else
Vox.frontend[ index ] = CT_NTANALOG;
}
d4xbdnum = 0; // show dxxxB1 as default vox board in Options Vox board selections combo box
}
return TRUE;
}
/*************************************************************************************
* NAME : AboutDlgProc()
* DESCRIPTION : Dialog box for the about box
* CAUTIONS : none.
*************************************************************************************/
BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HANDLE hwndStatic;
switch(iMsg)
{
case WM_INITDIALOG:
hwndStatic = GetDlgItem(hDlg, IDC_DIALOGIC);
SetWindowText(hwndStatic, dialogic);
hwndStatic = GetDlgItem(hDlg, IDC_DIALOGIC2);
SetWindowText(hwndStatic, dialogic2);
hwndStatic = GetDlgItem(hDlg, IDC_VERSION);
SetWindowText(hwndStatic, version);
return TRUE;
case WM_COMMAND:
switch(LOWORD (wParam))
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg, 0);
return TRUE;
}
break;
}
return FALSE;
}
/***************************************************************************
* FUNCTION : CheckBoxes()
* DESCRIPTION : This function will check the type of dti board and change
* the attribute of Protocol Box and Voice Box
* INPUTS : The HWND and The dti board number.
* OUTPUTS : text (to the Protocol Box and the Voice Box)
***************************************************************************/
void CheckBoxes( HWND hwnd )
{
if ( frontend != CT_NTANALOG )
{
CheckRadioButton( hwnd,IDC_RADIO_ANALOG, IDC_RADIO_DIGITAL, IDC_RADIO_DIGITAL );
EnableWindow( GetDlgItem(hwnd, IDC_COMBO_DTI), TRUE); // un-gray DTI board select
if ( frontend == CT_NTDM3 )
{
EnableWindow( GetDlgItem( hwnd, IDC_COMBO_VOX ), FALSE ); // gray out voice board select
SendDlgItemMessage( hwnd, IDC_SCBUS_ROUTE, BM_SETCHECK, 0, 0 );
EnableWindow( GetDlgItem( hwnd, IDC_SCBUS_ROUTE ), FALSE ); // gray SC bus select
SetDlgItemText( hwnd,IDC_PRO_NAME, protocol ); // resume protocol box
EnableWindow( GetDlgItem( hwnd, IDC_PRO_NAME ), TRUE ); // un-gray protocol name edit
}
else
{
SendDlgItemMessage( hwnd, IDC_SCBUS_ROUTE, BM_SETCHECK, 1, 0 );
EnableWindow( GetDlgItem( hwnd, IDC_SCBUS_ROUTE ), FALSE ); // gray SC bus select
SetDlgItemText( hwnd, IDC_PRO_NAME, "" ); // Clear protocol box
EnableWindow( GetDlgItem( hwnd, IDC_PRO_NAME ), FALSE ); // gray protocol name edit
EnableWindow( GetDlgItem( hwnd, IDC_COMBO_VOX ), TRUE ); // un-gray out voice board select
}
}
else
{
// set frontend Group's Analog Radio Button
CheckRadioButton( hwnd,IDC_RADIO_ANALOG, IDC_RADIO_DIGITAL, IDC_RADIO_ANALOG );
// SCbus Routing?
SendDlgItemMessage( hwnd, IDC_SCBUS_ROUTE, BM_SETCHECK, routeag, 0 );
EnableWindow( GetDlgItem( hwnd, IDC_SCBUS_ROUTE ), TRUE ); // un-gray SC bus select
EnableWindow( GetDlgItem( hwnd, IDC_COMBO_VOX ), TRUE ); // un-gray vox board select
EnableWindow( GetDlgItem( hwnd, IDC_COMBO_DTI ), FALSE ); // gray DTI board select
SetDlgItemText( hwnd, IDC_PRO_NAME, "" ); // Clear protocol box
EnableWindow( GetDlgItem( hwnd, IDC_PRO_NAME ), FALSE ); // gray protocol name edit
}
}
/***************************************************************************
* FUNCTION : GetDigitalBoard()
* DESCRIPTION : This function will check the type of dti board and change
* the attribute of Protocol Box and Voice Box
* INPUTS : None.
* OUTPUTS : None.
* Return: -1 if failed, the number of digital board if success
***************************************************************************/
int GetDigitalBoard()
{
int i;
for ( i = dtibdnum; i < dtibdnum + Dti.NumBrdDevs; i++ )
if ( Dti.frontend[ i%Dti.NumBrdDevs ] != CT_NTANALOG )
return i%Dti.NumBrdDevs;
return -1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -