コード例 #1
0
ファイル: FileDialogEx.cpp プロジェクト: janker007/cocoshun
//////////////////
// DoModal override copied mostly from MFC, with modification to use
// m_ofnEx instead of m_ofn.
//
int CFileDialogEx::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_ofn.Flags & OFN_ENABLEHOOK);
	ASSERT(m_ofn.lpfnHook != NULL); // can still be a user hook

	// zero out the file buffer for consistent parsing later
	ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile));
	DWORD nOffset = lstrlen(m_ofn.lpstrFile)+1;
	ASSERT(nOffset <= m_ofn.nMaxFile);
	memset(m_ofn.lpstrFile+nOffset, 0, (m_ofn.nMaxFile-nOffset)*sizeof(TCHAR));

	// WINBUG: This is a special case for the file open/save dialog,
	//  which sometimes pumps while it is coming up but before it has
	//  disabled the main window.
	HWND hWndFocus = ::GetFocus();
	BOOL bEnableParent = FALSE;
	m_ofn.hwndOwner = PreModal();
	AfxUnhookWindowCreate();
	if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
	{
		bEnableParent = TRUE;
		::EnableWindow(m_ofn.hwndOwner, FALSE);
	}

	_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
	ASSERT(pThreadState->m_pAlternateWndInit == NULL);

	if (m_ofn.Flags & OFN_EXPLORER)
		pThreadState->m_pAlternateWndInit = this;
	else
		AfxHookWindowCreate(this);

	memset(&m_ofnEx, 0, sizeof(m_ofnEx));
	memcpy(&m_ofnEx, &m_ofn, sizeof(m_ofn));
   if (IsWin2000())
	   m_ofnEx.lStructSize = sizeof(m_ofnEx);

	int nResult;
	if (m_bOpenFileDialog)
		nResult = ::GetOpenFileName((OPENFILENAME*)&m_ofnEx);
	else
		nResult = ::GetSaveFileName((OPENFILENAME*)&m_ofnEx);

	memcpy(&m_ofn, &m_ofnEx, sizeof(m_ofn));
   m_ofn.lStructSize = sizeof(m_ofn);

	if (nResult)
		ASSERT(pThreadState->m_pAlternateWndInit == NULL);
	pThreadState->m_pAlternateWndInit = NULL;

	// WINBUG: Second part of special case for file open/save dialog.
	if (bEnableParent)
		::EnableWindow(m_ofnEx.hwndOwner, TRUE);
	if (::IsWindow(hWndFocus))
		::SetFocus(hWndFocus);

	PostModal();
	return nResult ? nResult : IDCANCEL;
}
コード例 #2
0
ファイル: dlgprnt.cpp プロジェクト: Rupan/winscp
int CPrintDialog::DoModal()
{
	ASSERT_VALID(this);

	m_pd.hwndOwner = PreModal();
	int nResult = ::PrintDlg(&m_pd);
	PostModal();
	return nResult ? nResult : IDCANCEL;
}
コード例 #3
0
ファイル: oledlgs1.cpp プロジェクト: rickerliang/OpenNT
int COleInsertDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_io.lpfnHook != NULL);  // can still be a user hook

	m_io.hWndOwner = PreModal();
	int iResult = MapResult(::OleUIInsertObject(&m_io));
	PostModal();
	return iResult;
}
コード例 #4
0
ファイル: oledlgs1.cpp プロジェクト: rickerliang/OpenNT
int COleConvertDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_cv.lpfnHook != NULL);  // can still be a user hook

	m_cv.hWndOwner = PreModal();
	int iResult = MapResult(::OleUIConvert(&m_cv));
	PostModal();
	return iResult;
}
コード例 #5
0
ファイル: oledlgs1.cpp プロジェクト: rickerliang/OpenNT
int COleChangeIconDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_ci.lpfnHook != NULL);  // can still be a user hook

	m_ci.hWndOwner = PreModal();
	int iResult = MapResult(::OleUIChangeIcon(&m_ci));
	PostModal();
	return iResult;
}
コード例 #6
0
ファイル: dlgprnt.cpp プロジェクト: rickerliang/OpenNT
int CPageSetupDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_psd.Flags & PSD_ENABLEPAGESETUPHOOK);
	ASSERT(m_psd.Flags & PSD_ENABLEPAGEPAINTHOOK);
	ASSERT(m_psd.lpfnPageSetupHook != NULL); // can still be a user hook
	ASSERT(m_psd.lpfnPagePaintHook != NULL); // can still be a user hook

	m_psd.hwndOwner = PreModal();
	int nResult = ::PageSetupDlg(&m_psd);
	PostModal();
	return nResult ? nResult : IDCANCEL;
}
コード例 #7
0
ファイル: oledlgs1.cpp プロジェクト: rickerliang/OpenNT
int COleLinksDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_el.lpfnHook != NULL);  // can still be a user hook

	// this function is always used for updating links
	m_xLinkInfo.m_bUpdateLinks = TRUE;

	m_el.hWndOwner = PreModal();
	int iResult = MapResult(::OleUIEditLinks(&m_el));
	PostModal();
	return iResult;
}
コード例 #8
0
ファイル: dlgprnt.cpp プロジェクト: rickerliang/OpenNT
int CPrintDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_pd.Flags & PD_ENABLEPRINTHOOK);
	ASSERT(m_pd.Flags & PD_ENABLESETUPHOOK);
	ASSERT(m_pd.lpfnPrintHook != NULL); // can still be a user hook
	ASSERT(m_pd.lpfnSetupHook != NULL); // can still be a user hook

	m_pd.hwndOwner = PreModal();
	int nResult = ::PrintDlg(&m_pd);
	PostModal();
	return nResult ? nResult : IDCANCEL;
}
コード例 #9
0
ファイル: oledlgs1.cpp プロジェクト: rickerliang/OpenNT
int COlePasteSpecialDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_ps.lpfnHook != NULL);  // can still be a user hook

	// return error if IDataObject* not available
	if (m_ps.lpSrcDataObj == NULL)
		return -1;

	m_ps.hWndOwner = PreModal();
	int iResult = MapResult(::OleUIPasteSpecial(&m_ps));
	PostModal();
	return iResult;
}
コード例 #10
0
ファイル: dlgfile.cpp プロジェクト: rickerliang/OpenNT
int CFileDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_ofn.Flags & OFN_ENABLEHOOK);
	ASSERT(m_ofn.lpfnHook != NULL); // can still be a user hook
