Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to exit dialog

Status
Not open for further replies.

RPEN

Programmer
Aug 23, 2007
33
CA
I'm using a dialog similar to the on below (copied from another post).
Under 'case 5' (idle) I am checking to see if the Extra session window is still open. If not (user has closed it) then I also want to close the dialog box. I am setting FileDlgFunction = False, but the dialog box does not close. Any idea how to gracefully exit the 'dialog loop'?

What I am trying to do is shut down the dialog box if the user exits the Extra session first.


Code:
Function FileDlgFunction(identifier$, action, suppvalue)
   FileDlgFunction = True
   Select Case action
     Case 1 'dialog box initialized
     Case 2 'button or control value changed
        Select Case identifier
        Case "BtnOk"
            If DlgText$("NewPass") <> DlgText$("ConfNewPass") then
                DlgText("ErrMsg"), "Passwords do not match."
            Else
                FileDlgFunction = False
            End If
        Case "BtnCancel"
            FileDlgFunction = False
        End Select
     Case 3 'text or combo box changed
     Case 4 'control focus changed
     Case 5 'idle
         DoEvents
  End Select
End Function
 
The FileDlgFunction = False is going to allow it to close. A button press is still required to close the dialog box. Have you tried a simple Exit Function?

Also, in my experience the idle case is useless. If you set up your idle function to include a counter, you'll see that there are times where the dialog box is idle but isn't being treated as idle. I'm pretty sure if another window is active, then idle ceases to work. But, if you run the cursor over the dialog box it'll start up while the cursor is moving.
 
Yea, I tried an Exit Function - doesn't seem to work. Is there some way to 'simulate' a button press?

I use the idle case to check if the Extra session is the active window. If it's not, then I hide the dialog window, otherwise I show the dialog window. Seems to work good.

The only problem is that if the user exits the Extra session, my dialog window is hidden so it is running in the background.
 
I found something that works, although I don't know if it's good practice.

In my 'idle case' I check if the Extra session is active. If it's not (meaninf the user has exited Extra whie the dialog is still up), I use the DestroyWindow function to close the dialog box. I was worried about how this would work, but it seems to exit the 'dialog loop' properly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top