初学VC得困惑

seilfer2000 2003-09-11 02:22:09
BOOL CSpecialFileDialog::OnInitDialog()
{
BOOL bRet = CFileDialog::OnInitDialog();
if (bRet == TRUE) {
GetParent()->GetDlgItem(IDOK)->SetWindowText("Delete");
}
return bRet;
}
这段程序把一个FILEDIALOG上面得按钮换成了DELETE 我不明白BOOL
bRet = CFileDialog::OnInitDialog();
if (bRet == TRUE) {
是做什么用得?

MSDN: 我没理解这段话
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.


...全文
294 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
seilfer2000 2003-09-15
  • 打赏
  • 举报
回复
1
nirovf 2003-09-14
  • 打赏
  • 举报
回复
aa
seilfer2000 2003-09-11
  • 打赏
  • 举报
回复
up
seilfer2000 2003-09-11
  • 打赏
  • 举报
回复
可是 if (bRet == TRUE) 应该和初始化没关系吧

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.
flinming 2003-09-11
  • 打赏
  • 举报
回复
应该就是初始化成功才做setwindowtext的事情。。。
seilfer2000 2003-09-11
  • 打赏
  • 举报
回复
如果OnInitDialog返回值为非零,Windows将输入焦点置于对话框内的第一个控件上
只有当应用程序将输入焦点置于对话框内的某一个控件上时,应用程序返回0.

BOOL bRet = CFileDialog::OnInitDialog();
if (bRet == TRUE) {
GetParent()->GetDlgItem(IDOK)->SetWindowText("Delete");
}
return bRet;
搞不懂,它是怎么通过返回值判断第一次打开得。 如果是停留在第一个控件上就改变,但是
你打开以后还有可能让焦点停留在第一个控件上啊,那不是还要写一次??
seilfer2000 2003-09-11
  • 打赏
  • 举报
回复
不是垃圾啊,是VC技术内幕上得
gamestory 2003-09-11
  • 打赏
  • 举报
回复
CSpecialFileDialog是从CFileDialog类继承下来的,在CSpecialFileDialog的初始化过程中,先调用CFileDialog的初始化例程(显然必须调用CFileDialog的初始化,才能建立一个文件对话框),如果成功,才能获得文件框上的IDOK按钮,才能修改成为DELETE
oliverlin 2003-09-11
  • 打赏
  • 举报
回复
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.
如果OnInitDialog返回值为非零,Windows将输入焦点置于对话框内的第一个控件上.

The application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.
只有当应用程序将输入焦点置于对话框内的某一个控件上时,应用程序返回0.
Rainee 2003-09-11
  • 打赏
  • 举报
回复
楼上的从字面上看,说得没错。

不过这段代码真的很奇怪,干嘛无端端要调用CFileDialog::OnInitDialog()?

楼主这段代码你从哪里得到的?感觉像垃圾……要不就是我不懂。
bcpl 2003-09-11
  • 打赏
  • 举报
回复
如果对话框默认的初始化动作成功,就改按钮的标题,如果不成功,就别改了

16,467

社区成员

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

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

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