Ejemplo n.º 1
0
LONG CuEditableListCtrlCommentInsertValue::OnEditDlgOK (UINT wParam, LONG lParam)
{
	int iItem, iSubItem;
	CString s = EDIT_GetText();
	EDIT_GetEditItem(iItem, iSubItem);
	if (iItem < 0)
	{
		SetFocus();
		return 0L;
	}
	try
	{
		SetItemText (iItem, iSubItem, s);
		GetParent()->SendMessage (WM_LAYOUTEDITDLG_OK, (WPARAM)(LPCTSTR)m_EditDlgOriginalText, (LPARAM)(LPCTSTR)s);
	}
	catch (...)
	{
		//CString strMsg = _T("Cannot change edit text.");
		AfxMessageBox (IDS_E_CHANGE_EDIT);
	}

	SetFocus();
	return 0L;

}
Ejemplo n.º 2
0
LONG CuEditableListCtrlGeneric::OnEditDlgOK (UINT wParam, LONG lParam)
{
	int iItem, iSubItem;
	CString s = EDIT_GetText();
	EDIT_GetEditItem(iItem, iSubItem);
	if (iItem < 0)
		return 0L;

	try
	{
		GENERICLINEINFO* pData = (GENERICLINEINFO*)GetItemData (iItem);
		if (pData)
		{
			CString strOldName = pData->szname;
			if (GetGenericForCache())
			{
				//
				// Special care of cache management.
				VCBFllCachePaneOnEdit (pData, (LPTSTR)(LPCTSTR)s);
			}
			else
			{
				VCBFllGenPaneOnEdit(pData, (LPTSTR)(LPCTSTR)s);
			}
			ASSERT (strOldName == pData->szname);
			VCBF_GenericSetItem (this, pData, iItem);
		}
	}
	catch (CeVcbfException e)
	{
		//
		// Catch critical error 
		TRACE1 ("CuEditableListCtrlGeneric::OnEditDlgOK has caught exception: %s\n", e.m_strReason);
		CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
		pMain->CloseApplication (FALSE);
	}
	catch (CMemoryException* e)
	{
		VCBF_OutOfMemoryMessage ();
		e->Delete();
	}
	catch (...)
	{
		TRACE0 ("Other error occured ...\n");
	}
	return 0L;
}
Ejemplo n.º 3
0
LONG CuEditableListCtrlGenericDerived::OnEditDlgOK (UINT wParam, LONG lParam)
{
	int iItem, iSubItem;
	CString s = EDIT_GetText();
	EDIT_GetEditItem(iItem, iSubItem);
	if (iItem < 0)
		return 0L;

	try
	{
		DERIVEDLINEINFO* pData = (DERIVEDLINEINFO*)GetItemData (iItem);
		if (pData)
		{
			CString strOldName = pData->szname;
		
			BOOL bOk = VCBBllOnEditDependent(pData, (LPTSTR)(LPCTSTR)s);
			ASSERT (strOldName == pData->szname);
			VCBF_GenericDerivedAddItem (this, (LPCTSTR)strOldName, GetGenericForCache());
		}
	}
	catch (CeVcbfException e)
	{
		//
		// Catch critical error 
		TRACE1 ("CuEditableListCtrlGenericDerived::OnEditDlgOK has caught exception: %s\n", e.m_strReason);
		CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
		pMain->CloseApplication (FALSE);
	}
	catch (CMemoryException* e)
	{
		VCBF_OutOfMemoryMessage ();
		e->Delete();
	}
	catch (...)
	{
		TRACE0 ("Other error occured ...\n");
	}
	return 0L;
}
Ejemplo n.º 4
0
LONG CuEditableListCtrlComponent::OnEditDlgOK (UINT wParam, LONG lParam)
{
	int iItem, iSubItem;
	CString s = EDIT_GetText();
	EDIT_GetEditItem(iItem, iSubItem);
	if (iItem < 0) {
	  MessageBeep(MB_ICONEXCLAMATION);
			return 0L;
	}
	
	// optimization: if text not changed or if text empty, behave as if cancelled
	if (s.IsEmpty())
	  return 0L;
	if (s == m_EditDlgOriginalText)
	  return 0L;

  // Emb Oct 22, 97: don't accept underscore in name
  if (s.Find(_T('_')) != -1) {
    AfxMessageBox(IDS_ERR_UNDERSCORE);
  	SetItemText (iItem, iSubItem, m_EditDlgOriginalText);
    return 0L;    // As if not changed
  }

  // Emb Oct 22, 97: must check whether another item has the same name
  int count = GetItemCount();
  CuCbfListViewItem* pCurItemData = (CuCbfListViewItem*)GetItemData(iItem);
	LPCOMPONENTINFO lpCurComponentInfo = &pCurItemData->m_componentInfo;
  for (int cpt = 0; cpt < count; cpt++) {
    // exclude current item
    if (cpt == iItem)
      continue;

    // get component info of item
    CuCbfListViewItem* pItem = (CuCbfListViewItem*)GetItemData(cpt);
	  LPCOMPONENTINFO lpItemInfo = &pItem->m_componentInfo;

    // compare types
    if (lpItemInfo->itype != lpCurComponentInfo->itype)
      continue;

    // compare names - INSENSIVIVE
    if (s.CompareNoCase((LPCTSTR)lpItemInfo->szname) != 0)
      continue;

    // same type and name : denied
    AfxMessageBox(IDS_ERR_DUPLICATE_NAME);
  	SetItemText (iItem, iSubItem, m_EditDlgOriginalText);
    return 0L;    // As if not changed
  }

	// Emb Sept 25, 97: preliminary test at low level side
	CuCbfListViewItem* pItemData = (CuCbfListViewItem*)GetItemData(iItem);
	LPCOMPONENTINFO lpComponentInfo = &pItemData->m_componentInfo;
	AfxGetApp()->DoWaitCursor(1);
	try
	{
		BOOL bSuccess = VCBFllValidRename(lpComponentInfo, (LPTSTR)(LPCTSTR)s);
		AfxGetApp()->DoWaitCursor(-1);
		if (!bSuccess)
			MessageBeep(MB_ICONEXCLAMATION);
	}
	catch (CeVcbfException e)
	{
		//
		// Catch critical error 
		TRACE1 ("CuEditableListCtrlComponent::OnEditDlgOK has caught exception: %s\n", e.m_strReason);
		CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
		pMain->CloseApplication (FALSE);
	}
	catch (CMemoryException* e)
	{
		VCBF_OutOfMemoryMessage ();
		e->Delete();
	}
	catch (...)
	{
		TRACE0 ("Other error occured ...\n");
	}
	// always display text as returned in the structure by VCBFllValidRename()
	SetItemText (iItem, iSubItem, (LPCTSTR)lpComponentInfo->szname);

	return 0L;
}