在MFC中的子对话框中设置SetFocus [英] SetFocus in the Child Dialog in MFC

查看:737
本文介绍了在MFC中的子对话框中设置SetFocus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有CDialog ModelDialog应用程序,说ParentDialog'A',对话'A'创建子对话'B'。 

我点击另一个应用程序,然后打开'B'。但焦点不在Dialog.I需要点击"B"上的某个地方。

无需点击任何地方我如何设置焦点。



在Child对话框中,我有一个按钮,当用户将光标移到按钮上时,它会显示工具提示。

但是,当我点击其他应用程序并进入此应用程序时,未设置焦点。



我发现了一个例子,我正在寻找你的解释[附件是没有工具提示的例子]。

在附件中你可以获得Model Dialog的代码。在这个应用程序中,在第二个窗口中假设我已经包含了按钮的工具提示(取消)。
它正在工作。但是,当我点击另一个应用程序并来到这个应用程序焦点不在应用程序中。我需要将焦点设置在窗口上。所以当我将光标移到按钮上时,工具提示应该显示。我试图设置焦点。但它集中了
。我附上了我的附件


Hi,
I have the CDialog ModelDialog Application , say ParentDialog 'A', and Dialog 'A' creates Child Dialog 'B'. 
I click on another application and then open the 'B'.But focus is not in the Dialog.I need to click on somewhere on the 'B'.
Without clicking anywhere how do i set the focus.

In the Child Dialog, I have the button which will display the Tooltips when the user move the cursor over the button.
But when i click on the other application and come to this application, Focus is not set.

I found out the example which is exactly I am looking to explain you[Attachment which is example without tooltip ].
In the attachment you can get the code for Model Dialog. In this app, in the second window lets assume I have included the tool-tip for the button(Cancel). It is working.But when i click on another application and come this application Focus is not in the application. I need to set the focus on the window.so when i move the cursor over the button, Tooltip should display. I tried to set the focus.But it is focusing .I enclosed my attachment

因为我不知道如何附加Zip文件,所以我提到了URL"在这个URL中"http://www.codersource.net/2010/01/30/ dialog-boxes-in-mfc /" "
在这个网址,下页,你可以从下页下载代码

since I am not sure how to attach the Zip file, I mention the URL "In this URL "http://www.codersource.net/2010/01/30/dialog-boxes-in-mfc/"" In this url, down page you can download the code from the down page

问候,

Senthil

Regards,
Senthil

推荐答案

你好 Senthil Andavan,

感谢您在这里发帖。

>>在孩子对话框,我有一个按钮,当用户将光标移到按钮上时,它会显示工具提示。

但是当我点击其他应用程序并进入此应用程序时,焦点未设置。

在我看来,当您使用DoModal激活子对话框时,父对话框将失去焦点。当您从另一个对话框返回应用程序时应用程序,它将侧重于父对话框,而不是子对话框。

In my opinion, when you use DoModal to active a child dialog, the parent dialog will lose the focus. When you got back to application from another application, it will focus on parent dialog, not the child dialog.

也许您可以尝试以下方式。

Maybe you could try these ways below.

1. 使用无模式对话框或弹出对话框。

1. Use a modeless dialog or pop up dialog.

2. 处理WM_ACTIVE消息时,使用SW_SHOW或SW_SHOWNORMAL命令调用ShowWindow。

2. When you handle WM_ACTIVE message , call ShowWindow with SW_SHOW or SW_SHOWNORMAL command.

3。你处理WM_ACTIVE消息,用HWND_TOPMOST调用SetWindowPos命令。

3. When you handle WM_ACTIVE message, call SetWindowPos with the HWND_TOPMOST command.

希望这对你有帮助。

最好的问候,

Sera Yu

Best Regards,
Sera Yu


这篇关于在MFC中的子对话框中设置SetFocus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