void CMacroDlg::OnOpenFile() { int nResult; HRESULT hResult; CString strFilter; LOAD_STRING_FROM_RESOURCE(strFilter, IDS_SCRIPT_FILES); CFileDialog dlg( TRUE, _T( "dsm" ), NULL, OFN_HIDEREADONLY| OFN_OVERWRITEPROMPT, strFilter ); nResult = (int)dlg.DoModal(); if( nResult != IDOK ) { return; } hResult = m_pScriptManager->LoadScript( dlg.GetPathName(), dlg.GetFileTitle() ); if( FAILED( hResult ) ) { CString strErrorMessage; _com_error error( hResult ); AfxFormatString2( strErrorMessage, IDS_ERRORLOADINGSCRIPT, dlg.GetFileTitle(), error.ErrorMessage() ); AfxMessageBox( strErrorMessage ); return; } UpdateMacroList(); }
BOOL CPropertyBagDlg::OnInitDialog() { POSITION posItem; CPropertyBagItem* pItem; int iItem; int iLVItem; COleVariant varString; CString strColumnTitle; CString str; CDialog::OnInitDialog(); // Add the appropriate columns to the parameter list control. LOAD_STRING_FROM_RESOURCE(strColumnTitle, IDS_PROPERTY); m_lvProperties.InsertColumn( 0, strColumnTitle, LVCFMT_LEFT, 100 ); LOAD_STRING_FROM_RESOURCE(strColumnTitle, IDS_VALUE); m_lvProperties.InsertColumn( 1, strColumnTitle, LVCFMT_LEFT, 100 ); LOAD_STRING_FROM_RESOURCE(strColumnTitle, IDS_TYPE); m_lvProperties.InsertColumn( 2, strColumnTitle, LVCFMT_LEFT, 100 ); iItem = 0; posItem = m_pPropertyBag->GetFirstItemPosition(); while( posItem != NULL ) { pItem = m_pPropertyBag->GetNextItem( posItem ); iLVItem = m_lvProperties.InsertItem( iItem, pItem->m_strName ); m_lvProperties.SetItemText( iLVItem, 0, pItem->m_strName ); TRY { varString.ChangeType( VT_BSTR, pItem->m_varValue ); str = varString.bstrVal; } CATCH( COleException, e ) { LOAD_STRING_FROM_RESOURCE(str, IDS_UNABLETOREPRESENT); } END_CATCH m_lvProperties.SetItemText( iLVItem, 1, str ); m_lvProperties.SetItemText( iLVItem, 2, VTToString( pItem->m_varValue.vt ) ); iItem++; }
BOOL CRegisterControlsDlg::OnInitDialog() { CWaitCursor wait; CString strColumnTitle; CDialog::OnInitDialog(); LOAD_STRING_FROM_RESOURCE(strColumnTitle, IDS_PROGID); m_lvRegisteredControls.InsertColumn( 0, strColumnTitle, LVCFMT_LEFT, 200 ); LOAD_STRING_FROM_RESOURCE(strColumnTitle, IDS_PATH); m_lvRegisteredControls.InsertColumn( 1, strColumnTitle, LVCFMT_LEFT, 250 ); RefreshRegisteredControls(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void GetClassServerPath( REFCLSID clsid, CString& strServerPath ) { HKEY hKey; HKEY hServerKey; OLECHAR szCLSID[64]; LONG nResult; ULONG nBytes; DWORD dwType; LPTSTR pszServerPath; StringFromGUID2( clsid, szCLSID, 64 ); hKey = NULL; hServerKey = NULL; try { nResult = RegOpenKeyEx( HKEY_CLASSES_ROOT, CString( "CLSID\\" )+CString( szCLSID ), 0, KEY_READ, &hKey ); if( nResult != ERROR_SUCCESS ) { throw( E_FAIL ); } nResult = RegOpenKeyEx( hKey, _T( "InprocServer32" ), 0, KEY_READ, &hServerKey ); if( nResult != ERROR_SUCCESS ) { nResult = RegOpenKeyEx( hKey, _T( "InprocHandler32" ), 0, KEY_READ, &hServerKey ); if( nResult != ERROR_SUCCESS ) { nResult = RegOpenKeyEx( hKey, _T( "LocalServer32" ), 0, KEY_READ, &hServerKey ); if( nResult != ERROR_SUCCESS ) { throw( E_FAIL ); } } } nBytes = 0; nResult = RegQueryValueEx( hServerKey, NULL, NULL, &dwType, NULL, &nBytes ); if( (nResult != ERROR_SUCCESS) || (dwType != REG_SZ) ) { throw( E_FAIL ); } pszServerPath = LPTSTR( _alloca( nBytes ) ); nResult = RegQueryValueEx( hServerKey, NULL, NULL, &dwType, LPBYTE( pszServerPath ), &nBytes ); if( (nResult != ERROR_SUCCESS) || (dwType != REG_SZ) ) { throw( E_FAIL ); } strServerPath = pszServerPath; RegCloseKey( hKey ); hKey = NULL; RegCloseKey( hServerKey ); hServerKey = NULL; } catch( HRESULT ) { if( hKey != NULL ) { RegCloseKey( hKey ); } if( hServerKey != NULL ) { RegCloseKey( hServerKey ); } LOAD_STRING_FROM_RESOURCE( strServerPath, IDS_SERVERNOTFOUND ); return; } }
BOOL CContainerInfoDlg::OnInitDialog() { POSITION posItem; CTestContainer98Item* pItem; int iItem; CString strItemName; CString strState; CString strObject; CString strWindowStatus; int nAutoWidth; int nAutoHeaderWidth; CDialog::OnInitDialog(); LOAD_STRING_FROM_RESOURCE( strObject, IDS_CONTAINERINFOOBJECTHEADER ); m_listObjects.InsertColumn( 0, strObject, LVCFMT_LEFT, 100 ); LOAD_STRING_FROM_RESOURCE( strState, IDS_CONTAINERINFOSTATEHEADER ); m_listObjects.InsertColumn( 1, strState, LVCFMT_LEFT, 100 ); LOAD_STRING_FROM_RESOURCE( strWindowStatus, IDS_CONTAINERINFOWINDOWHEADER ); m_listObjects.InsertColumn( 2, strWindowStatus, LVCFMT_LEFT, 100 ); iItem = 0; posItem = m_pDoc->GetStartPosition(); while( posItem != NULL ) { pItem = (CTestContainer98Item*)m_pDoc->GetNextItem( posItem ); strItemName = pItem->GetDisplayName(); m_listObjects.InsertItem( iItem, strItemName ); m_listObjects.SetItemText( iItem, 0, strItemName ); switch( pItem->GetItemState() ) { case COleClientItem::activeState: LOAD_STRING_FROM_RESOURCE( strState, IDS_ACTIVESTATE ); if( pItem->IsWindowless() ) { LOAD_STRING_FROM_RESOURCE( strWindowStatus, IDS_WINDOWLESS ); } else { LOAD_STRING_FROM_RESOURCE( strWindowStatus, IDS_WINDOWED ); } break; case COleClientItem::activeUIState: LOAD_STRING_FROM_RESOURCE( strState, IDS_UIACTIVESTATE ); if( pItem->IsWindowless() ) { LOAD_STRING_FROM_RESOURCE( strWindowStatus, IDS_WINDOWLESS ); } else { LOAD_STRING_FROM_RESOURCE( strWindowStatus, IDS_WINDOWED ); } break; case COleClientItem::openState: LOAD_STRING_FROM_RESOURCE( strState, IDS_OPENSTATE ); strWindowStatus.Empty(); break; case COleClientItem::loadedState: LOAD_STRING_FROM_RESOURCE( strState, IDS_LOADEDSTATE ); strWindowStatus.Empty(); break; case COleClientItem::emptyState: LOAD_STRING_FROM_RESOURCE( strState, IDS_EMPTYSTATE ); strWindowStatus.Empty(); break; default: ASSERT( FALSE ); break; } m_listObjects.SetItemText( iItem, 1, strState ); m_listObjects.SetItemText( iItem, 2, strWindowStatus ); iItem++; } m_listObjects.SetColumnWidth( 0, LVSCW_AUTOSIZE ); nAutoWidth = m_listObjects.GetColumnWidth( 0 ); m_listObjects.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER ); nAutoHeaderWidth = m_listObjects.GetColumnWidth( 0 ); m_listObjects.SetColumnWidth( 0, max( nAutoWidth, nAutoHeaderWidth ) ); m_listObjects.SetColumnWidth( 1, LVSCW_AUTOSIZE ); nAutoWidth = m_listObjects.GetColumnWidth( 1 ); m_listObjects.SetColumnWidth( 1, LVSCW_AUTOSIZE_USEHEADER ); nAutoHeaderWidth = m_listObjects.GetColumnWidth( 1 ); m_listObjects.SetColumnWidth( 1, max( nAutoWidth, nAutoHeaderWidth ) ); m_listObjects.SetColumnWidth( 2, LVSCW_AUTOSIZE ); nAutoWidth = m_listObjects.GetColumnWidth( 2 ); m_listObjects.SetColumnWidth( 2, LVSCW_AUTOSIZE_USEHEADER ); nAutoHeaderWidth = m_listObjects.GetColumnWidth( 2 ); m_listObjects.SetColumnWidth( 2, max( nAutoWidth, nAutoHeaderWidth ) ); return( TRUE ); }