#ifdef _MAC
	ASSERT((m_ofn.Flags & OFN_ALLOWMULTISELECT) == 0);
#endif

	// WINBUG: This is a special case for the file open/save dialog,
	//  which sometimes pumps while it is coming up but before it has
	//  disabled the main window.
	HWND hWndFocus = ::GetFocus();
	BOOL bEnableParent = FALSE;
	m_ofn.hwndOwner = PreModal();
	AfxUnhookWindowCreate();
	if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
	{
		bEnableParent = TRUE;
		::EnableWindow(m_ofn.hwndOwner, FALSE);
	}

	_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
	ASSERT(pThreadState->m_pAlternateWndInit == NULL);

	if (m_ofn.Flags & OFN_EXPLORER)
		pThreadState->m_pAlternateWndInit = this;
	else
		AfxHookWindowCreate(this);

	int nResult;
	if (m_bOpenFileDialog)
		nResult = ::GetOpenFileName(&m_ofn);
	else
		nResult = ::GetSaveFileName(&m_ofn);

	if (nResult)
		ASSERT(pThreadState->m_pAlternateWndInit == NULL);
	pThreadState->m_pAlternateWndInit = NULL;

	// WINBUG: Second part of special case for file open/save dialog.
	if (bEnableParent)
		::EnableWindow(m_ofn.hwndOwner, TRUE);
	if (::IsWindow(hWndFocus))
		::SetFocus(hWndFocus);

	PostModal();
	return nResult ? nResult : IDCANCEL;
}
コード例 #11
0
int CKSFileDialog::DoModal()
{
	ASSERT_VALID(this);
	DWORD nOffset = lstrlen(m_ofn.lpstrFile)+1;
	memset(m_ofn.lpstrFile+nOffset, 0, (m_ofn.nMaxFile-nOffset)*sizeof(TCHAR));

	HWND hWndFocus = ::GetFocus();
	BOOL bEnableParent = FALSE;
	//m_ofn.hwndOwner = PreModal();
	
	CWnd dummy;
	dummy.CreateEx(NULL,AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),NULL,NULL,CRect(0,0,0,0),NULL,NULL);
	dummy.CenterWindow();
	CRect rect;
	dummy.GetWindowRect(rect);
	dummy.SetWindowPos(NULL, rect.left-230, rect.top-180, -1, -1,
		SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);	dummy.ShowWindow(SW_HIDE);
	m_ofn.hwndOwner=dummy.GetSafeHwnd();
	if (m_ofn.hwndOwner==NULL) m_ofn.hwndOwner=PreModal();
	if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
	{
		bEnableParent = TRUE;
		::EnableWindow(m_ofn.hwndOwner, FALSE);
	}

	_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
	ASSERT(pThreadState->m_pAlternateWndInit == NULL);

	m_ofn.lpfnHook = NULL;
	m_ofn.lpTemplateName = NULL;
	int nResult;
	if (m_bOpenFileDialog)
		nResult = ::GetOpenFileName(&m_ofn);
	else
		nResult = ::GetSaveFileName(&m_ofn);

	if (nResult)
		ASSERT(pThreadState->m_pAlternateWndInit == NULL);
	pThreadState->m_pAlternateWndInit = NULL;

	// WINBUG: Second part of special case for file open/save dialog.
	if (bEnableParent)
		::EnableWindow(m_ofn.hwndOwner, TRUE);
	if (::IsWindow(hWndFocus))
		::SetFocus(hWndFocus);

	PostModal();
	return nResult ? nResult : IDCANCEL;
}
コード例 #12
0
ファイル: dlgfile.cpp プロジェクト: rickerliang/OpenNT
int CFileDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_ofn.Flags & OFN_ENABLEHOOK);
	ASSERT(m_ofn.lpfnHook != NULL); // can still be a user hook

	int nResult;
	m_ofn.hwndOwner = PreModal();
	if (m_bOpenFileDialog)
		nResult = ::GetOpenFileName(&m_ofn);
	else
		nResult = ::GetSaveFileName(&m_ofn);
	PostModal();
	return nResult ? nResult : IDCANCEL;
}
コード例 #13
0
ファイル: Dialogs.cpp プロジェクト: DavidKinder/Libraries
INT_PTR SimpleFileDialog::DoModal()
{
  // Don't use a hook procedure for Vista
  OSVERSIONINFO osvi;
  osvi.dwOSVersionInfoSize = sizeof osvi;
  ::GetVersionEx(&osvi);
  if (osvi.dwMajorVersion >= 6)
    m_ofn.Flags &= ~OFN_ENABLEHOOK;

  DWORD nOffset = lstrlen(m_ofn.lpstrFile)+1;
  memset(m_ofn.lpstrFile+nOffset, 0, (m_ofn.nMaxFile-nOffset)*sizeof(TCHAR));

  HWND hWndFocus = ::GetFocus();
  BOOL bEnableParent = FALSE;
  m_ofn.hwndOwner = PreModal();
  AfxUnhookWindowCreate();
  if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
  {
    bEnableParent = TRUE;
    ::EnableWindow(m_ofn.hwndOwner, FALSE);
  }

  _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();

  if (m_ofn.Flags & OFN_EXPLORER)
    pThreadState->m_pAlternateWndInit = this;
  else
    AfxHookWindowCreate(this);

  INT_PTR nResult;
  if (m_bOpenFileDialog)
    nResult = ::GetOpenFileName(&m_ofn);
  else
    nResult = ::GetSaveFileName(&m_ofn);

  pThreadState->m_pAlternateWndInit = NULL;

  if (bEnableParent)
    ::EnableWindow(m_ofn.hwndOwner, TRUE);
  if (::IsWindow(hWndFocus))
    ::SetFocus(hWndFocus);

  PostModal();
  return nResult ? nResult : IDCANCEL;
}
コード例 #14
0
ファイル: dlgfnt.cpp プロジェクト: Rupan/winscp
int CFontDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_cf.Flags & CF_ENABLEHOOK);
	ASSERT(m_cf.lpfnHook != NULL); // can still be a user hook

	m_cf.hwndOwner = PreModal();
	int nResult = ::ChooseFont(&m_cf);
	PostModal();

	if (nResult == IDOK)
	{
		// copy logical font from user's initialization buffer (if needed)
		memcpy(&m_lf, m_cf.lpLogFont, sizeof(m_lf));
		return IDOK;
	}
	return nResult ? nResult : IDCANCEL;
}
コード例 #15
0
ファイル: dialog.cpp プロジェクト: clbr/netradiant
EMessageBoxReturn Dialog::DoModal()
{
  importData();

  PreModal();

  EMessageBoxReturn ret = modal_dialog_show(m_window, m_modal);
  ASSERT_NOTNULL(m_window);
  if(ret == eIDOK)
  {
    exportData();
  }

  gtk_widget_hide(GTK_WIDGET(m_window));

  PostModal(m_modal.ret);

  return m_modal.ret;
}
コード例 #16
0
ファイル: dialog.cpp プロジェクト: chrisglass/ufoai
EMessageBoxReturn Dialog::DoModal ()
{
	// Import the values from the registry before showing the dialog
	_registryConnector.importValues();

	PreModal();

	EMessageBoxReturn ret = modal_dialog_show(m_window, m_modal);
	ASSERT_NOTNULL(m_window);
	if (ret == eIDOK) {
		_registryConnector.exportValues();
	}

	gtk_widget_hide(GTK_WIDGET(m_window));

	PostModal(m_modal.ret);

	return m_modal.ret;
}
コード例 #17
0
ファイル: oledlgs1.cpp プロジェクト: rickerliang/OpenNT
int COleUpdateDialog::DoModal()
{
	ASSERT_VALID(this);

	// first count number of links/embeddings to be updated
	DWORD dwLink = 0;
	int cLinks = 0;
	while ((dwLink = m_el.lpOleUILinkContainer->GetNextLink(dwLink)) != 0)
		++cLinks;
	// when no links are out-of-date, don't bother
	if (cLinks == 0)
		return IDCANCEL;

	// bring up the dialog that processes all the links
	HWND hWndParent = PreModal();
	BOOL bResult = OleUIUpdateLinks(m_el.lpOleUILinkContainer,
		hWndParent, (LPTSTR)(LPCTSTR)m_strCaption, cLinks);
	PostModal();
	return bResult ? IDOK : -1;
}
コード例 #18
0
ファイル: FolderDlg.cpp プロジェクト: Zero3K/connectfusion
	INT		CFolderDialog::DoModal( void )
