예제 #1
0
void mydialog::sfont()
{
    CFontDialog dlg;
    CString str;
    int size;
    long style;

    CFont ff;
    int i=dlg.DoModal();
    if(i==IDCANCEL)
        return;
    str=dlg.GetFaceName();

    size=dlg.GetSize();


    LOGFONT lf;
    lf.lfHeight =dlg.GetSize();

    memset(&lf,0,sizeof lf);


    str=dlg.GetFaceName();
    if(dlg.IsItalic())
        lf.lfItalic =1;

    if(dlg.IsUnderline())
        lf.lfUnderline=1;

    if(dlg.IsBold())
        lf.lfWeight=700;

    if(dlg.IsStrikeOut())
        lf.lfStrikeOut=1;

    lf.lfHeight =size/10+10;


    char s[32]="Arial";
    strcpy(lf.lfFaceName,str);

    ff.CreateFontIndirect(&lf);

    e1.SetWindowText("dfdfsdfsfsd");
    e1.SetFont(&ff);

}
예제 #2
0
void CfgAppearanceFontDlg::OnCustomFontTextBrowse(void) 
{
    xpr_tchar_t sFont[MAX_FONT_TEXT + 1] = {0};
    GetDlgItemText(IDC_CFG_FONT_CUSTOM_FONT_TEXT, sFont, MAX_FONT_TEXT);

    LOGFONT sLogFont = {0};
    StringToLogFont(sFont, sLogFont);

    CFontDialog sDlg;
    sDlg.m_cf.Flags &= ~CF_EFFECTS;
    sDlg.m_cf.Flags |= CF_INITTOLOGFONTSTRUCT;
    memcpy(sDlg.m_cf.lpLogFont, &sLogFont, sizeof(LOGFONT));
    if (sDlg.DoModal() == IDOK)
    {
        xpr_tchar_t sText[MAX_FONT_TEXT + 1] = {0};
        FontDlgToString(sDlg.GetFaceName(), sDlg.GetSize(), sDlg.GetWeight(), sDlg.IsItalic(), sDlg.IsStrikeOut(), sDlg.IsUnderline(), sText);

        SetDlgItemText(IDC_CFG_FONT_CUSTOM_FONT_TEXT, sText);

        setModified();
    }
}