哪位大神能帮帮我

覃煜 2014-04-12 09:44:38
void CMyFontDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//MessageBeep((WORD)-1);
//device context for painting
CPaintDC dc(this);
//Update control's variables
UpdateData(TRUE);
//Set the background mode to transparent
dc.SetBkMode(TRANSPARENT);
//Create a font object
CFont MyFont;
MyFont.CreateFont(25+25*m_SizeRadio,
0,
0,
0,
400,
FALSE,
FALSE,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS,
" ");
HWND hW=::GetFocus();
HDC hdc=::GetDC(hW);
LOGFONT lf;
memset(&lf,0,sizeof(lf));
lf.lfCharSet = CHINESEBIG5_CHARSET; //如果该值为DEFAULT_CHARSET将会列出所有字体
lf.lfFaceName = " ";
lf.lfPitchAndFamily = 0;
EmunFontFamiliesEx(hdc,&lf,myEnumFontFamExProc,0,0);
int CALLBACK myEnumFontFamExProc(ENUMLOGFONTEX
*lpelfe,NEWTEXTMETRICEX *lpntme, int FontType,LPARAM lParam)
{
TRACE("font family name\n",lpelfe->elfLogFont.lfFaceName);
//将该字体LOGFONT或是FaceName保存到自己的数据中
}




//Select the new font object
CFont * pOldFont=dc.SelectObject(&MyFont);
if(m_ShadowCheck==TRUE)
{
//Set the color of the text
dc.SetTextColor(RGB(255,0,0));
//Draw the text
dc.TextOut(150,120,m_DataEdit);
}

//Set the color of the text
dc.SetTextColor(RGB(0,255,0));
//Draw the text
dc.TextOut(150+10,120+10,m_DataEdit);
//Select the old font
dc.SelectObject(pOldFont);
CDialog::OnPaint();
}
}



--------------------Configuration: MyFont - Win32 Debug--------------------
Compiling...
MyFontDlg.cpp
E:\VC\备用\MyFont好\MyFontDlg.cpp(203) : error C2440: '=' : cannot convert from 'char [2]' to 'char [32]'
There is no context in which this conversion is possible
E:\VC\备用\MyFont好\MyFontDlg.cpp(205) : error C2064: term does not evaluate to a function
E:\VC\备用\MyFont好\MyFontDlg.cpp(208) : error C2601: 'myEnumFontFamExProc' : local function definitions are illegal
Error executing cl.exe.
...全文
127 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
覃煜 2014-04-13
  • 打赏
  • 举报
回复
具体怎么改呀
覃煜 2014-04-13
  • 打赏
  • 举报
回复
能告诉我具体在哪吗,本人是个菜鸟
覃煜 2014-04-13
  • 打赏
  • 举报
回复
这是我抄写别人的程序的,我本来想通过按钮来切换字体的,好像得用什么EmunFontFamiliesEx函数和回调函数
叶恭介叶恭介 2014-04-13
  • 打赏
  • 举报
回复
(1)lf.lfFaceName = " ";改成strcpy_s(lf.lfFaceName,_T("宋体"));,因为不能简单的用"="赋值 (2)int CALLBACK myEnumFontFamExProc(ENUMLOGFONTEX *lpelfe,NEWTEXTMETRICEX *lpntme, int FontType,LPARAM lParam) { TRACE("font family name\n",lpelfe->elfLogFont.lfFaceName); //将该字体LOGFONT或是FaceName保存到自己的数据中 } 上面这是一个函数的定义为的,你怎么放在函数的中间呢,应该放在外面,天啊,你有很多不会的啊
叶恭介叶恭介 2014-04-12
  • 打赏
  • 举报
回复
203行错了,改改就行了
oyljerry 2014-04-12
  • 打赏
  • 举报
回复
基本语法错误,自己修改一下

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