#endif
{
	ASSERT_VALID( this );	
	ASSERT( m_bi.lpfn != NULL );
		
	m_bi.hwndOwner = PreModal();	
	INT_PTR nRet   = -1;

	LPITEMIDLIST pItemIDList = ::SHBrowseForFolder( &m_bi );
	if( pItemIDList )
	{
		if( ::SHGetPathFromIDList( pItemIDList, m_szFolPath ) )
			nRet = IDOK;
		else
			nRet = IDCANCEL;

		_coTaskMemFree( pItemIDList );
	}

	PostModal();
	return ( nRet );
}
コード例 #19
0
INT		CFolderDialog::DoModal(VOID)
#endif
{
	ASSERT_VALID(this);
	ASSERT(m_bi.lpfn != NULL);

	INT_PTR nRet = -1;
	m_bi.hwndOwner = PreModal();

	LPITEMIDLIST pItemIDList = ::SHBrowseForFolder(&m_bi);
	if (pItemIDList)
	{
		if (::SHGetPathFromIDList(pItemIDList, m_szFolPath))
			nRet = IDOK;

		SAFE_COTASKMEMFREE(pItemIDList);
	}
	else
		nRet = IDCANCEL;


	PostModal();
	return (nRet);
}
コード例 #20
0
int Dialog::DoModal(){
	Create();
	UpdateData( FALSE );

	PreModal();

	gtk_grab_add( m_pWidget );
	gtk_widget_show( m_pWidget );

	m_nLoop = true;
	while ( m_nLoop ) {
		gtk_main_iteration();
	}

	if ( m_pWidget != NULL ) {
		UpdateData( TRUE );

		gtk_grab_remove( m_pWidget );
		gtk_widget_hide( m_pWidget );
	}
	PostModal( m_nReturn );

	return m_nReturn;
}
コード例 #21
0
ファイル: MyFileDialog.cpp プロジェクト: ijprest/WinDjVu
INT_PTR CMyFileDialog::DoModal()
{
	// From MFC:  CFileDialog::DoModal
	// Uses the OpenFileNameEx structure on Win2k+

	set<CWnd*> disabled;
	theApp.DisableTopLevelWindows(disabled);

	ASSERT_VALID(this);
	ASSERT((m_ofn.Flags & OFN_EXPLORER) != 0);
	ASSERT((m_ofn.Flags & OFN_ENABLEHOOK) == 0);
	ASSERT(m_ofn.lpfnHook == NULL);  // Not using hooks

	// zero out the file buffer for consistent parsing later
	ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile));
	DWORD nOffset = lstrlen(m_ofn.lpstrFile) + 1;
	ASSERT(nOffset <= m_ofn.nMaxFile);
	ZeroMemory(m_ofn.lpstrFile + nOffset, (m_ofn.nMaxFile - nOffset)*sizeof(TCHAR));

	// WINBUG: This is a special case for the file open/save dialog,
	//  which sometimes pumps while it is coming up but before it has
	//  disabled the main window.
	HWND hWndFocus = ::GetFocus();
	BOOL bEnableParent = FALSE;
	m_ofn.hwndOwner = PreModal();
	if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
	{
		bEnableParent = TRUE;
		::EnableWindow(m_ofn.hwndOwner, FALSE);
	}

	AfxUnhookWindowCreate();

	_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
	ASSERT(pThreadState->m_pAlternateWndInit == NULL);
	pThreadState->m_pAlternateWndInit = this;

	// Install our own hook to subclass the file dialog
	MyFileDialogData* pMyData = _myFileDlgData.GetData();
	ASSERT(pMyData->hHook == NULL);
	pMyData->hHook = ::SetWindowsHookEx(WH_CBT, &HookProc, NULL, ::GetCurrentThreadId());

	int nResult;
	if (m_bOpenFileDialog)
		nResult = ::GetOpenFileName(&m_ofn);
	else
		nResult = ::GetSaveFileName(&m_ofn);

	if (nResult)
		ASSERT(pThreadState->m_pAlternateWndInit == NULL);
	pThreadState->m_pAlternateWndInit = NULL;

	::UnhookWindowsHookEx(pMyData->hHook);
	pMyData->hHook = NULL;

	// WINBUG: Second part of special case for file open/save dialog.
	if (bEnableParent)
		::EnableWindow(m_ofn.hwndOwner, TRUE);
	if (::IsWindow(hWndFocus))
		::SetFocus(hWndFocus);

	PostModal();

	theApp.EnableWindows(disabled);
	return nResult ? nResult : IDCANCEL;
}
コード例 #22
0
ファイル: dlgprnt2.cpp プロジェクト: ContiGabriel/msiext
INT_PTR C_PrintDialogEx::DoModal()
{
        ASSERT_VALID(this);

        m_pd.hwndOwner = PreModal();
        AfxUnhookWindowCreate();

        // expand m_pd data into the PRINTDLGEX structure

        m_pdex.hwndOwner = m_pd.hwndOwner;
        m_pdex.hDevMode = m_pd.hDevMode;
        m_pdex.hDevNames = m_pd.hDevNames;
        m_pdex.hDC = m_pd.hDC;
//        m_pdex.Flags = (m_pd.Flags & ~(PD_ENABLEPRINTHOOK | PD_ENABLESETUPHOOK | PD_PRINTSETUP));

        m_pdex.nMinPage = m_pd.nMinPage;
        m_pdex.nMaxPage = m_pd.nMaxPage;
        m_pdex.hInstance = m_pd.hInstance;
        m_pdex.nStartPage = START_PAGE_GENERAL;
        m_pdex.nCopies = m_pd.nCopies;
        m_pdex.lpCallback = &m_xPrintDialogCallback;

        // initialize page ranges

        PRINTPAGERANGE ourPageRange;

        if (m_pdex.Flags & PD_NOPAGENUMS)
        {
                m_pdex.lpPageRanges = NULL;
                m_pdex.nPageRanges = 0;
                m_pdex.nMaxPageRanges = 0;
        }
        else
        {
                ourPageRange.nFromPage = m_pd.nFromPage;
                ourPageRange.nToPage   = m_pd.nToPage;
                m_pdex.nPageRanges = 1;
                m_pdex.nMaxPageRanges = 1;
                m_pdex.lpPageRanges = &ourPageRange;
        }

        HMODULE hCommDlg = GetModuleHandleA("COMDLG32.DLL");
        HRESULT (STDAPICALLTYPE* pfn)(LPPRINTDLGEX);
#ifdef UNICODE
        pfn = (HRESULT (STDAPICALLTYPE*)(LPPRINTDLGEX))
                                GetProcAddress(hCommDlg, "PrintDlgExW");
#else
        pfn = (HRESULT (STDAPICALLTYPE*)(LPPRINTDLGEX))
                                GetProcAddress(hCommDlg, "PrintDlgExA");
#endif

        HRESULT hResult = E_NOTIMPL;
        if (pfn != NULL)
        {
                _AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
                ASSERT(pThreadState->m_pAlternateWndInit == NULL);

                pThreadState->m_pAlternateWndInit = this;

                hResult = pfn(&m_pdex);
                if (SUCCEEDED(hResult))
                        ASSERT(pThreadState->m_pAlternateWndInit == NULL);
                pThreadState->m_pAlternateWndInit = NULL;
        }

        // pull data back...

        PostModal();

        if (!(m_pdex.Flags & PD_NOPAGENUMS))
        {
                m_pd.nToPage = (WORD) m_pdex.lpPageRanges->nToPage;
                m_pd.nFromPage = (WORD) m_pdex.lpPageRanges->nFromPage;
                m_pd.nMinPage = (WORD) m_pdex.nMinPage;
                m_pd.nMaxPage = (WORD) m_pdex.nMaxPage;
        }

        m_pd.hDevMode = m_pdex.hDevMode;
        m_pd.hDevNames = m_pdex.hDevNames;
        m_pd.hDC = m_pdex.hDC;
        m_pd.nCopies = (WORD)m_pdex.nCopies;
        // calculate return code
        int nResult = IDCANCEL;
        if (SUCCEEDED(hResult))
        {
                if (m_pdex.dwResultAction == PD_RESULT_PRINT)
                        nResult = IDOK;
        }
        return nResult;
}
コード例 #23
0
//=============================================================================
// DoModal override copied mostly from MFC, with modification to use
// m_ofnEx instead of m_ofn.
INT_PTR CXFolderDialog::DoModal()
//=============================================================================
{
	TRACE(_T("in CXFolderDialog::DoModal\n"));

	ASSERT_VALID(this);
	ASSERT(m_ofn.Flags & OFN_ENABLEHOOK);
	ASSERT(m_ofn.lpfnHook != NULL); // can still be a user hook

	AFX_MANAGE_STATE(AFXMANAGESTATE())

	m_bFirstTime = TRUE;

	m_wndListView.Init(this);

	// zero out the file buffer for consistent parsing later
	TCHAR * pBuf = new TCHAR [m_ofn.nMaxFile + 100];
	memset(pBuf, 0, (m_ofn.nMaxFile + 100) * sizeof(TCHAR));
	if (m_ofn.lpstrFile)
	{
		// copy file buffer
		_tcsncpy(pBuf, m_ofn.lpstrFile, m_ofn.nMaxFile);
		// zero out file buffer in OPENFILENAME struct
		memset(m_ofn.lpstrFile, 0, m_ofn.nMaxFile*sizeof(TCHAR));
		// restore copied file buffer
		_tcsncpy(m_ofn.lpstrFile, pBuf, m_ofn.nMaxFile);
	}
	if (pBuf)
		delete [] pBuf;
	pBuf = NULL;

	// WINBUG: This is a special case for the file open/save dialog,
	// which sometimes pumps while it is coming up but before it has
	// disabled the main window.
	HWND hWndFocus = ::GetFocus();
	BOOL bEnableParent = FALSE;
	m_ofn.hwndOwner = PreModal();
	AfxUnhookWindowCreate();
	if (m_ofn.hwndOwner != NULL && ::IsWindowEnabled(m_ofn.hwndOwner))
	{
		bEnableParent = TRUE;
		::EnableWindow(m_ofn.hwndOwner, FALSE);
	}

	_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
	ASSERT(pThreadState->m_pAlternateWndInit == NULL);

	if (m_ofn.Flags & OFN_EXPLORER)
		pThreadState->m_pAlternateWndInit = this;
	else
		AfxHookWindowCreate(this);

	memset(&m_ofnEx, 0, sizeof(m_ofnEx));
	memcpy(&m_ofnEx, &m_ofn, sizeof(m_ofn));
	if (m_ofnEx.hInstance == 0)
		m_ofnEx.hInstance = AfxGetInstanceHandle();

	m_ofnEx.Flags |= OFN_ENABLESIZING;

#if (_WIN32_WINNT >= 0x0500)

	TRACE(_T("_WIN32_WINNT=0x%X\n"), _WIN32_WINNT);

	#pragma message(__FILE__ "(" makestring(__LINE__) \
		") : OPENFILENAME is large size (3 extra items are included)")

	if (IsWin2000())
		m_ofnEx.lStructSize = sizeof(OPENFILENAME);				// OS >= 2000, force to large size
	else
		m_ofnEx.lStructSize = OPENFILENAME_SIZE_VERSION_400;	// use small size

