📄 addeditdialog.cpp
字号:
void CAddEditDialog::Prepare3rdColumnForNewDataSet()
{
NewDataSetNameEdit.ShowWindow(SW_SHOW);
NewDataSetDescrEdit.ShowWindow(SW_SHOW);
NewDataSetNameEdit.SetWindowText(_T(""));
NewDataSetDescrEdit.SetWindowText(_T(""));
static_new_ds_descr.ShowWindow(SW_SHOW);
static_new_ds_name.ShowWindow(SW_SHOW);
static_new_ds_desrc.ShowWindow(SW_SHOW);
NewDataSetNameEdit.SetFocus();
int datawindow_item_cnt = datawindow.GetItemCount();
for(int item_no=0;item_no<datawindow_item_cnt;item_no++)
{
datawindow.SetItemText(item_no,3,_T(""));
}
DSIdCombo.SetCurSel(-1);
DataSetFreqCombo.SetCurSel(0);
DataSetTimerCombo.SetCurSel(0);
//for the controls which were disabled in case of no datasets....
DataSetFreqCombo.EnableWindow(1);
DataSetTimerCombo.EnableWindow(0);
datawindow.EnableWindow(1);
edit_sel_ds_descr.SetWindowText(_T(""));
}
BOOL CAddEditDialog::PreTranslateMessage(MSG * pMsg)
{
int numkey;
if(pMsg->message == WM_KEYDOWN)
{
//48 is the key code for 1 and 57 is for 9
numkey = (pMsg->wParam >= 48 &&pMsg->wParam <= 57) || (pMsg->wParam >= VK_NUMPAD0 &&pMsg->wParam <= VK_NUMPAD9);
if(pMsg->wParam == VK_DOWN ||pMsg->wParam == VK_UP || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_RIGHT || numkey)
{
CWnd* wnd_under_focus = GetFocus();
//CWnd * parent_of_wnd_under_focus = GetFocus()->GetParent();
//done by PANKAJ on 8.12.2004.....as the dropdown should be called only when we have focus on one of the three combo boxes....
if((wnd_under_focus == &MsgIdCombo) || (wnd_under_focus == &AppIdCombo) || (wnd_under_focus == &DSIdCombo))
{
return (DropDown());
}
}
else if(pMsg->wParam == VK_ESCAPE)
{
OnBnClickedButtonCancelPan();
return 1;
}
else if(pMsg->wParam == VK_RETURN)
{
CWnd* wnd_under_focus = GetFocus();
if((wnd_under_focus == &SaveButton) || (wnd_under_focus == &SaveSendButton)|| (wnd_under_focus == &SearchMessage_button)|| (wnd_under_focus == &SendButton)|| (wnd_under_focus == &NewDataSetButton)|| (wnd_under_focus == &close_button))
return CDialog::PreTranslateMessage(pMsg);
else
return 1;
}
else
return CDialog::PreTranslateMessage(pMsg);
}
return CDialog::PreTranslateMessage(pMsg);
}
void CAddEditDialog::OnBnClickedChgAttrib()
{
CString string_for_window_text;
MsgIdCombo.GetWindowText(string_for_window_text);
MsgAttributeChange clsAttrib;
clsAttrib.SetMsgId(_ttoi(string_for_window_text));
clsAttrib.SetLibraryIdentifier(library_identifier);
if(!NewDataSetNameEdit.IsWindowVisible())
{
if(has_been_edited)
{
if(IDYES == AfxMessageBox(IDS_STRING_EDITED_DATA_LOSS,MB_YESNO))
{
SetTheHasBeenEditedFlag(0);
clsAttrib.Is_Coming_From = ADDEDIT;
clsAttrib.DoModal();
}
}
else
{
clsAttrib.Is_Coming_From = ADDEDIT;
clsAttrib.DoModal();
}
}
else
{
if(!(CheckAndNotifyForNewDataSetAddition()))
{
clsAttrib.Is_Coming_From = ADDEDIT;
clsAttrib.DoModal();
}
}
}
void CAddEditDialog::OnBnClickedSearchbuttonPan()
{
// TODO: Add your control notification handler code here
MessageSearch search_dialog;
search_dialog.SetTheLibraryIdentifier(library_identifier);
if(set_msg_attrib_flag)
{
int response = AfxMessageBox(IDS_STRING_LOOSE_MSG_DATA,MB_YESNO);
if(response == IDYES)
{
SetTheHasBeenEditedFlag(0);
set_msg_attrib_flag = 0;
search_dialog.DoModal();
return;
}
else
return;
}
else
{
if(!DropDown())
search_dialog.DoModal();
return;
}
}
/*Routine for handling the close button on the dialog.....this routine looks at various
cases that can happen in case of user pressing the close button/escape key....*/
void CAddEditDialog::OnBnClickedButtonCancelPan()
{
if(set_msg_attrib_flag) //when msg attribs have been modified....
{
int response = AfxMessageBox(IDS_STRING_WANT_TO_SAVE_CHANGES,MB_YESNOCANCEL);
if(response == IDYES)
{
int response_from_save = SaveWhileClosingDialog();
if(response_from_save) //if response is not 0...then close....
CDialog::OnCancel();
return;
}
else if(response == IDNO)
{
CDialog::OnCancel();
return;
}
else
return;
}
if(!NewDataSetNameEdit.IsWindowVisible())//when it's for old dataset
{
if(has_been_edited)//when it has been edited
{
int response = AfxMessageBox(IDS_STRING_WANT_TO_SAVE_CHANGES,MB_YESNOCANCEL);
if(response == IDYES)
{
int response_from_save = SaveWhileClosingDialog();
if(response_from_save) //if response is not 0...then close...
CDialog::OnCancel();
return;
}
else if(response == IDNO)
{
CDialog::OnCancel();
}
else
return;
}
else //if no editing has been done...then just close dialog.....
{
CDialog::OnCancel();
}
}
else //if it is new dataset case.....
{
if(NewDataSetNameEdit.GetWindowTextLength()||NewDataSetDescrEdit.GetWindowTextLength())
{ //if we have text in new dataset edit boxes....
int response = AfxMessageBox(IDS_STRING_WANT_TO_SAVE_CHANGES,MB_YESNOCANCEL);
if(response == IDNO)
{
CDialog::OnCancel();
}
else if(response == IDCANCEL)
{
return;
}
else
{
int response_from_save = SaveWhileClosingDialog();
if(response_from_save) //if response is not 0...then close...
CDialog::OnCancel();
}
}
else if (AreThereValuesInTheDataSet()) //if we have some values in listctrl....
{
int response = AfxMessageBox(IDS_STRING_WANT_TO_SAVE_CHANGES,MB_YESNOCANCEL);
if(response == IDNO)
{
CDialog::OnCancel();
}
else if(response == IDCANCEL)
{
return;
}
else
{
int response_from_save = SaveWhileClosingDialog();
if(response_from_save) //if response is not 0...then close...
CDialog::OnCancel();
}
}
else
{
CDialog::OnCancel();
}
}
}
void CAddEditDialog::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);
}
}
int CAddEditDialog::CheckAndNotifyForNewDataSetAddition()
{
if(NewDataSetNameEdit.IsWindowVisible())
{
if(NewDataSetNameEdit.GetWindowTextLength()||NewDataSetDescrEdit.GetWindowTextLength())
{
int response = AfxMessageBox(IDS_STRING_NOTIFY_LOSS_OF_DATA,MB_YESNO);
//return response;
if (response == IDYES)
{
NewDataSetNameEdit.ShowWindow(SW_HIDE);
NewDataSetDescrEdit.ShowWindow(SW_HIDE);
NewDataSetNameEdit.SetWindowText(_T(""));
NewDataSetDescrEdit.SetWindowText(_T(""));
static_new_ds_descr.ShowWindow(SW_HIDE);
static_new_ds_name.ShowWindow(SW_HIDE);
static_new_ds_desrc.ShowWindow(SW_HIDE);
int datawindow_item_cnt = datawindow.GetItemCount();
for(int i=0;i<datawindow_item_cnt;i++)
{
datawindow.SetItemText(i,3,_T(""));
}
SetTheHasBeenEditedFlag(0);
if(set_msg_attrib_flag)
{
SaveButton.EnableWindow(1);
SaveSendButton.EnableWindow(1);
}
return 0;
}
else
return 1;
}
else if (AreThereValuesInTheDataSet())
{
int response = AfxMessageBox(IDS_STRING_NOTIFY_LOSS_OF_DATA,MB_YESNO);
if (response == IDYES)
{
NewDataSetNameEdit.ShowWindow(SW_HIDE);
NewDataSetDescrEdit.ShowWindow(SW_HIDE);
NewDataSetNameEdit.SetWindowText(_T(""));
NewDataSetDescrEdit.SetWindowText(_T(""));
static_new_ds_descr.ShowWindow(SW_HIDE);
static_new_ds_name.ShowWindow(SW_HIDE);
static_new_ds_desrc.ShowWindow(SW_HIDE);
int datawindow_item_cnt = datawindow.GetItemCount();
for(int item_no=0;item_no<datawindow_item_cnt;item_no++)
{
datawindow.SetItemText(item_no,2,_T(""));
}
SetTheHasBeenEditedFlag(0);
if(set_msg_attrib_flag)
{
SaveButton.EnableWindow(1);
SaveSendButton.EnableWindow(1);
}
return 0;
}
else
return 1;
}
else
{
SetTheHasBeenEditedFlag(0);
if(set_msg_attrib_flag)
{
SaveButton.EnableWindow(1);
SaveSendButton.EnableWindow(1);
}
return 0;
}
}
else
return 0;
}
int CAddEditDialog::DropDownForMsgOrAppCombo()
{
if(set_msg_attrib_flag)
{
int response = AfxMessageBox(IDS_STRING_LOOSE_MSG_DATA,MB_YESNO);
if(response == IDNO)
{
PostMessage(WM_SETTINGFOCUS,0,0);
return 1;
}
else
{
set_msg_attrib_flag = 0; //since it is for loose data option....
SetTheHasBeenEditedFlag(0);
//hide the new dataset controls...bcos if they remain open...they cause confusion and
//leave the dialog in an inconsistent state...
NewDataSetNameEdit.ShowWindow(SW_HIDE);
NewDataSetDescrEdit.ShowWindow(SW_HIDE);
static_new_ds_descr.ShowWindow(SW_HIDE);
static_new_ds_name.ShowWindow(SW_HIDE);
static_new_ds_desrc.ShowWindow(SW_HIDE);
int datawindow_item_cnt = datawindow.GetItemCount();
for(int i=0;i<datawindow_item_cnt;i++)
{
datawindow.SetItemText(i,3,_T(""));
}
return 0;
}
}
else
{
return(DropDown());
}
}
void CAddEditDialog::OnCbnDropdownDscomboPan()
{
DropDown();
// TODO: Add your control notification handler code here
}
LRESULT CAddEditDialog::FocusSettingRoutine(WPARAM a,LPARAM b)
{
datawindow.SetFocus();
return 1;
}
int CAddEditDialog::DropDown()
{
if(!NewDataSetNameEdit.IsWindowVisible())
{
if(has_been_edited)
{
if(IDNO == AfxMessageBox(IDS_STRING_EDITED_DATA_LOSS,MB_YESNO))
{
PostMessage(WM_SETTINGFOCUS,0,0);
return 1;
}
else
{
SetTheHasBeenEditedFlag(0);
if(set_msg_attrib_flag)
{
SaveButton.EnableWindow(1);
SaveSendButton.EnableWindow(1);
}
return 0;
}
}
return 0;
}
else
{
if(CheckAndNotifyForNewDataSetAddition())
{
PostMessage(WM_SETTINGFOCUS,0,0);
return 1;
}
else
{
NewDataSetNameEdit.ShowWindow(SW_HIDE);
NewDataSetDescrEdit.ShowWindow(SW_HIDE);
static_new_ds_descr.ShowWindow(SW_HIDE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -