Set focus automatically to the last focus item after clossinga modal dialog
-
1. I set tab order for control in a MFC dialog. 2. Started the application. 3. Clicked a button in dialog, whose tab order is 3. 4. A modal dialog displayed. 5. Closed the modal dialog. Now the focus automatically moved to the control having tab order 0. Since the focus was on the button just before the click, I would like to retain the selection on the same button.
aks
-
1. I set tab order for control in a MFC dialog. 2. Started the application. 3. Clicked a button in dialog, whose tab order is 3. 4. A modal dialog displayed. 5. Closed the modal dialog. Now the focus automatically moved to the control having tab order 0. Since the focus was on the button just before the click, I would like to retain the selection on the same button.
aks
-
aks. wrote:
3. Clicked a button in dialog, whose tab order is 3.
But did this button actually have the focus at this point?
-
Yes. Before button click, even if the last focus is on another control( say tab order 2 ), after closing the Modal dialog the focus move to control having Tab order 0.
aks
-
1. I set tab order for control in a MFC dialog. 2. Started the application. 3. Clicked a button in dialog, whose tab order is 3. 4. A modal dialog displayed. 5. Closed the modal dialog. Now the focus automatically moved to the control having tab order 0. Since the focus was on the button just before the click, I would like to retain the selection on the same button.
aks
aks. wrote:
Now the focus automatically moved to the control having tab order 0.
How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
aks. wrote:
Now the focus automatically moved to the control having tab order 0.
How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Yes. I think the default MFC application created using the VS2010 wizard has this behavior.
aks
-
There is a world of difference between thinking something and actually checking it. If this was the default behaviour it is likely that many programs would not work.
-
Solution to what? We have no idea what your code is doing, or what you are doing when you run it, beyond your belief that the focus moves after you run some dialog. The only way to move forward with this is to write a very simple test program to demonstrate the problem and run some tests until you can isolate exactly what is happening.
-
Solution to what? We have no idea what your code is doing, or what you are doing when you run it, beyond your belief that the focus moves after you run some dialog. The only way to move forward with this is to write a very simple test program to demonstrate the problem and run some tests until you can isolate exactly what is happening.
-
please find the source shared at https://www.dropbox.com/s/w8pv31dhxy88h5p/Focus_Test.zip?dl=0[^]
aks
-
please find the source shared at https://www.dropbox.com/s/w8pv31dhxy88h5p/Focus_Test.zip?dl=0[^]
aks
The onus is on you to narrow the problem down to just the relevant code. Sane folks aren't going to chase links around and pull unrelated code from a project.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
The onus is on you to narrow the problem down to just the relevant code. Sane folks aren't going to chase links around and pull unrelated code from a project.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles