void CDocStructRecordItem::OnEditChanged(XTP_REPORTRECORDITEM_ARGS* pItemArgs, LPCTSTR szText) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); UNREFERENCED_PARAMETER(pItemArgs); UNREFERENCED_PARAMETER(szText); CString csText(szText); if (csText.IsEmpty()) { csText = m_csInitialCaption; } SetCaption(csText); CDocStructRecord* pRecord = (CDocStructRecord*)GetRecord(); if (pRecord) { pRecord->m_pContainer->SetName(pRecord->m_pvData, csText); m_csInitialCaption = csText; pRecord->UpdateTooltip(); } int x = 0; }
void CNewComm::OnCreateButton() { // TRACE("CNewComm::OnCreateButton()\n"); ASSERT(m_pTemporaryICSO == NULL); // NAME must NOT exist as instrument or as a communications object //going to do a child dialog box so don't want //to time out until it returns KillTimer(1); char *at; while ((at = strpbrk(m_pName,INVALIDCHARS)) != NULL) at[0] = '-'; SetDlgItemText(IDC_COMMNAME_EDIT,m_pName); char temp[32]; //check if an instrument by this name already exists GetPrivateProfileString( INSTRUMENTS,m_pName,"NO_MATCH",temp,sizeof(temp)-1,g_szIniFile); if (strcmp(temp,"NO_MATCH")!=0) { CString csText("An Instrument object with this\nname already exists.\nSelect a different name."); new CTimedMessageDialog(m_csTitle, csText,g_iDlgCloseMillisec/1000, this); SetTimer(1,g_iDlgCloseMillisec,NULL); m_pCreateButton->EnableWindow(FALSE); return; } //check if a communications object by this name already exists GetPrivateProfileString( COMMUNICATIONS,m_pName,"NO_MATCH",temp,sizeof(temp)-1,g_szIniFile); if (strcmp(temp,"NO_MATCH")!=0) { CString csText("A Communications object with this\nname already exists.\nSelect a different name."); new CTimedMessageDialog(m_csTitle, csText,g_iDlgCloseMillisec/1000, this); SetTimer(1,g_iDlgCloseMillisec,NULL); m_pCreateButton->EnableWindow(FALSE); return; } GetDlgItemText(IDC_COMMNAME_EDIT,temp,31); if (temp[0] == ';') { CString csText("A \"Name\" for an instrument object cannot start with \";\"."); new CTimedMessageDialog(m_csTitle, csText,g_iDlgCloseMillisec/1000, this); SetTimer(1,g_iDlgCloseMillisec,NULL);; m_pCreateButton->EnableWindow(FALSE); return; } // Pick the class factory from the index out of the picklist. // Recall that some of the class factory pointers might be NULL. // Also establish the CLSID for this component type to put in the INI file later. IClassFactory *pFactory = NULL; CLSID this_CLSID; memset(&this_CLSID,0,sizeof(CLSID)); int j = -1; for (int i = 0; i < MAX_CLSIDS; i++) { if (m_pClassFactory[i] != NULL) j++; if (j == m_iSelectionIndex) { pFactory = m_pClassFactory[i]; memcpy(&this_CLSID, &m_CLSID[i], sizeof(CLSID)); break; } } //Instantiate a short-lived CSO component //and have it gather its own data from its own version of //CModParam. if (pFactory == NULL) return; HRESULT hr = pFactory->CreateInstance( NULL, IID_ICSO, (void **)&m_pTemporaryICSO); if ( FAILED(hr) || (m_pTemporaryICSO == NULL) ) return; //Tell it to collect its startup parameters //And put them in the INI file BSTR bstr; Convert_Character_String_to_BSTR(g_szIniFile, bstr); m_pTemporaryICSO->put_INIPathname(bstr); Convert_Character_String_to_BSTR(m_pName, bstr); m_pTemporaryICSO->put_Name(bstr); m_pTemporaryICSO->put_DialogAutoCloseTime((ULONG)(g_iDlgCloseMillisec/1000)); //Specific CSO writes its own data to the INI file. The content of this //data would vary according to the requirements of the CSO. //The IPX CSO will change the name. The output csCSONameOut is used to capture //that changed name. Other as-yet-to-be-defined CSO's may need to do the //same. If the name has not been changed, the CSO will leave the //csCSOName string unchanged. CString csNameOut("NONAME"); BSTR bstrNameOut; VARIANT_BOOL vbHaveNewCSO; WCHAR *pwide = NULL; char narrow[80]; m_pTemporaryICSO->CollectParametersForNewCSO(&bstrNameOut,&vbHaveNewCSO); if (vbHaveNewCSO == VARIANT_TRUE) { if (0 != SysStringLen(bstrNameOut)) { Convert_BSTR_to_CString(bstrNameOut, csNameOut); ::StringFromCLSID(this_CLSID,&pwide); ::wcstombs(narrow,pwide,sizeof(narrow)); CoTaskMemFree(pwide); pwide = NULL; } CValidate Valid(this); if (IDOK == Valid.DoModal()) { //put the new CSO's class id into the ini file WritePrivateProfileString(csNameOut,"CLSID",narrow,g_szIniFile); //send message to MICDlg with name of new CSO so MicMgrDlg can look in the INI file UINT ubytes = 1 + csNameOut.GetLength(); unsigned char *cobuffer = (unsigned char*)CoTaskMemAlloc((ULONG)ubytes); if (cobuffer != 0) { //Beep(100,500); memcpy(cobuffer,(void *)((LPCTSTR)csNameOut),(unsigned int)ubytes); ::PostMessage(AfxGetMainWnd()->m_hWnd,IDC_CREATE_COMM,WPARAM(ubytes),LPARAM(cobuffer)); } //Disable the create button since we have used the name //that is in the comm name edit box. m_pCreateButton->EnableWindow(FALSE); } else //validate failed { //remove the non-validated name from the INI file WritePrivateProfileString(COMMUNICATIONS,csNameOut,NULL,g_szIniFile); } } if (pwide != NULL) CoTaskMemFree(pwide); // destroy the temporary component CleanUpTemporaryICSO(); //restart the timeout timer SetTimer(1,g_iDlgCloseMillisec,NULL); //get rid of the ugly focus indicator on the Create button. GetDlgItem(IDOK)->SetFocus(); }