Example #1
0
void CDFileNew::OnBnClickedBrowse()
{
	// TODO: 開新檔案 -> 瀏覽
	CString strFilter;
	CSimpleArray<GUID> aguidFileTypes;
	HRESULT hResult;
	CImage *pImgTemp = NULL;

	hResult = pImgTemp->GetImporterFilterString(strFilter, aguidFileTypes, _T("All Image Files"));
	if(FAILED(hResult)) return; // 副檔名讀取失敗

	CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, strFilter);
	hResult = (int)dlg.DoModal();
	if(FAILED(hResult)) return; // 對話方塊執行失敗

	m_sPath = dlg.GetPathName();
	OnInitDialog();
}
Example #2
0
void CChildView::OnFileOpen()
{
	CImage image;
	CString strFilter;
	CString strAllFilePrompt;
	CSimpleArray<GUID> aguidFileTypes;
	HRESULT hResult;
	INT_PTR nResult;

	if (m_pSurface == NULL)
		return;
	VERIFY(strAllFilePrompt.LoadString(IDS_ALL_IMAGES));
	hResult = image.GetImporterFilterString(strFilter, aguidFileTypes, strAllFilePrompt);
	if(FAILED(hResult))	{
		CString fmt;
		fmt.Format(IDS_ERROR_GETEXPORTERFILTER, hResult, _com_error(hResult).ErrorMessage());
		::AfxMessageBox(fmt);
		return;
	}

	CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, strFilter);
	dlg.m_ofn.nFilterIndex = m_nFilterLoad;

	nResult = dlg.DoModal();
	if(nResult != IDOK) {
		return;
	}

	m_nFilterLoad = dlg.m_ofn.nFilterIndex;
	hResult = image.Load(dlg.GetFileName());
	ASSERT(SUCCEEDED(hResult));
	if (SUCCEEDED(hResult)) {
		m_pSurface->Import(image);
		// Stop the weird effects
		m_bPauseBlur = true;
		m_bPauseSwarm = true;
	}
}