📄 msgattributechange.cpp
字号:
}
}
}
if(msgformat.CompareNoCase(CString("NULL"))) // if msgformat is null
{
ptrOutGoingMsgList= cmessagemanager.m_pFormatList;
CFormat* FmtPtr;
if(ptrOutGoingMsgList->GetCount())
{
for(POSITION pos = ptrOutGoingMsgList->GetHeadPosition();pos!= NULL;)
{
FmtPtr = (CFormat *) (ptrOutGoingMsgList->GetNext (pos));
CString name = FmtPtr->GetName();
if(!msgformat.CompareNoCase(name))
{
datalist = FmtPtr->GetDataList();
if(!(FmtPtr->GetInputMode().CompareNoCase(CString("Dialog"))))
{
DiDialog.SetCheck(1);
DiDataset.SetCheck(0);
}
else
{
DiDialog.SetCheck(0);
DiDataset.SetCheck(1);
}
break;
}
}
}
CData dataobj;
CString datalistname = datalist.GetName();
CList <CData,CData&>& dataset = datalist.GetData();
CList <CVar,CVar&>& varlist = FmtPtr->GetVarList();
if(dataset.GetCount() > 0 && varlist.GetCount() > 0)
{
CmbDataSet.ResetContent();
for(POSITION pos = dataset.GetHeadPosition();pos!= NULL;)
{
dataobj = dataset.GetNext(pos);
CmbDataSet.AddString(dataobj.GetName());
if(!(datalist.GetDefault().CompareNoCase(dataobj.GetName())))
{
if(dataobj.GetFrequency()>0 && dataobj.GetTimer()>0)
{
mFreq.SetCurSel(dataobj.GetFrequency()-1);
mTimer.SetCurSel(dataobj.GetTimer()-1);
}
if(dataobj.GetFrequency()>1) // Just to implement the logic freq >1, only then timer will be activatd
{
mTimer.EnableWindow(1);
}
else
{
mTimer.EnableWindow(0);
}
}
}
}
CmbDataSet.SetCurSel(GetDataSetComboIndexForItem(datalist.GetDefault()));
}
else
{
CmbDataSet.SetWindowText(CString("Plugin"));
DiDialog.SetCheck(0);
DiDataset.SetCheck(0);
mFreq.SetWindowText(_T(""));
mTimer.SetWindowText(_T(""));
DiDialog.EnableWindow(0);
DiDataset.EnableWindow(0);
CmbDataSet.EnableWindow(0);
mFreq.EnableWindow(0);
mTimer.EnableWindow(0);
}
free(dummy);
}
void MsgAttributeChange::OnClose()
{
CDialog::OnClose();
}
void MsgAttributeChange::OnOK()
{
}
void MsgAttributeChange::OnBnClickedButtonSrhMsgId()
{
MessageSearch ms;
ms.SetTheLibraryIdentifier(library_identifier);
ms.DoModal ();
}
/***********************************************************************************/
void MsgAttributeChange::OnBnClickedCancel()
{
OnCancel();
}
/***********************************************************************************/
void MsgAttributeChange::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
if (lpwndpos->cx == -1)
if (lpwndpos->cy == -1) // is init time
{
lpwndpos->x = 257; // change here if you want to move left or right the window.
lpwndpos->y = 41; // change here if you want to move top or bottom the window.
CDialog::OnWindowPosChanging(lpwndpos);
}
}
/***********************************************************************************/
void MsgAttributeChange::OnBnClickedButtonAddDataset()
{
// TODO: Add your control notification handler code here
CString stringID_to_string;
CAddEditDialog clsAddEdit;
clsAddEdit.SetLibraryIdentifier(library_identifier);
CmbMsgId.GetWindowText(stringID_to_string);
clsAddEdit.SetValueOfMsgId(_ttoi(stringID_to_string));
clsAddEdit.Is_Coming_From = CHANGEATTRIB;
clsAddEdit.DoModal();
}
/***********************************************************************************/
void MsgAttributeChange::OnCbnSelchangeComboDefaultDataSet()
{
CString sMsgId, msgformat,sDataset;
CmbMsgId.GetLBText(CmbMsgId.GetCurSel(),sMsgId);
CPtrList * ptrOutGoingMsgList= cmessagemanager.m_plstOutGoingMsg;
COutgoingMessage * ptrOutGoingMsg;
char *dummy = (char*) malloc(sizeof(char)*10);
UINT32 messageid = _ttoi(sMsgId);
if(ptrOutGoingMsgList->GetCount())
{
for(POSITION pos = ptrOutGoingMsgList->GetHeadPosition();pos!= NULL;)
{
ptrOutGoingMsg = (COutgoingMessage *) (ptrOutGoingMsgList->GetNext (pos));
if(ptrOutGoingMsg->GetMessageId()== messageid)
{
msgformat = ptrOutGoingMsg->GetFormat();
}
}
}
ptrOutGoingMsgList= cmessagemanager.m_pFormatList;
CFormat* FmtPtr;
CDataList datalist;
if(ptrOutGoingMsgList->GetCount())
{
for(POSITION pos = ptrOutGoingMsgList->GetHeadPosition();pos!= NULL;)
{
FmtPtr = (CFormat *) (ptrOutGoingMsgList->GetNext (pos));
CString name = FmtPtr->GetName();
if(!msgformat.CompareNoCase(name))
{
datalist = FmtPtr->GetDataList();
break;
}
}
}
CData dataobj;
CString datalistname = datalist.GetName();
CList <CData,CData&>& dataset = datalist.GetData();
CList <CVar,CVar&>& varlist = FmtPtr->GetVarList();
if(dataset.GetCount() > 0 && varlist.GetCount() > 0)
{
for(POSITION pos = dataset.GetHeadPosition();pos!= NULL;)
{
dataobj = dataset.GetNext(pos);
CmbDataSet.GetLBText(CmbDataSet.GetCurSel(),sDataset);
if(!((dataobj.GetName()).CompareNoCase(sDataset)))
{
if(dataobj.GetFrequency()>0 && dataobj.GetTimer()>0)
{
mFreq.SetCurSel(dataobj.GetFrequency()-1);
mTimer.SetCurSel(dataobj.GetTimer()-1);
}
if(dataobj.GetFrequency()>1) // Just to implement the logic freq >1, only then timer will be activatd
{
mTimer.EnableWindow(1);
}
else
{
mTimer.EnableWindow(0);
}
}
}
}
button_save.EnableWindow(1);
free(dummy);
}
//////////////////////////////////////////////////////////////////////////////////////
void MsgAttributeChange::InitFrequencyTimerCombo()
{
int counter;
char *dummy = (char*) malloc(sizeof(char)*10);
for(counter=1;counter<=100;counter++)
{
mTimer.AddString(CString(CString(itoa(counter,dummy,10))));
mFreq.AddString(CString(CString(itoa(counter,dummy,10))));
}
free(dummy);
}
/*********The handler for filling the dialog with the information it received from Search Dialog**********/
LRESULT MsgAttributeChange::SetValuesInDialog(WPARAM MsgId,LPARAM Unused)
{
CPtrList * ptr_to_outgoing_msg_list = cmessagemanager.m_plstOutGoingMsg;
COutgoingMessage * ptr_to_outgoing_msg;
char *dummy = (char*) malloc(sizeof(char)*10);
if(ptr_to_outgoing_msg_list)
{
if(ptr_to_outgoing_msg_list->GetCount())
{
for(POSITION pos = ptr_to_outgoing_msg_list->GetHeadPosition();pos!= NULL;)
{
ptr_to_outgoing_msg = (COutgoingMessage *) (ptr_to_outgoing_msg_list->GetNext (pos));
if(ptr_to_outgoing_msg->GetMessageId() == MsgId)
{
CPtrList *applst_ptr;
CApplication *App_ptr;
applst_ptr = cmessagemanager.m_pAppList;
if(applst_ptr)
{
if(applst_ptr->GetCount())
{
for(POSITION pos = applst_ptr->GetHeadPosition();pos!= NULL;)
{
App_ptr = (CApplication *) (applst_ptr->GetNext (pos));
if(App_ptr->GetAppId()==ptr_to_outgoing_msg->GetAppId())
{
int appidIndex,cmbmsgidIndex;
CString AppIdElement,CmbMsgIdElement;
// set appropriate combo box value as active one
for(appidIndex=0;appidIndex<=AppId.GetCount();appidIndex++)
{
AppId.GetLBText(appidIndex,AppIdElement);
if(!AppIdElement.CompareNoCase(CString(itoa(App_ptr->GetAppId(),dummy,10))+":"+ App_ptr->GetApplicationName()))
{
break;
}
}
AppId.SetCurSel(appidIndex);
OnCbnSelendokComboAppid();
for(cmbmsgidIndex=0;cmbmsgidIndex<=CmbMsgId.GetCount();cmbmsgidIndex++)
{
CmbMsgId.GetLBText(cmbmsgidIndex,CmbMsgIdElement);
if(!CmbMsgIdElement.CompareNoCase(CString(itoa(ptr_to_outgoing_msg->GetMessageId(),dummy,10))+":"+ ptr_to_outgoing_msg->GetMessageName()))
{
break;
}
}
CmbMsgId.SetCurSel(cmbmsgidIndex);
OnCbnSelendokComboMsgid();
}
}
}
}
}
}
}
}
CmbMsgId.SetFocus();
free(dummy);
return 1;
}void MsgAttributeChange::OnCbnSelchangeComboFreq()
{
CString freqcmbwindowtext;
mFreq.GetLBText(mFreq.GetCurSel(),freqcmbwindowtext);
if(!(CString("1").CompareNoCase(freqcmbwindowtext)))
mTimer.EnableWindow(0);
else
mTimer.EnableWindow(1);
button_save.EnableWindow(1);
}
int MsgAttributeChange::GetDataSetComboIndexForItem(CString strComboItem)
{
int cmbIndex;
CString CmbElement;
for(cmbIndex=0;cmbIndex<=CmbDataSet.GetCount();cmbIndex++)
{
CmbDataSet.GetLBText(cmbIndex,CmbElement);
if(!CmbElement.CompareNoCase(strComboItem))
{
return cmbIndex;
}
}
}
void MsgAttributeChange::OnBnClickedRadioDialog()
{
button_save.EnableWindow(1);
}
void MsgAttributeChange::OnBnClickedRadioDataset()
{
button_save.EnableWindow(1);
}
void MsgAttributeChange::OnCbnSelchangeComboTimer()
{
button_save.EnableWindow(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -