Exemplo n.º 1
0
void CFontasticDlg::OnChoosefont() 
{
	CFontDialog dlgTemp(&gFont, CF_EFFECTS | CF_SCREENFONTS, NULL, this);

	dlgTemp.DoModal();

	CStatic *pStatic = (CStatic *)GetDlgItem(IDC_PREVIEW);

	Invalidate();
}
Exemplo n.º 2
0
BOOL CXTPPropertyPage::LoadTemplate(HGLOBAL& hTemplate, HINSTANCE& hInst)
{
	hTemplate = 0;
	hInst = AfxGetInstanceHandle();

	if ((m_psp.dwFlags & PSP_DLGINDIRECT) && m_psp.pResource)
	{
		CDialogTemplate dlgTemp((LPCDLGTEMPLATE)m_psp.pResource);
		hTemplate = dlgTemp.Detach();
	}
	else
	{

		hInst = AfxFindResourceHandle(m_psp.pszTemplate, RT_DIALOG);
		if (!hInst)
			return FALSE;

		HRSRC hResource = ::FindResource(hInst, m_psp.pszTemplate, RT_DIALOG);
		if (!hResource)
			return FALSE;

		hTemplate = LoadResource(hInst, hResource);
		if (!hTemplate)
			return FALSE;

		DLGTEMPLATE* pTemplate = (DLGTEMPLATE*)LockResource(hTemplate);

		CDialogTemplate dlgTemp(pTemplate);

		UnlockResource(hTemplate);
		FreeResource(hTemplate);

		hTemplate = dlgTemp.Detach();
	}
	return TRUE;

}
Exemplo n.º 3
0
BOOL BaseDialog::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd, HINSTANCE hInst)
{
  if(!hInst)
    hInst = AfxGetResourceHandle();

  HGLOBAL hTemplate = NULL;
  HWND hWnd = NULL;

  TRY
  {
    CDialogTemplate dlgTemp(lpDialogTemplate);
    SetFont(dlgTemp);
    hTemplate = dlgTemp.Detach();
    lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate);

    m_nModalResult = -1;
    m_nFlags |= WF_CONTINUEMODAL;

    AfxHookWindowCreate(this);
    hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
      pParentWnd->GetSafeHwnd(), AfxDlgProc);
  }
  CATCH_ALL(e)
  {
    e->Delete();
    m_nModalResult = -1;
  }
  END_CATCH_ALL

  if (!AfxUnhookWindowCreate())
    PostNcDestroy();

  if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
  {
    ::DestroyWindow(hWnd);
    hWnd = NULL;
  }

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

  if (hWnd == NULL)
    return FALSE;
  return TRUE;
}
Exemplo n.º 4
0
BOOL CXTPPropertyPage::LoadTemplate()
{
	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;

	BOOL bDialogEx = lpDialogExTemplate->wSignature == 0xFFFF;

	m_lineDev = CXTPDrawHelpers::Dlu2Pix(5, 5);

	if ((m_psp.dwFlags & PSP_USETITLE) == 0)
	{
		WORD* lpTitle = bDialogEx ? (WORD*)(lpDialogExTemplate + 1) : (WORD*)(lpDialogTemplate + 1);

		if (*lpTitle == (WORD)-1)        // Skip menu name string or ordinal
			lpTitle += 2;
		else
			while(*lpTitle++);

		if (*lpTitle == (WORD)-1)        // Skip class name string or ordinal
			lpTitle += 2;
		else
			while(*lpTitle++);

		m_strCaption = CString((LPWSTR)lpTitle);
	}

	CDialogTemplate dlgTemp(hTemplate);
	dlgTemp.GetSizeInPixels(&m_totalDev);

	GlobalUnlock(hTemplate);
	GlobalFree(hTemplate);

	return TRUE;
}
Exemplo n.º 5
0
void CFontasticDlg::OnSaveas() 
{
	static char BASED_CODE szFilter[] = "Homeworld Font Files (*.hff)|*.hff|All Files (*.*)|*.*||";
	char *tempFileName;

	tempFileName = FixFontName(&gFont);
	
	CFileDialog dlgTemp(FALSE, ".HFF", tempFileName, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, szFilter, this);

	delete tempFileName;

	int nResult = dlgTemp.DoModal();

	if(nResult == IDOK)
	{
		// Save the file here.
		CString strTemp = dlgTemp.GetFileName();

		SaveFontFile(strTemp);
		
		CDialog::OnOK();
	}
}
Exemplo n.º 6
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;
}