David,
    Make your variables global so the assignment is not local then,
    When opening up the dialog and it still exists, keep it and place focus 
where you want focus inside that window, or object inside...
    Then in the original setting up the dialog and when closing that window, 
have it set it to Nothing!
Example:
'    Global:
     Dim MyDialog: Set MyDialog = Nothing
Sub HK1(myKeyId)
     'This routine is called when the hotkey Alt-Windows-C is pressed.
     If Keyboard.KeyDescriberActive Then
         Speak myStrings(myKeyId & "_Description")
     Else
         'Main routine functionality goes here
         If MyDialog Is Nothing Then
             Queue "OpenMyAppWin"
         Else
             MyDialog.window.Focus
     End IfKeyboard.KeyDescriberActive.
End Sub 'HK1.

Sent: Friday, October 07, 2016 9:11 PM
Subject: Single Instance Dialog Issue


Got a challenge here. I want to make sure only ONE instance of my dialog 
will be open, at any given time. The user will open the dialog with the 
Hotkey Win-c. But even if he tabs away from the dialog, and then once 
again hit Win-C, he should land in the already open dialog; not in a 
brand new window. Just like, when you hit the Ctrl-Backslash, you always 
land in one and same instance of the Window-Eyes Controlpanel.

Below you will find the cut-out of my code, that has to do with the 
opening of the dialog. In my Opening sub, I do the  lines:
     MyDialog.window.Activate
     MyDialog.window.Focus
But even this does not seem to fix my issue.

I am all learning ears, to any feedback you may have, or any good 
practice that you may want to share on this part.

Thanks to all,


---Snip-it:
Sub HK1(myKeyId)
     'This routine is called when the hotkey Alt-Windows-C is pressed.
     If Keyboard.KeyDescriberActive Then
         Speak myStrings(myKeyId & "_Description")
     Else
         'Main routine functionality goes here
         Queue "OpenMyAppWin"
     End IfKeyboard.KeyDescriberActive.
End Sub 'HK1.

Sub OpenMyAppWin()
     Dim MyDialog: Set MyDialog = Nothing
' Bring up the dialog:
     If MyDialog Is Nothing Then
         Set MyDialog = Dialog( myXMLFile, "MyAppMainDialog", 
"EHMainDialog")
     Else
         MyDialog.window.Activate
         MyDialog.window.Focus
     End If 'MyDialog Is Nothing.
' Room Cleaning:
     Set MyDialog = Nothing
End Sub 'OpenMyAppWin.

Function EHMainDialog( dObj, dEvent, dId, dControl)
Blah-blah-blah...
End Function 'EHMainDialog.
---End Of Snip.


-- 
David

_______________________________________________
Any views or opinions presented in this email are solely those of the author 
and do not necessarily represent those of Ai Squared.

For membership options, visit 
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/lab4me%40fltg.net.
For subscription options, visit 
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at 
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
Any views or opinions presented in this email are solely those of the author 
and do not necessarily represent those of Ai Squared.

For membership options, visit 
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/archive%40mail-archive.com.
For subscription options, visit 
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at 
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com

Reply via email to