Пример #1
0
_AFX_OCC_DIALOG_INFO* CFormView::GetOccDialogInfo()
{
#ifndef _AFX_NO_OCC_SUPPORT
    if (m_pOccDialogInfo == NULL && m_lpszTemplateName != NULL)
    {
        LPCDLGTEMPLATE lpDialogTemplate = NULL;
        HINSTANCE hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
        HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
        HGLOBAL hTemplate = LoadResource(hInst, hResource);
        if (hTemplate != NULL)
        {
            lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hTemplate);
            if (lpDialogTemplate != NULL)
            {
                COccManager* pOccManager = afxOccManager;
                if (pOccManager != NULL)
                {
                    _AFX_OCC_DIALOG_INFO *pOccDialogInfo = new _AFX_OCC_DIALOG_INFO;
                    lpDialogTemplate = pOccManager->PreCreateDialog(pOccDialogInfo,
                        lpDialogTemplate);
                    m_pOccDialogInfo = pOccDialogInfo;
                }
            }
        }
        
    }
#endif
    return m_pOccDialogInfo;	
}
Пример #2
0
CFormView::~CFormView()
{
#ifndef _AFX_NO_OCC_SUPPORT
    if (m_pOccDialogInfo != NULL)
    {
        COccManager* pOccManager = afxOccManager;
        if (pOccManager != NULL)
        {
            pOccManager->PostCreateDialog(m_pOccDialogInfo);
            m_pOccDialogInfo = NULL;
        }
    }
#endif
}
Пример #3
0
LRESULT CFormView::HandleInitDialog(WPARAM, LPARAM)
{
    Default();  // allow default to initialize first (common dialogs/etc)

    // create OLE controls
    COccManager* pOccManager = afxOccManager;
    if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
    {
        if (!pOccManager->CreateDlgControls(this, m_lpszTemplateName,
                                            m_pOccDialogInfo))
        {
            TRACE0("Warning: CreateDlgControls failed during form view init.\n");
            return FALSE;
        }
    }

    return FALSE;   // don't set focus until later
}
Пример #4
0
LRESULT CBCGDialogBar::HandleInitDialog(WPARAM, LPARAM)
{
	Default();  // allow default to initialize first (common dialogs/etc)

	// create OLE controls
	COccManager* pOccManager = afxOccManager;
	if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
	{
		if (!pOccManager->CreateDlgControls(this, m_lpszTemplateName,
			m_pOccDialogInfo))
		{
			TRACE (_T("Warning: CreateDlgControls failed during dialog bar init.\n"));
			return FALSE;
		}
	}

	return TRUE;
}
Пример #5
0
LRESULT CDialog::HandleInitDialog(WPARAM, LPARAM)
{
	PreInitDialog();

#ifndef _AFX_NO_OCC_SUPPORT
	// create OLE controls
	COccManager* pOccManager = afxOccManager;
	if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
	{
		BOOL bDlgInit;
		if (m_lpDialogInit != NULL)
			bDlgInit = pOccManager->CreateDlgControls(this, m_lpDialogInit,
				m_pOccDialogInfo);
		else
			bDlgInit = pOccManager->CreateDlgControls(this, m_lpszTemplateName,
				m_pOccDialogInfo);

		if (!bDlgInit)
		{
			TRACE0("Warning: CreateDlgControls failed during dialog init.\n");
			EndDialog(-1);
			return FALSE;
		}
	}
#endif

	// Default will call the dialog proc, and thus OnInitDialog
	BOOL bResult = Default();

#ifndef _AFX_NO_OCC_SUPPORT
	if (bResult && (m_nFlags & WF_OLECTLCONTAINER))
	{
		CWnd* pWndNext = GetNextDlgTabItem(NULL);
		if (pWndNext != NULL)
		{
			pWndNext->SetFocus();   // UI Activate OLE control
			bResult = FALSE;
		}
	}
#endif

	return bResult;
}
Пример #6
0
LRESULT COXSizeDialogBar::HandleInitDialog(WPARAM, LPARAM)
	{
	Default();  // allow default to initialize first (common dialogs/etc)


	// get extension data - for backward compatibility with existing MRCEXT,
	// this can't be in the base class itself.
	// create OLE controls
	COccManager* pOccManager = afxOccManager;
	if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
		{
		if (!pOccManager->CreateDlgControls(this, m_lpszTemplateName, m_pOccDialogInfo))
			{
			TRACE0("Warning: CreateDlgControls failed during dialog bar init.\n");
			return FALSE;
			}
		}

	BOOL bResult=OnInitDialog();
	return bResult;
	}
