📄 counter.c
字号:
CheckRadioButton( hDlg,IDC_OutputEnable,IDC_OutputDisable,IDC_OutputDisable );
EnableWindow( GetDlgItem( hDlg,IDC_OUTMODE ), FALSE );
}
*/
// initial output mode
SendDlgItemMessage(
hDlg,
IDC_OUTMODE,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"OUTPUT DISABLE"));
SendDlgItemMessage(
hDlg,
IDC_OUTMODE,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"TPGGLED FROM LOW"));
SendDlgItemMessage(
hDlg,
IDC_OUTMODE,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"TC OUTPUT"));
SendDlgItemMessage(
hDlg,
IDC_OUTMODE,
CB_SETCURSEL,
//gwOutputModeIndex,
gwOutputMode,
0);
// initial count source
SendDlgItemMessage(
hDlg,
IDC_CntClkSrc,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"IDI0"));
SendDlgItemMessage(
hDlg,
IDC_CntClkSrc,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"1 MHz"));
SendDlgItemMessage(
hDlg,
IDC_CntClkSrc,
CB_SETCURSEL,
//gwClkSrcIndex,
gwClkSrc,
0);
// initial count interrupt
CheckRadioButton(hDlg, IDC_IntEnable, IDC_IntDisable,
(gwIntFlag)?IDC_IntEnable:IDC_IntDisable );
SendDlgItemMessage(
hDlg,
IDC_GateSrc,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"GATING"));
SendDlgItemMessage(
hDlg,
IDC_GateSrc,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"IDI16 AS GATE HIGH"));
SendDlgItemMessage(
hDlg,
IDC_GateSrc,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"IDI16 AS GATE LOW"));
SendDlgItemMessage(
hDlg,
IDC_GateSrc,
CB_ADDSTRING,
0,
(LPARAM)((LPSTR)"NO GATING"));
SendDlgItemMessage(
hDlg,
IDC_GateSrc,
CB_SETCURSEL,
//gwGateSrcIndex,
gwGateSrc,
0);
return TRUE;
case WM_COMMAND :
switch (LOWORD(wParam))
{
case IDOK :
{
//
// get device selection
//
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_DEVICE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwDevice = (WORD)dwIndex;
//
// get sub-device selection
//
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_MODULE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwSubDevice = (WORD)dwIndex;
// get output mode
gwOutputMode = (USHORT)SendDlgItemMessage(
hDlg,
IDC_OUTMODE,
CB_GETCURSEL,
0,
(LPARAM)0 );
// if output disable, gwOutputModeIndex = 0;
/*
if (EnableWindow( GetDlgItem( hDlg,IDC_GateSrc ), FALSE ))
{
gwGateSrc = 0; // gating
}
else // get gate source
{
*/
gwGateSrc = (USHORT)SendDlgItemMessage(
hDlg,
IDC_GateSrc,
CB_GETCURSEL,
0,
(LPARAM)0 );
//}
// get clock source
gwClkSrc = (USHORT)SendDlgItemMessage(
hDlg,
IDC_CntClkSrc,
CB_GETCURSEL,
0,
(LPARAM)0 );
}
case IDCANCEL :
EndDialog(hDlg, 0);
return TRUE;
/*
case IDC_OutputEnable:
EnableWindow(GetDlgItem(hDlg, IDC_OUTMODE), TRUE);
gwOutputEnable = PA_MODE_ENABLE_OUTPUT;
break;
case IDC_OutputDisable:
EnableWindow(GetDlgItem(hDlg, IDC_OUTMODE), FALSE);
gwOutputEnable = PA_MODE_DISABLE_OUTPUT;
break;
*/
case IDC_IntEnable:
gwIntFlag = 1;
break;
case IDC_IntDisable:
gwIntFlag = 0;
case IDC_CntIniVal :
if ( HIWORD(wParam) == EN_KILLFOCUS )
{
if(SendDlgItemMessage(hDlg, IDC_CntIniVal,
EM_GETMODIFY, 0, 0))
{
SendDlgItemMessage(hDlg, IDC_CntIniVal,
WM_GETTEXT, 10, (LPARAM)(LPSTR)szBuffer) ;
g_usIniVal = atol(szBuffer);
SendDlgItemMessage(hDlg, IDC_CntIniVal,
EM_SETMODIFY, FALSE, 0) ;
}
if ( ( g_usIniVal <= 0 )||( g_usIniVal > 65535 ))
{
MessageBox( hDlg, "Invalid Counter Terminate Value",
"Notice", MB_OK );
g_usIniVal = 65535;
itoa(g_usIniVal, szBuffer, 10);
SendDlgItemMessage(hDlg, IDC_CntIniVal, EM_UNDO, 0,
(LPARAM)((LPSTR)szBuffer));
return TRUE;
}
}
return TRUE;
case IDC_DEVICE :
//
// When device selection is changed, it needs to
// re-initialize sub-device combobox and input range
// combobox.
//
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_DEVICE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwDevice = (WORD)dwIndex;
else
return TRUE;
// ------------------------------------------------------
// Initialize Module Combobox for COM port or CAN devices
// ------------------------------------------------------
// check any device attached on this COM port or CAN
gnNumOfSubdevices = DeviceList[gwDevice].nNumOfSubdevices;
if (gnNumOfSubdevices > MAX_DEVICES)
gnNumOfSubdevices = MAX_DEVICES;
// retrieve the information of all installed devices
if (gnNumOfSubdevices != 0)
{
if ((ErrCde = DRV_DeviceGetSubList(
(DWORD)DeviceList[gwDevice].dwDeviceNum,
(DEVLIST far *)&SubDeviceList[0],
(SHORT)gnNumOfSubdevices,
(SHORT far *)&nOutEntries)) != (LONG)SUCCESS)
{
DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
MessageBox(hMainWnd, (LPCSTR)szErrMsg,
"Driver Message", MB_OK);
return TRUE;
}
// initialize the Module List Combobox with the
// retrieved information
EnableWindow(GetDlgItem(hDlg, IDC_MODULE), TRUE);
SendDlgItemMessage(hDlg, IDC_MODULE, CB_RESETCONTENT,
0, (LPARAM)((LPSTR)0));
for (i = 0; i < gnNumOfSubdevices; i++)
SendDlgItemMessage(hDlg, IDC_MODULE, CB_ADDSTRING, 0,
(LPARAM)((LPSTR)SubDeviceList[i].szDeviceName));
gwSubDevice = 0;
SendDlgItemMessage(hDlg, IDC_MODULE, CB_SETCURSEL,
(WPARAM)gwSubDevice, (LPARAM)0);
}
else
{
EnableWindow(GetDlgItem(hDlg, IDC_MODULE), FALSE);
SendDlgItemMessage(hDlg, IDC_MODULE, CB_RESETCONTENT,
0, (LPARAM)((LPSTR)0));
}
}
return TRUE;
}
break;
}
return FALSE ;
}
/***************************************************************************
FUNCTION: ScanDlgProc(HWND, unsigned, WPARAM, LPARAM)
PURPOSE: Processes dialog box messages for scan time settings
****************************************************************************/
BOOL FTYPE ScanDlgProc
(
HWND hDlg, // window handle
unsigned message, // type of message
WPARAM wParam, // additional information
LPARAM lParam // additional information
)
{
char szBuffer[40];
switch (message)
{
case WM_INITDIALOG :
// ---------------------------------------------------
// Initialize Scan Time Edit, Maximum accuracy: 40 ms
// ---------------------------------------------------
itoa(gwScanTime, szBuffer, 10);
SendDlgItemMessage(hDlg, IDC_SCAN, EM_REPLACESEL, 0,
(LPARAM)((LPSTR)szBuffer));
return TRUE;
case WM_COMMAND :
switch (LOWORD(wParam))
{
case IDOK :
//
// get scan time
//
if (SendDlgItemMessage(hDlg, IDC_SCAN,
EM_GETMODIFY, 0, 0))
{
SendDlgItemMessage(hDlg, IDC_SCAN,
WM_GETTEXT, 10, (LPARAM)(LPSTR)szBuffer) ;
gwScanTime = atoi(szBuffer);
SendDlgItemMessage(hDlg, IDC_SCAN,
EM_SETMODIFY, FALSE, 0) ;
}
case IDCANCEL :
EndDialog(hDlg, 0);
return TRUE;
}
break;
}
return FALSE ;
}
/***************************************************************************
FUNCTION: MainWndProc(HWND, unsigned, WPARAM, LPARAM)
PURPOSE: Processes messages
MESSAGES:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -