-
June 30th, 2017, 08:38 AM
#1
Set the ChildDialog Window Focus when i go to another application and come here
Hi Team,
please help me on how to set the focus for the Child Dialog Window
I have CDialog. In this i have couple of Tool bar [ File, Edit, Options, Tool,help]
Out of all these option,I clicked on Tool->Display panel.
Now Display Panel small Dialog pops-up.In this window there are static controls are available.
(Reset,Draw buttons). when I hover the cursor on the Reset button "Tool-tip" should display.It's happening.
In the "Display panel" dialog i have written the code SetActiveWindow function to activate the dialog. Now if i minimize and maximize the window,
the main Dialog is visible.But the "Display Panel" is hidden. This is where i am facing the problem. In this case, SetActiveWindow function is applied to the parent window.But i need to set child window as active window.
Regards,
Senthil
-
July 1st, 2017, 12:16 PM
#2
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by SAP_7
...
Out of all these option,I clicked on Tool->Display panel.
Now Display Panel small Dialog pops-up.
...
In the "Display panel" dialog i have written the code SetActiveWindow function to activate the dialog.
Does it mean that "Display panel" dialog is a modless one?
Victor Nijegorodov
-
July 2nd, 2017, 01:10 PM
#3
Re: Set the ChildDialog Window Focus when i go to another application and come here
Thank you for your reply Victor . I am not sure what is model and modeless Dialog.Anyway by referring this site http://www.codersource.net/2010/01/3...-boxes-in-mfc/ I got to know that "The difference between a modal and modeless dialog box is that, modal dialogs once invoked will not allow the users to access the parent window, where as modeless dialogs will allow the user to work with the parent window. "
My Application is Model Dialog since Parent window(Display panel) will not be able to access when child window is open.
I found out the example code in this site [http://www.codersource.net/2010/01/3...-boxes-in-mfc/] which is exactly I am looking to explain you.
In this application , in the children lets assume I have included the tooltip for the button(Cancel). It is working.
But when i click on another application and come this application Focus is not on the child window of the application. I need to set the focus on the child window and when i move the cursor over the button, Tooltip should display. I tried to set the focus to child window.But it is focusing the parent window.
Regards,
Senthil
-
July 2nd, 2017, 01:48 PM
#4
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by SAP_7
Thank you for your reply Victor . I am not sure what is model and modeless Dialog.Anyway by referring this site http://www.codersource.net/2010/01/3...-boxes-in-mfc/ I got to know that "The difference between a modal and modeless dialog box is that, modal dialogs once invoked will not allow the users to access the parent window, where as modeless dialogs will allow the user to work with the parent window. " ...
OK, let's try it from the "other side": please, show us the code you are using to spawn this "Display Panel" dialog.
Victor Nijegorodov
-
July 3rd, 2017, 12:03 AM
#5
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by VictorN
OK, let's try it from the "other side": please, show us the code you are using to spawn this "Display Panel" dialog.
I guess i could not share the code of "Display Panel" dialog with you. But you can get the application from the following link.In this Link you can download the application and try to set the focus on the child window. [For instance Cancel button]
https://cboard.cprogramming.com/cplu...-come-mfc.html
-
July 3rd, 2017, 08:55 AM
#6
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by SAP_7
I guess i could not share the code of "Display Panel" dialog with you. ...
But I didn't ask you to "share the code of "Display Panel" dialog", just only the code used to spawn this dialog!
Hint: are you using CDialog::DoModal or CDialog::Create?
Victor Nijegorodov
-
July 3rd, 2017, 11:26 AM
#7
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by VictorN
But I didn't ask you to " share the code of "Display Panel" dialog", just only the code used to spawn this dialog!
Hint: are you using CDialog::DoModal or CDialog::Create?
Neither we are using CDialog:oModal nor CDialog::Create.
If I am not wrong , "Code of Display Panel to spawn this dialog" may be in OnInitDialog
-
July 3rd, 2017, 01:44 PM
#8
Re: Set the ChildDialog Window Focus when i go to another application and come here
Victor Nijegorodov
-
July 3rd, 2017, 01:51 PM
#9
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by SAP_7
I guess i could not share the code of "Display Panel" dialog with you. But you can get the application from the following link.In this Link you can download the application and try to set the focus on the child window. [For instance Cancel button]
https://cboard.cprogramming.com/cplu...-come-mfc.html
If you want to have someone look at the code, please zip it up and attach it directly. We're willing to help, but most folks here are not willing take the risk of going to an unknown site for a download.
At any rate, Victor has asked you for the specific code that creates the dialog.
Can you take the time to post that bit of code here?
Last edited by Arjay; July 4th, 2017 at 04:05 AM.
-
July 3rd, 2017, 11:10 PM
#10
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by Arjay
If you want to have someone look at the code, please zip it up and attach it directly. We're willing to help, but most folks here are willing take the risk of going to an unknown site for a download.
At any rate, Victor has asked you for the specific code that creates the dialog.
Can't you take the time to post that bit of code here?
Thank you for your time Victor /Arjay/Everyone
I Understand everyone is trying to help me here and I am not sure which part of code i need to share.
I am sorry that i could not able to provide the information.
-
July 4th, 2017, 04:07 AM
#11
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by SAP_7
Thank you for your time Victor /Arjay/Everyone
I Understand everyone is trying to help me here and I am not sure which part of code i need to share.
I am sorry that i could not able to provide the information.
We are asking for the code snippet that displays the dialog. If you have written the code, this should be very easy to provide
-
July 6th, 2017, 09:14 AM
#12
Re: Set the ChildDialog Window Focus when i go to another application and come here
I understand your concern and try to give the code.
I have tried the below things. But not able to set the Focus on the Dialog
Written this code in the Child Window(Display panel) as per the above conversation. Its get notified whenever the Dialog is activate/Inactivated/WA_CLICKACTIVE.
Here,I am not sure how to set the focus on my Dialog(Display panel) when the user goes to another app and come to this application.
one more point is in the Parent window , the below notification code is written
void parentApp::OnActiveApp(Bool bActive, DWORD hTask) {
if(bActive)
if(GetLastActivePopUp !=this)
{
BringWindowTop();
}
} // This function is getting callled whenver I go to another app and come to the application
void XYZ::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
case WA_INACTIVE:
pWndOther = GetDlgItem(IDC_DISPLAY_UNIT);
pWndOther->SetFocus();
case WA_INACTIVE:
case WA_CLICKACTIVE:
SetWindowText("This window has been activated using the mouse!!!");
}
void XYZ::OnSetFocus(CWnd* pOldWnd) {
if (pOldWnd != NULL)
{
GetDlgItem(IDC_DISPLAY_UNIT)->SetFocus();
}
}
Included the Notifications in the message maps
ON_WM_ACTIVATE()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
As I am new to MFC, please forgive if anything i have written mistakenly
Thank you,
Senthil
Last edited by SAP_7; July 6th, 2017 at 09:35 AM.
Reason: Included the Content
-
July 6th, 2017, 01:37 PM
#13
Re: Set the ChildDialog Window Focus when i go to another application and come here
Originally Posted by SAP_7
Code:
void parentApp::OnActiveApp(Bool bActive, DWORD hTask) {
if(bActive)
if(GetLastActivePopUp !=this)
{
BringWindowTop();
}
} // This function is getting callled whenver I go to another app and come to the application
What is BringWindowTop function?
Originally Posted by SAP_7
Code:
void XYZ::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
case WA_INACTIVE:
pWndOther = GetDlgItem(IDC_DISPLAY_UNIT);
pWndOther->SetFocus();
case WA_INACTIVE:
case WA_CLICKACTIVE:
SetWindowText("This window has been activated using the mouse!!!");
}
Does this code compile?
Originally Posted by SAP_7
Code:
void XYZ::OnSetFocus(CWnd* pOldWnd) {
if (pOldWnd != NULL)
{
GetDlgItem(IDC_DISPLAY_UNIT)->SetFocus();
}
}
if your code does compile - then did you try to debug it?
Besides, you didn't show the line of your code to spawn this "Display panel" dialog window yet. Why????
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|