⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_53490.htm

📁 vc
💻 HTM
字号:
<p>
序号:53490 发表者:郑中 发表日期:2003-09-19 23:01:02
<br>主题:请看看这代码!!错在哪里??
<br>内容:////////////////////////////////////////////////////////////////////////////<BR>// CFontDlg message handlers<BR><BR>BOOL CFontDlg::OnInitDialog() <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;CDialog::OnInitDialog();<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;// TODO: Add extra initialization here<BR>&nbsp;&nbsp;&nbsp;&nbsp;CenterWindow();<BR>&nbsp;&nbsp;&nbsp;&nbsp;CFontApp * app=(CFontApp *)AfxGetApp();<BR>&nbsp;&nbsp;&nbsp;&nbsp;CFont * font=app-&gt;GetCurrentFont();<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(font==NULL) <BR>&nbsp;&nbsp;&nbsp;&nbsp;return TRUE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;FARPROC proc=MakeProcInstance((FARPROC)SetFontProc,AfxGetInstanceHandle());<BR>&nbsp;&nbsp;&nbsp;&nbsp;EnumChildWindows(m_hWnd,(WNDENUMPROC)proc,(LPARAM)font-&gt;m_hObject);<BR>&nbsp;&nbsp;&nbsp;&nbsp;FreeProcInstance(proc);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;return TRUE;&nbsp;&nbsp;// return TRUE unless you set the focus to a control<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// EXCEPTION: OCX Property Pages should return FALSE<BR>}<BR><BR>BOOL CFontDlg::SetFontProc(HWND hWnd, LPARAM lParam)<BR>{<BR>HFONT font=(HFONT)lParam;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(hWnd,WM_SETFONT,(WPARAM)font,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(LPARAM)MAKELONG((WORD)TRUE,0));<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;return TRUE;<BR>}<BR><BR>提示错误::<BR>FontDlg.cpp<BR>H:\study\Font\FontDlg.cpp(54) : error C2440: 'type cast' : cannot convert from '' to 'int (__stdcall *)(void)'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;None of the functions with this name in scope match the target type<BR>H:\study\Font\FontDlg.cpp(67) : error C2660: 'SendMessageA' : function does not take 4 parameters<BR>Error executing cl.exe.<BR><BR>Font.exe - 2 error(s), 0 warning(s)<BR>第一个错误指---FARPROC proc=MakeProcInstance((FARPROC)SetFontProc,AfxGetInstanceHandle());
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:iamhere 回复日期:2003-09-19 23:39:14
<br>内容:第一个Error表示要求SetFontProc这个函数或者为全局函数或者为类的静态函数<BR><BR>第二个Error是因为默认SendMessage作为CDialog的成员函数调用,而该成员函数只需三个参数。改为::SendMessage(hWnd,WM_SETFONT,(WPARAM)font,(LPARAM)MAKELONG((WORD)TRUE,0));<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:郑中 回复日期:2003-09-20 00:05:11
<br>内容:谢谢你!!现在可以了!!但是你可不可以说详细点!!或者是有什么资料介绍!!回为我还是不明白为什么要这样改!?!谢谢!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -