claiming focus for a dialog
-
G'Day All, I have created a Dialog application that will manipulate some excel spreadsheets. In my OnInitDialog function (I am using MFC) I perform a test to see if excel is currently running. If it is running I display an interim modeless dialog that politely informs the user to shut excel and waits for them to do so (done with a call to WaitForSingleObject if that is relevant). This is all fine. Once excel is closed then I close this interim dialog and my OnInitDialog function completes and my 'real' dialog is displayed. However my problem is that when my 'real' dialog is displayed it is done so without the focus - it is not the currently active window. I have tried numerous things such as SetActiveWindow(), BringWindowToTop() etc without success. I was wondering if anyone could suggest a way of having my 'real' dialog start with the focus as it normally would if I wasn't mucking around with other windows whilst it was starting. Much Thanks In Advance Richard.
-
G'Day All, I have created a Dialog application that will manipulate some excel spreadsheets. In my OnInitDialog function (I am using MFC) I perform a test to see if excel is currently running. If it is running I display an interim modeless dialog that politely informs the user to shut excel and waits for them to do so (done with a call to WaitForSingleObject if that is relevant). This is all fine. Once excel is closed then I close this interim dialog and my OnInitDialog function completes and my 'real' dialog is displayed. However my problem is that when my 'real' dialog is displayed it is done so without the focus - it is not the currently active window. I have tried numerous things such as SetActiveWindow(), BringWindowToTop() etc without success. I was wondering if anyone could suggest a way of having my 'real' dialog start with the focus as it normally would if I wasn't mucking around with other windows whilst it was starting. Much Thanks In Advance Richard.
Did you try SetForegroundWindow? Use in together with SetActiveWindow. Nish
Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.
-
Did you try SetForegroundWindow? Use in together with SetActiveWindow. Nish
Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.
No, not until 30 seconds after you suggested it Nish :-) I missed that one. It now works like a charm. Thanks Nish problem solved! Richard.