#else	// _WIN32_WINNT < 0x0500, or isn't defined

	#pragma message(__FILE__ "(" makestring(__LINE__) \
		") : OPENFILENAME is small size (3 extra items are NOT included)")

	if (IsWin2000())
		m_ofnEx.lStructSize = sizeof(OPENFILENAMEEX_FOLDER);			// OS >= 2000, force to large size
	else
		m_ofnEx.lStructSize = OPENFILENAME_SIZE_VERSION_400;	// use small size

#endif

	m_ofnEx.lpstrInitialDir = m_strInitialFolder;
	//m_ofnEx.lpstrFilter = m_strFilter;

	int nResult = 0;
	if (m_bOpenFileDialog)
		nResult = ::GetOpenFileName((OPENFILENAME*)&m_ofnEx);
	else
		nResult = ::GetSaveFileName((OPENFILENAME*)&m_ofnEx);

	memcpy(&m_ofn, &m_ofnEx, sizeof(m_ofn));
	m_ofn.lStructSize = sizeof(m_ofn);

	if (nResult)
	{
		ASSERT(pThreadState->m_pAlternateWndInit == NULL);
	}
	pThreadState->m_pAlternateWndInit = NULL;

	// WINBUG: Second part of special case for file open/save dialog.
	if (bEnableParent)
		::EnableWindow(m_ofnEx.hwndOwner, TRUE);
	if (::IsWindow(hWndFocus))
		::SetFocus(hWndFocus);

	PostModal();

	return nResult ? nResult : IDCANCEL;
}
コード例 #24
0
ファイル: dlgcore.cpp プロジェクト: anyue100/winscp
int CDialog::DoModal()
{
	// can be constructed with a resource template or InitModalIndirect
	ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
		m_lpDialogTemplate != NULL);

	// load resource as necessary
	LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
	HGLOBAL hDialogTemplate = m_hDialogTemplate;
	HINSTANCE hInst = AfxGetResourceHandle();
	if (m_lpszTemplateName != NULL)
	{
		hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
		HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
		hDialogTemplate = LoadResource(hInst, hResource);
	}
	if (hDialogTemplate != NULL)
		lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);

	// return -1 in case of failure to load the dialog template resource
	if (lpDialogTemplate == NULL)
		return -1;

	// disable parent (before creating dialog)
	HWND hWndParent = PreModal();
	AfxUnhookWindowCreate();
	BOOL bEnableParent = FALSE;
	if (hWndParent != NULL && ::IsWindowEnabled(hWndParent))
	{
		::EnableWindow(hWndParent, FALSE);
		bEnableParent = TRUE;
	}

	TRY
	{
		// create modeless dialog
		AfxHookWindowCreate(this);
		if (CreateDlgIndirect(lpDialogTemplate,
						CWnd::FromHandle(hWndParent), hInst))
		{
			if (m_nFlags & WF_CONTINUEMODAL)
			{
				// enter modal loop
				DWORD dwFlags = MLF_SHOWONIDLE;
				if (GetStyle() & DS_NOIDLEMSG)
					dwFlags |= MLF_NOIDLEMSG;
				VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
			}

			// hide the window before enabling the parent, etc.
			if (m_hWnd != NULL)
				SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
					SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
		}
	}
	CATCH_ALL(e)
	{
		DELETE_EXCEPTION(e);
		m_nModalResult = -1;
	}
	END_CATCH_ALL

	if (bEnableParent)
		::EnableWindow(hWndParent, TRUE);
	if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
		::SetActiveWindow(hWndParent);

	// destroy modal window
	DestroyWindow();
	PostModal();

	// unlock/free resources as necessary
	if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
		UnlockResource(hDialogTemplate);
	if (m_lpszTemplateName != NULL)
		FreeResource(hDialogTemplate);

	return m_nModalResult;
}
コード例 #25
0
int CWebInterfaceDlg::DoModal() 
{
		
	ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
		m_lpDialogTemplate != NULL);

	
	LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
	HGLOBAL hDialogTemplate = m_hDialogTemplate;
	HINSTANCE hInst = AfxGetResourceHandle();
	if (m_lpszTemplateName != NULL)
	{
		hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
		HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
		hDialogTemplate = LoadResource(hInst, hResource);
	}
	if (hDialogTemplate != NULL)
		lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);

	
	if (lpDialogTemplate == NULL)
		return -1;

	
	HWND hWndParent = PreModal();
	AfxUnhookWindowCreate();
	BOOL bEnableParent = FALSE;
	if (hWndParent != NULL && ::IsWindowEnabled(hWndParent))
	{
		::EnableWindow(hWndParent, FALSE);
		bEnableParent = TRUE;
	}

	TRY
	{
		
		AfxHookWindowCreate(this);
		if (CreateDlgIndirect(lpDialogTemplate,
						CWnd::FromHandle(hWndParent), hInst))
		{
			if (m_nFlags & WF_CONTINUEMODAL)
			{
				
				DWORD dwFlags = 0; 
				if (GetStyle() & DS_NOIDLEMSG)
					dwFlags |= MLF_NOIDLEMSG;
				VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
			}

			
			if (m_hWnd != NULL)
				SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
					SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
		}
	}
	CATCH_ALL(e)
	{
		DELETE_EXCEPTION(e);
		m_nModalResult = -1;
	}
	END_CATCH_ALL

	if (bEnableParent)
		::EnableWindow(hWndParent, TRUE);
	if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
		::SetActiveWindow(hWndParent);

	
	DestroyWindow();
	PostModal();

	
	if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
		UnlockResource(hDialogTemplate);
	if (m_lpszTemplateName != NULL)
		FreeResource(hDialogTemplate);

	return m_nModalResult;
}
コード例 #26
0
ファイル: RuntimeDlg.cpp プロジェクト: jithuin/infogeezer
int CRuntimeDlg::DoModal(LPCTSTR szCaption, DWORD dwStyle, DWORD dwExStyle, const CRect& rect, CWnd* pParentWnd, UINT nID)
{
	// fail immediately if no controls have been added
	if (!m_lstControls.GetCount())
		return IDCANCEL;
	
	// setup for modal loop and creation
	m_nModalResult = -1;
	m_nFlags |= WF_CONTINUEMODAL;
	
	// disable parent (before creating dialog)
	HWND hWndParent = PreModal();
	AfxUnhookWindowCreate();
	
	BOOL bEnableParent = FALSE;
	if (hWndParent != NULL && ::IsWindowEnabled(hWndParent))
	{
		::EnableWindow(hWndParent, FALSE);
		bEnableParent = TRUE;
	}
	
	try
	{
		// create modeless dialog
		if (Create(szCaption, dwStyle, dwExStyle, rect, pParentWnd ? pParentWnd : CWnd::FromHandle(hWndParent), nID))
		{
			if (m_nFlags & WF_CONTINUEMODAL)
			{
				// enter modal loop
				DWORD dwFlags = MLF_SHOWONIDLE;
				if (GetStyle() & DS_NOIDLEMSG)
					dwFlags |= MLF_NOIDLEMSG;
				VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
			}
			
			// hide the window before enabling the parent, etc.
			if (m_hWnd != NULL)
				SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
		}
	}
	catch(...)
	{
		m_nModalResult = -1;
	}
	
	if (bEnableParent)
		::EnableWindow(hWndParent, TRUE);
	
	if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
		::SetActiveWindow(hWndParent);
	
	// save pos
	SaveCurrentPos();

	// destroy modal window
	DestroyWindow();
	PostModal();

	// cleanup resources
	GraphicsMisc::VerifyDeleteObject(m_hFont);
	::DestroyIcon(m_hILarge);
	::DestroyIcon(m_hISmall);
	
	return m_nModalResult;
}
コード例 #27
-1
ファイル: oledlgs3.cpp プロジェクト: anyue100/winscp
int COlePropertiesDialog::DoModal()
{
	ASSERT_VALID(this);
	ASSERT(m_gp.lpfnHook != NULL);  // can still be a user hook
	ASSERT(m_vp.lpfnHook != NULL);  // can still be a user hook
	ASSERT(m_lp.lpfnHook != NULL);  // can still be a user hook

	// disable scale if OnApplyScale not implemented
	if (!OnApplyScale(NULL, -1, FALSE))
		m_op.lpVP->dwFlags |= VPF_DISABLESCALE;

	// invoke the dialog
	m_op.lpPS->hwndParent = PreModal();
	int iResult = MapResult(::OleUIObjectProperties(&m_op));
	PostModal();
	return iResult;
}