救救我吧!GG,JJ,DD,MM们!!

vc_lover_2002 2002-10-04 09:04:33
各位你们好:
小弟初学VC,有两个问题,恳请诸位不吝加以赐教,小汪在此先谢过!!!
一般,一个对话框的初始化函数中最后一句话是什么意思?
BOOL CDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//TODO:Add extra initialization here


return TRUE;//return TRUE unless you set the focus to a control
}
我想问return TRUE;//return TRUE unless you set the focus to a control
这一句话是什么意思,能不能把此句删除掉?这一句话有什么作用呢?

而在创建工具栏时函数OnCreate()中最后一句却是return 0;请问这又是什么意思?如下所示:
int CMainFrame;;OnCreate(LPCREATESTRUCT lpCreateStruct)
{
........
m_wndToolBar.EnableDocking(CBRS_ALIRN_ANY);
EnableDocking(CBRS_ALIRN_ANY);
DockControlBar(&EnableDocking);
return 0;
}

return 0;这一句话有什么作用呢?能不能删除呢?
诸位,拜托了!!!!!
...全文
94 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
mooncat2000 2002-10-05
  • 打赏
  • 举报
回复
我也想说啊,怎么办啊
findmylover 2002-10-05
  • 打赏
  • 举报
回复
都被你们说完了~

UP
findmylover 2002-10-05
  • 打赏
  • 举报
回复
没的说了~
都被你们说完了!~

UP
zyoujie 2002-10-05
  • 打赏
  • 举报
回复
up
sunzm 2002-10-05
  • 打赏
  • 举报
回复
在WIN2K下,默认的字符形式是UNICODE,但在WIN98下,默认的是单字节模式,所以,为了程序兼容,就有了如下宏:
#ifdef _UNICODE
typedef wchar_t TCHAR
#else
typedef char TCHAR
#.......
就是说,如果你定义了_UNICODE,(在编译器中定义),那么TCAHR就是UNICODE字符串,否则就是普通的char
vc_lover_2002 2002-10-04
  • 打赏
  • 举报
回复
我还有一个问题:
就是TCHAR 和CHAR 有什么区别和联系呢?
kwiner 2002-10-04
  • 打赏
  • 举报
回复
上面都说了,我都没得说了
sidewalk 2002-10-04
  • 打赏
  • 举报
回复
呵呵,你干嘛要返回1呢?MSDN上说得很明白must return 0才能继续执行,不过你可以试一试返回1的效果,看看程序的结果不就很容易得出答案了吗?而且这样记忆深刻。
vc_lover_2002 2002-10-04
  • 打赏
  • 举报
回复
SS15(8K99)你好:
OnCreate()能不能返回1呢?
sunzm 2002-10-04
  • 打赏
  • 举报
回复
BOOL CDialog::OnInitDialog()
{
CDialog::OnInitDialog();
//TODO:Add extra initialization here


return TRUE;//return TRUE unless you set the focus to a control
}
函数定义为BOOL型,没有return能行吗?return TRUE表示初始化成功。
问题二同意楼上的说法
SGUav 2002-10-04
  • 打赏
  • 举报
回复
看 MSDN 中对 OnInitDialog 的描述

CDialog::OnInitDialog
virtual BOOL OnInitDialog( );

Return Value

Specifies whether the application has set the input focus to one of the controls in the dialog box. If OnInitDialog returns nonzero, Windows sets the input focus to the first control in the dialog box. The application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.

返回非零,在第一个控件上设置输入焦点
返回零,明确地在对话框上的某一个控件上设置输入焦点

OnCreate() 的返回值:

CWnd::OnCreate
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );

Return Value

OnCreate must return 0 to continue the creation of the CWnd object. If the application returns –1, the window will be destroyed.


rivershan 2002-10-04
  • 打赏
  • 举报
回复
必须返回值的~
其它的楼上已经说的很清楚了~
everandforever 2002-10-04
  • 打赏
  • 举报
回复
TCHAR是针对UNICODE的宽字符,两字节.

16,550

社区成员

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

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

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