📄 subject_53490.htm
字号:
<p>
序号:53490 发表者:郑中 发表日期:2003-09-19 23:01:02
<br>主题:请看看这代码!!错在哪里??
<br>内容:////////////////////////////////////////////////////////////////////////////<BR>// CFontDlg message handlers<BR><BR>BOOL CFontDlg::OnInitDialog() <BR>{<BR> CDialog::OnInitDialog();<BR> <BR> // TODO: Add extra initialization here<BR> CenterWindow();<BR> CFontApp * app=(CFontApp *)AfxGetApp();<BR> CFont * font=app->GetCurrentFont();<BR> if(font==NULL) <BR> return TRUE;<BR> FARPROC proc=MakeProcInstance((FARPROC)SetFontProc,AfxGetInstanceHandle());<BR> EnumChildWindows(m_hWnd,(WNDENUMPROC)proc,(LPARAM)font->m_hObject);<BR> FreeProcInstance(proc);<BR><BR> return TRUE; // return TRUE unless you set the focus to a control<BR> // 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> SendMessage(hWnd,WM_SETFONT,(WPARAM)font,<BR> (LPARAM)MAKELONG((WORD)TRUE,0));<BR><BR> 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> 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 + -