示例#1
0
void CGetFilenameControl::Edit(BOOL fShowDlg)
{
//bring up the common file open dialog to select the filename

//retreive the current filename to use as the initial value
CString sCurrentFilename;

	if (m_sDir.IsEmpty())
		GetWindowText(sCurrentFilename);
	else
		sCurrentFilename = m_sDir;

	if (fShowDlg || 0 == sCurrentFilename.GetLength()) {
	// work out the flags to use
	DWORD dwFlags = 0;
	BOOL fOpenFile = TRUE;

	  if (m_dwFlags & GF_HIDEREADONLY)
		dwFlags |= OFN_HIDEREADONLY;
	  if (m_dwFlags & GF_OVERWRITEPROMPT)
	    dwFlags |= OFN_OVERWRITEPROMPT;
	  if (m_dwFlags & GF_FILEMUSTEXIST)
	    dwFlags |= OFN_FILEMUSTEXIST;
	  if (m_dwFlags & GF_SAVEASDIALOG) {
		fOpenFile = FALSE;
		m_dwFlags |= OFN_NOREADONLYRETURN;
	  }
	  if (m_dwFlags & GF_MULTIPLESELECTION)
		dwFlags |= OFN_ALLOWMULTISELECT;

		if (IsWin40())
			dwFlags |= OFN_EXPLORER;
		else
			dwFlags |= OFN_LONGNAMES;

	#if defined(OFN_ENABLESIZING)
		if (IsWin41() || (IsWinNT() && IsWin50())) {		// Win98 oder WinNT50
			dwFlags |= OFN_ENABLESIZING;
	#if defined(OFN_DONTADDTORECENT)
			dwFlags |= OFN_DONTADDTORECENT;
	#endif // defined(OFN_DONTADDTORECENT)
		}
	#endif // OFN_ENABLESIZING

	CGetFileNameDialog dlg (fOpenFile, m_sDefExt, sCurrentFilename, dwFlags, m_sExtFilter, GetParent());

	  //Modify the title to the desired value
	  dlg.m_ofn.lpstrTitle = m_sTitle;
	  
	  //uncomment the following line if you want to use the old style file open common dialog
	  if (m_dwFlags & GF_OLD_STYLE_DIALOG)
	    dlg.m_ofn.Flags &= ~OFN_EXPLORER;

	// evtl. Verzeichnis voreinstellen
	  if (!m_sDir.IsEmpty())
		dlg.m_ofn.lpstrInitialDir = m_sDir;

	//bring up the dialog and if hit ok set the text in this control to the new filename
	  if (dlg.DoModal() == IDOK) {
	    SetWindowText (GetPathName (dlg));
		if (!(m_dwFlags & GF_HIDEREADONLY) && !(m_dwFlags & GF_SAVEASDIALOG)) {
			m_fReadOnly = (dlg.m_ofn.Flags & OFN_READONLY) ? TRUE: FALSE;

		// testen, ob die Datei evtl. schreibgeschützt ist
			if (!m_fReadOnly) {
			DWORD dwAttr = ::GetFileAttributes (GetPathName (dlg));

				if ((UINT)(-1) != dwAttr)
					m_fReadOnly = (dwAttr & FILE_ATTRIBUTE_READONLY) ? TRUE : FALSE;
			}
		}
		GetParent()->PostMessage (WM_FILESELECTED);
	  }
	} else {
		SetWindowText(sCurrentFilename);
		m_Files.insert(os_string(sCurrentFilename));
		GetParent()->PostMessage (WM_FILESELECTED);
	}
}
示例#2
0
// --------------------------------------------------------------------------------------------
// Toolbar für die Bildung von Konstruktionshilfslinien in TRiAS einhängen
HRESULT CGeoEditExtension::InstallDesignToolbar (void)
{
// Lizensierung testen
#if _TRiAS_VER < 0x0400
	if (0 != g_dwVer4) 
#endif // _TRiAS_VER < 0x0400
	{
	VERIFYLICENSE VL;

		INITSTRUCT(VL, VERIFYLICENSE);
		VL.iMode = VERIFYMODE_DontShowDialog|VERIFYMODE_LessOrEqual;
		VL.lLevelOrOption = CKILEVEL_PLUS;
		if (!DEX_VerifyLicenseLevel(VL))
			return E_FAIL;
	}

TBBUTTON *pBtnCopy = NULL;

	try {
	WTRiASBarContainer BarCont (m_pXtnSite);
	WTRiASBar Bar;
	ResString strCap (ResID (IDS_DESIGNTOOLCAPTION, &RF()), 128);
	DWORD dwStyle = CBRS_ALIGN_TOP|CBRS_SIZE_DYNAMIC|CBRS_TOOLTIPS|
					CBRS_BORDER_ANY|CBRS_FLYBY|WS_VISIBLE;

		if (IsWin40()) dwStyle |= CBRS_BORDER_3D;

	// ToolBar erzeugen
	HRESULT hr = BarCont -> AddTRiASBar (strCap, dwStyle, TRIASTOOLBAR_PREDEFINED, Bar.ppi());

		if (FAILED(hr)) _com_issue_error (hr);

	// Bitmaps hinzufügen
	WTRiASToolBar ToolBar (Bar);	// throws HRESULT
	int iOffset = -1;

		hr = ToolBar -> AddBitmap (g_hInstance, IDB_TOOLBARDESIGN, BMPSIZE_DESIGN, &iOffset);
		if (FAILED(hr)) return hr;

		pBtnCopy = CopyButtons (tbDesign, NUMBUTTONS_DESIGN);
		if (NULL == pBtnCopy) _com_issue_error (E_OUTOFMEMORY);

	TBBUTTON *pCurr = pBtnCopy;

		for (int i = 0; i < NUMBUTTONS_DESIGN; i++, pCurr++) {
			if (!(TBSTYLE_SEP & pCurr -> fsStyle))
				pCurr -> iBitmap += iOffset;
		}
	
	// UIOwner erzeugen
	WTRiASUIOwner UIOwner;
	
		THROW_FAILED_HRESULT (CUIOwner::_CreatorClass::CreateInstance (NULL, IID_ITRiASUIOwner,
																	  (LPVOID*)UIOwner.ppi()));
		// Buttons hinzufügen
		hr = ToolBar -> AddButtons (pBtnCopy, NUMBUTTONS_DESIGN, UIOwner);
		if (FAILED(hr)) _com_issue_error (hr);

		hr = ToolBar -> DockBar (AFX_IDW_DOCKBAR_LEFT, &m_REC);
		if (FAILED(hr)) _com_issue_error (hr);

		DELETE_OBJ(pBtnCopy);

	} catch (_com_error &hr) {
		DELETE_OBJ(pBtnCopy);
		return _COM_ERROR(hr);
	}

return NOERROR;
}
示例#3
0
void CInPlaceCombo::SetHorizontalExtent (UINT uiExtent)
{
	if (IsWin40())
		ForwardEvent(CB_SETHORIZONTALEXTENT, uiExtent, 0);
}