Ejemplo n.º 1
0
BOOL CDialog::CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
	void* lpDialogInit, HINSTANCE hInst)
{
	ASSERT(lpDialogTemplate != NULL);

	if (pParentWnd == NULL)
		pParentWnd = AfxGetMainWnd();
	m_lpDialogInit = lpDialogInit;

	return CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInst);
}
Ejemplo n.º 2
0
BOOL CXTPPropertyPage::CreatePage(CWnd* pParentWnd)
{
	if (GetSafeHwnd())
		return TRUE;

	HGLOBAL hTemplate = NULL;
	HINSTANCE hInstance = NULL;

	if (!LoadTemplate(hTemplate, hInstance))
		return FALSE;

	if (!hTemplate)
		return FALSE;

	DLGTEMPLATE* lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate);
	if (!lpDialogTemplate)
		return FALSE;

	DLGEXTEMPLATE* lpDialogExTemplate = (DLGEXTEMPLATE*)lpDialogTemplate;

	DWORD lSaveStyle;
	if (lpDialogExTemplate->wSignature == 0xFFFF)
		lSaveStyle = lpDialogExTemplate->dwStyle;
	else
		lSaveStyle = lpDialogTemplate->style;

	DWORD dwNewStyle = (lSaveStyle & (DS_LOCALEDIT | WS_CLIPCHILDREN | DS_SETFONT | DS_FIXEDSYS))
		| WS_CHILD | WS_TABSTOP | DS_3DLOOK | DS_CONTROL;

	if (lpDialogExTemplate->wSignature == 0xFFFF)
		lpDialogExTemplate->dwStyle = dwNewStyle;
	else
		lpDialogTemplate->style = dwNewStyle;

	BOOL bResult = CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInstance);

	CSize sz;
	CXTPWindowRect rc(this);
	m_totalDev = rc.Size();

	m_bCreated = TRUE;


	GlobalUnlock(hTemplate);
	GlobalFree(hTemplate);

	return bResult;
}
Ejemplo n.º 3
0
BOOL CRuntimeDlg::Create(LPCTSTR szCaption, DWORD dwStyle, DWORD dwExStyle, const CRect& rect, CWnd* pParentWnd, UINT nID)
{
	// cache and remove visibility
	BOOL bVisible = (dwStyle & WS_VISIBLE);
	dwStyle &= ~WS_VISIBLE;
	
	// remove DS_SETFONT (not supported)
	dwStyle &= ~DS_SETFONT;
	
	if (dwStyle & WS_CHILD)
	{
		dwStyle |= DS_CONTROL;
		dwExStyle |= WS_EX_CONTROLPARENT;
	}
	
	// create modeless dialog
	AfxHookWindowCreate(this);
	
	if (CreateDlgIndirect(RTDLGTEMPLATE(dwStyle, dwExStyle, rect), pParentWnd, NULL) != NULL)
	{
		// notify parent if we're a child window
		if (pParentWnd && (dwStyle & WS_CHILD) && !(dwExStyle & WS_EX_NOPARENTNOTIFY))
			pParentWnd->SendMessage(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, nID), (LPARAM)GetSafeHwnd());

		SetInitialPos(rect, dwStyle);
		
		// set window text
		SetWindowText(szCaption);
		
		// set control id
		SetDlgCtrlID(nID);
		
		PostCreate(); // for derived classes
		
		// reshow?
		if (bVisible)
			ShowWindow(SW_SHOW);
		
		return TRUE;
	}
	
	return FALSE;
}
Ejemplo n.º 4
0
BOOL CFilePreviewDlg::Create()
{
	ASSERT( m_hWnd == NULL );
	ASSERT( m_pDownload != NULL );
	
	LPCTSTR lpszTemplateName = MAKEINTRESOURCE( IDD );
	
	HINSTANCE hInst		= AfxFindResourceHandle( lpszTemplateName, RT_DIALOG );
	HRSRC hResource		= ::FindResource( hInst, lpszTemplateName, RT_DIALOG );
	HGLOBAL hTemplate	= LoadResource( hInst, hResource );
	
	LPCDLGTEMPLATE lpDialogTemplate = (LPCDLGTEMPLATE)LockResource( hTemplate );
	
	BOOL bResult = CreateDlgIndirect( lpDialogTemplate, NULL, hInst );
	
	UnlockResource( hTemplate );
	FreeResource( hTemplate );
	
	return bResult;
}
Ejemplo n.º 5
0
BOOL CWnd::CreateDlg(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
	// load resource
	LPCDLGTEMPLATE lpDialogTemplate = NULL;
	HGLOBAL hDialogTemplate = NULL;
	HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
	HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
	hDialogTemplate = LoadResource(hInst, hResource);
	if (hDialogTemplate != NULL)
		lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
	ASSERT(lpDialogTemplate != NULL);

	// create a modeless dialog
	BOOL bSuccess = CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInst);

	// free resource
	UnlockResource(hDialogTemplate);
	FreeResource(hDialogTemplate);

	return bSuccess;
}
Ejemplo n.º 6
0
BOOL CDownloadMonitorDlg::CreateReal(UINT nID)
{
	LPCTSTR lpszTemplateName = MAKEINTRESOURCE( nID );
	BOOL bResult = FALSE;
	HINSTANCE hInst		= AfxFindResourceHandle( lpszTemplateName, RT_DIALOG );
	HRSRC hResource		= ::FindResource( hInst, lpszTemplateName, RT_DIALOG );
	if ( hResource )
	{
		HGLOBAL hTemplate = LoadResource( hInst, hResource );
		if ( hTemplate )
		{
			LPCDLGTEMPLATE lpDialogTemplate = (LPCDLGTEMPLATE)LockResource( hTemplate );
			if ( lpDialogTemplate )
			{
				bResult = CreateDlgIndirect( lpDialogTemplate, NULL, hInst );
			}
			FreeResource( hTemplate );
		}
	}
	return bResult;
}
Ejemplo n.º 7
0
// Copied from MFC sources to enable a call to our CreateDlgIndirect()
BOOL BaseDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
  m_lpszTemplateName = lpszTemplateName;
  if (IS_INTRESOURCE(m_lpszTemplateName) && m_nIDHelp == 0)
    m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);

  HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
  HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
  HGLOBAL hTemplate = LoadResource(hInst, hResource);
  LPCDLGTEMPLATE lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hTemplate);

  if (pParentWnd == NULL)
    pParentWnd = AfxGetMainWnd();
  m_lpDialogInit = NULL;
  BOOL bResult = CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInst);

  UnlockResource(hTemplate);
  FreeResource(hTemplate);

  return bResult;
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
0
// for backward compatibility
BOOL CWnd::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd)
{
	return CreateDlgIndirect(lpDialogTemplate, pParentWnd, NULL);
}
Ejemplo n.º 10
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;
}