//*****************************************************************************************
LRESULT CBCGPDialogBar::HandleInitDialog(WPARAM wParam, LPARAM lParam)
{
	CBCGPBaseControlBar::HandleInitDialog(wParam, lParam);

#ifndef _AFX_NO_OCC_SUPPORT
	Default();  // allow default to initialize first (common dialogs/etc)

	// create OLE controls
	COccManager* pOccManager = afxOccManager;
	if ((pOccManager != NULL) && (m_pOccDialogInfo != NULL))
	{
		if (!pOccManager->CreateDlgControls(this, m_lpszBarTemplateName,
			m_pOccDialogInfo))
		{
			TRACE (_T("Warning: CreateDlgControls failed during dialog bar init.\n"));
			return FALSE;
		}
	}
#endif //!_AFX_NO_OCC_SUPPORT

	if (IsVisualManagerStyle ())
	{
		m_Impl.EnableVisualManagerStyle (TRUE);
		m_Impl.m_bTransparentStaticCtrls = FALSE;
	}

	if (m_bIsScrollingEnabled)
	{
		CRect rectClient;
		GetClientRect (rectClient);

		m_scrollSize = rectClient.Size ();
	}

	return TRUE;
}
Пример #8
0
BOOL CWnd::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate,
	CWnd* pParentWnd, HINSTANCE hInst)
{
	ASSERT(lpDialogTemplate != NULL);
	if (pParentWnd != NULL)
		ASSERT_VALID(pParentWnd);

	if (hInst == NULL)
		hInst = AfxGetInstanceHandle();

#ifndef _AFX_NO_OCC_SUPPORT
	_AFX_OCC_DIALOG_INFO occDialogInfo;
	COccManager* pOccManager = afxOccManager;
#endif

	HGLOBAL hTemplate = NULL;

	HWND hWnd = NULL;
#ifdef _DEBUG
	DWORD dwError = 0;
#endif

	TRY
	{
		VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
		AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);

#ifndef _AFX_NO_OCC_SUPPORT
		// separately create OLE controls in the dialog template
		if (pOccManager != NULL)
		{
			if (!SetOccDialogInfo(&occDialogInfo))
				return FALSE;

			lpDialogTemplate = pOccManager->PreCreateDialog(&occDialogInfo,
				lpDialogTemplate);
		}

		if (lpDialogTemplate == NULL)
			return FALSE;
#endif //!_AFX_NO_OCC_SUPPORT

		// If no font specified, set the system font.
		CString strFace;
		WORD wSize = 0;
		BOOL bSetSysFont = !CDialogTemplate::GetFont(lpDialogTemplate, strFace,
			wSize);

		// On DBCS systems, also change "MS Sans Serif" or "Helv" to system font.
		if ((!bSetSysFont) && GetSystemMetrics(SM_DBCSENABLED))
		{
			bSetSysFont = (strFace == _T("MS Shell Dlg") ||
				strFace == _T("MS Sans Serif") || strFace == _T("Helv"));
			if (bSetSysFont && (wSize == 8))
				wSize = 0;
		}

		if (bSetSysFont)
		{
			CDialogTemplate dlgTemp(lpDialogTemplate);
			dlgTemp.SetSystemFont(wSize);
			hTemplate = dlgTemp.Detach();
		}

		if (hTemplate != NULL)
			lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate);

		// setup for modal loop and creation
		m_nModalResult = -1;
		m_nFlags |= WF_CONTINUEMODAL;

		// create modeless dialog
		AfxHookWindowCreate(this);
		hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
			pParentWnd->GetSafeHwnd(), AfxDlgProc);
#ifdef _DEBUG
		dwError = ::GetLastError();
#endif
	}
	CATCH_ALL(e)
	{
		DELETE_EXCEPTION(e);
		m_nModalResult = -1;
	}
	END_CATCH_ALL

#ifndef _AFX_NO_OCC_SUPPORT
	if (pOccManager != NULL)
	{
		pOccManager->PostCreateDialog(&occDialogInfo);
		if (hWnd != NULL)
			SetOccDialogInfo(NULL);
	}
#endif //!_AFX_NO_OCC_SUPPORT

	if (!AfxUnhookWindowCreate())
		PostNcDestroy();        // cleanup if Create fails too soon

	// handle EndDialog calls during OnInitDialog
	if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
	{
		::DestroyWindow(hWnd);
		hWnd = NULL;
	}

	if (hTemplate != NULL)
	{
		GlobalUnlock(hTemplate);
		GlobalFree(hTemplate);
	}

	// help with error diagnosis (only if WM_INITDIALOG didn't EndDialog())
	if (hWnd == NULL && (m_nFlags & WF_CONTINUEMODAL))
	{
#ifdef _DEBUG
#ifndef _AFX_NO_OCC_SUPPORT
		if (afxOccManager == NULL)
		{
			TRACE0(">>> If this dialog has OLE controls:\n");
			TRACE0(">>> AfxEnableControlContainer has not been called yet.\n");
			TRACE0(">>> You should call it in your app's InitInstance function.\n");
		}
		else if (dwError != 0)
		{
			TRACE1("Warning: Dialog creation failed!  GetLastError returns 0x%8.8X\n", dwError);
		}
#endif //!_AFX_NO_OCC_SUPPORT
#endif //_DEBUG
		return FALSE;
	}

	ASSERT(hWnd == m_hWnd);
	return TRUE;
}