msgshowdlg.cpp
来自「1553B板卡的源代码,只有购买板卡才能得到的好资料」· C++ 代码 · 共 1,611 行 · 第 1/3 页
CPP
1,611 行
void CMsgShowDlg::OnChangeMshowEdBased()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
char c[80], s[80];
char tc='\0';
int i=0;
int l=0, j=0;
BOOL isErr=FALSE;
DWORD dw=0;
l = Edit_LineLength(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), -1);
if (l==0)
return;
memset(s, 0, sizeof(s));
memset(c, 0, sizeof(c));
dw = Edit_GetSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED));
::GetWindowText(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), c, sizeof(c)); // get data string with HEX
// analyze data string with HEX
//
j=0;
for (i=0; i<l; i++)
{
tc = c[i];
if (((tc>='a')&&(tc<='f'))||((tc>='0')&&(tc<='9'))||((tc>='A')&&(tc<='F')))
{
s[j] = tc;
j++;
}
else
{
isErr=TRUE;
}
}
if (!isErr)
return;
// write back the HEX value
//
::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), TEXT(s));
Edit_SetSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), HIWORD(dw)-1, HIWORD(dw)-1);
}
BOOL CMsgShowDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
WORD wlow=0, whigh=0;
HWND hWnd=(HWND)lParam;
wlow = LOWORD(wParam); // retrieve ID of control
if ((wlow>=IDC_MSHOW_ED_DATA0) && (wlow<=IDC_MSHOW_ED_DATA31))
{
whigh = HIWORD(wParam); // retrieve notify message of control
if (whigh == EN_CHANGE) // on edit changed
{
char c[80], s[80];
char tc='\0';
int i=0;
int l=0, j=0;
BOOL isErr=FALSE;
DWORD dw=0;
l = Edit_LineLength(hWnd, -1);
if (l==0)
return CDialog::OnCommand(wParam, lParam);
memset(s, 0, sizeof(s));
memset(c, 0, sizeof(c));
dw = Edit_GetSel(hWnd);
::GetWindowText(hWnd, c, sizeof(c)); // get data string with HEX
// analyze data string with HEX
//
j=0;
for (i=0; i<l; i++)
{
tc = c[i];
if (((tc>='a')&&(tc<='f'))||((tc>='0')&&(tc<='9'))||((tc>='A')&&(tc<='F')))
{
s[j] = tc;
j++;
}
else
{
isErr=TRUE;
}
}
if (!isErr)
return CDialog::OnCommand(wParam, lParam);
// write back the HEX value
//
::SetWindowText(hWnd, TEXT(s));
Edit_SetSel(hWnd, HIWORD(dw)-1, HIWORD(dw)-1);
}
if (whigh == EN_KILLFOCUS) // on edit kill focus
{
if (Edit_LineLength(hWnd, -1)==0)
{
::SetWindowText(hWnd, TEXT("0"));
}
else
{
char c[80];
memset(c, 0, sizeof(c));
::GetWindowText(hWnd, c, sizeof(c));
strupr(c);
::SetWindowText(hWnd, TEXT(c));
}
}
}
return CDialog::OnCommand(wParam, lParam);
}
void CMsgShowDlg::OnKillfocusMshowEdBased()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
if (Edit_LineLength(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), -1)==0)
{
::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), TEXT("0"));
}
else
{
char c[80];
memset(c, 0, sizeof(c));
::GetWindowText(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), c, sizeof(c));
strupr(c);
::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_BASED), TEXT(c));
}
}
void CMsgShowDlg::OnKillfocusMshowEdMint()
{
// TODO: Add your control notification handler code here
if (Edit_LineLength(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_MINT), -1)==0)
{
::SetWindowText(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_MINT), TEXT("0"));
}
}
void CMsgShowDlg::OnMshowCkBcast()
{
// TODO: Add your control notification handler code here
BYTE msgtype=0;
int i=0, j=0;
msgtype = g_TempMsg.msg.MSGFormat;
if (Button_GetCheck(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CK_BCAST))==BST_UNCHECKED)
{
if (::OwnRTAddr(cmd1)==31)
{
j = this->GetRTAddr(0);
if (j!=31)
{
cmd1 = ::SetRTAddr(cmd1, j); // change RT addr
this->SetRTAddr(j, 0);
}
else
{
cmd1 = ::SetRTAddr(cmd1, 1); // change RT addr
this->SetRTAddr(1, 0);
}
}
g_TempMsg.msg.MSGFormat = (g_TempMsg.msg.MSGFormat & (~FMSG_BRDCST));
}
else
{
cmd1 = ::SetRTAddr(cmd1, 31); // change RT addr
this->SetRTAddr(31, 0);
g_TempMsg.msg.MSGFormat = (g_TempMsg.msg.MSGFormat | FMSG_BRDCST);
}
this->SetCmdWord(cmd1, 0);
}
short CMsgShowDlg::GetRTAddr(unsigned char id)
{
short rt=0;
if (id==0)
{
rt = ComboBox_GetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_RTADDR0));
}
else
{
rt = ComboBox_GetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_RTADDR1));
}
return rt;
}
void CMsgShowDlg::SetRTAddr(short val, unsigned char id)
{
if (id==0)
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_RTADDR0), val);
}
else
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_RTADDR1), val);
}
}
void CMsgShowDlg::OnMshowCkMcode()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
BYTE msgtype=0;
int i=0, j=0, k=0;
msgtype = g_TempMsg.msg.MSGFormat;
if (Button_GetCheck(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CK_MCODE))==BST_UNCHECKED)
{
k = ::OwnSubAddr(cmd1);
if ((k==0)||(k==31))
{
cmd1 = ::SetSubAddr(cmd1, 1); // change sub addr
this->SetSubAddr(1, 0);
}
else
{
cmd1 = ::SetSubAddr(cmd1, k); // change sub addr
this->SetSubAddr(1, 0);
}
j = ::OwnWordCount(cmd1);
if (j==0)
{
for (i=0; i<32; i++)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), TRUE);
}
}
else
{
for (i=0; i<32; i++)
{
if (i<j)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), TRUE);
}
else
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), FALSE);
}
}
}
g_TempMsg.msg.MSGFormat = (g_TempMsg.msg.MSGFormat & (~FMSG_MC));
}
else
{
for (i=0; i<32; i++)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), FALSE);
}
cmd1 = ::SetSubAddr(cmd1, 31);
this->SetSubAddr(31, 0);
j = ::OwnModeCode(cmd1); // retrieve mode code
if (::OwnTR(cmd1)==0)
{
switch (j)
{
// no data | broadcast | mode code
//case 0: // dync bus control
case 1: // sync (no data)
//case 2: // transmit last status word (no data)
case 3: // initialize self-test
case 4: // transmit shut-down
case 5: // override shut-down
case 6: // inhibit terminal flag bits
case 7: // override inhibit terminal flag bits
case 8: // reset terminal
break;
// with data | broadcast | mode code
//case 16: // transmit vector word
case 17: // sync (with data)
//case 18: // transmit last command word (with data)
//case 19: // transmit sefl-test word
case 20: // selected transmitor shut-down
case 21: // inhibit selected transmitor shut-down
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0), TRUE);
break;
default: // reserved
break;
}
}
g_TempMsg.msg.MSGFormat = (g_TempMsg.msg.MSGFormat | FMSG_MC);
}
if ((msgtype&FMSG_RT_RT) == FMSG_RT_RT) // RT-RT
{
for (j=0; j<32; j++)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+j), FALSE);
}
}
this->SetCmdWord(cmd1, 0);
}
void CMsgShowDlg::SetSubAddr(short val, unsigned char id)
{
if (id==0)
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_SAADDR0), val);
}
else
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_SAADDR1), val);
}
}
void CMsgShowDlg::OnMshowCkRtrt()
{
// TODO: Add your control notification handler code here
BYTE msgtype=0;
int i=0, j=0;
msgtype = g_TempMsg.msg.MSGFormat;
if (Button_GetCheck(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CK_RTRT))==BST_UNCHECKED)
{
if ((msgtype&FMSG_MC) == FMSG_MC) // Mode Code
{
for (i=0; i<32; i++)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), FALSE);
}
j = ::OwnModeCode(cmd1); // retrieve mode code
if ((msgtype&FMSG_BRDCST) == FMSG_BRDCST) // broadcast | with data
{
switch (j)
{
// no data | broadcast | mode code
//case 0: // dync bus control
//case 1: // sync (no data)
//case 2: // transmit last status word (no data)
//case 3: // initialize self-test
//case 4: // transmit shut-down
//case 5: // override shut-down
//case 6: // inhibit terminal flag bits
//case 7: // override inhibit terminal flag bits
//case 8: // reset terminal
// break;
// with data | broadcast | mode code
//case 16: // transmit vector word
case 17: // sync (with data)
//case 18: // transmit last command word (with data)
//case 19: // transmit sefl-test word
case 20: // selected transmitor shut-down
case 21: // inhibit selected transmitor shut-down
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0), TRUE);
break;
default: // reserved
break;
}
}
else // un broadcast
{
switch (j)
{
// no data | mode code
//case 0: // dync bus control
//case 1: // sync (no data)
//case 2: // transmit last status word (no data)
//case 3: // initialize self-test
//case 4: // transmit shut-down
//case 5: // override shut-down
//case 6: // inhibit terminal flag bits
//case 7: // override inhibit terminal flag bits
//case 8: // reset terminal
// break;
// with data | mode code
//case 16: // transmit vector word
case 17: // sync (with data)
case 18: // transmit last command word (with data)
//case 19: // transmit sefl-test word
case 20: // selected transmitor shut-down
case 21: // inhibit selected transmitor shut-down
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0), TRUE);
break;
default: // reserved
break;
}
}
}
else // Broadcast or BC-RT
{
if (::OwnTR(cmd1)==0) // RT is R
{
j = ::OwnWordCount(cmd1);
for (i=0; i<32; i++)
{
if (i<j)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), TRUE);
}
else
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), FALSE);
}
}
}
else
{
for (i=0; i<32; i++)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), TRUE);
}
}
}
g_TempMsg.msg.MSGFormat = (g_TempMsg.msg.MSGFormat & (~FMSG_RT_RT));
this->SetRT2Visible(FALSE); // RT2
}
else
{
if (cmd2==0) // pre don't have cmd2
{
cmd2 = ::SetRTAddr(cmd2, 2);
cmd2 = ::SetTR(cmd2, 1);
cmd2 = ::SetSubAddr(cmd2, 1);
cmd2 = ::SetWordCount(cmd2, 1);
// RT2
this->SetRTAddr(::OwnRTAddr(cmd2), 1);
this->SetTR(::OwnTR(cmd2), 1); // T/R
this->SetSubAddr(::OwnSubAddr(cmd2), 1); // Sub Addr
this->SetWordCount(::OwnWordCount(cmd2), 1); // Word Count
}
else // pre have cmd2
{
// RT2
this->SetRTAddr(::OwnRTAddr(cmd2), 1);
this->SetTR(::OwnTR(cmd2), 1); // T/R
this->SetSubAddr(::OwnSubAddr(cmd2), 1);
this->SetWordCount(::OwnWordCount(cmd2), 1);
}
g_TempMsg.msg.MSGFormat = (g_TempMsg.msg.MSGFormat | FMSG_RT_RT);
this->SetCmdWord(cmd2, 1);
for (i=0; i<32; i++)
{
::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_MSHOW_ED_DATA0+i), FALSE);
}
this->SetRT2Visible(TRUE); // RT2
}
}
void CMsgShowDlg::SetTR(short val, unsigned char id)
{
if (id==0)
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_RORT0), val);
}
else
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_RORT1), val);
}
}
void CMsgShowDlg::SetWordCount(short val, unsigned char id)
{
if (id==0)
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_DCNT0), val);
}
else
{
ComboBox_SetCurSel(::GetDlgItem(this->m_hWnd, IDC_MSHOW_CB_DCNT1), val);
}
}
void CMsgShowDlg::OnSelchangeMshowCbDcnt0()
{
// TODO: Add your control notification handler code here
short i=0, j=0, k=0;
WORD msgtype=0;
msgtype = g_TempMsg.msg.MSGFormat;
i = this->GetWordCount(0);
cmd1 = ::SetWordCount(cmd1, i);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?