Click to See Complete Forum and Search --> : Disabling "X" on the form and re-enabling it later.
Ghost
Dec 13th, 1999, 01:46 AM
Is it possible to disable the "X" on the form whenever processing is being done by the form and then re-enable it when the processing is complete. *We process data against DB2, and it takes couple of seconds (sometimes 10-15) before the operation is complete. And we don't want the user to fool around and click on "X" when the data update is taking place"
TIA.
funkheads
Dec 13th, 1999, 02:32 AM
take a look at my response here:
http://www.vb-world.net/ubb/Forum1/HTML/011482.html
it answers your question perfectly.
--michael
Ghost
Dec 13th, 1999, 03:37 AM
michael,
thanks for the code. that piece of code works fine for removing "X". But the re-enabling of "X" does not work properly even though I am calling it with MF_INSERT option.
MartinLiss
Dec 13th, 1999, 05:08 AM
Try this instead. This would be in your form's QueryUnload Event.
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
' g_bProcessFinished is a (perhaps) global variable
' that you would set to true when your long-running
' process is complete.
If Not g_bProcessFinished Then
Beep
MsgBox "Please wait. Process is not finished"
Cancel = True
End If
End If
End Sub
------------------
Marty
Just a thought "outside-of-the-box".
In SQL, would transactions help you?
(Begin Transaction, Rollback Transaction, and Commit Transaction)
You may not have to worry so much about the X in the window.
Ghost
Dec 13th, 1999, 06:27 AM
transaction will help when data is being inserted/updated or deleted. but what do you do when data is being selected ?
I don't know your specific application's needs, but if my user doesn't want to wait for normal processing (fooling around with the X), then he/she probably doesn't want to commit the transaction either. Your original post said , "update", but anything within the transaction is taken as a group or the group is not taken with a Rollback.
If it really is just a select, then why do you care about the X ?
Begin Transaction
Select * From MyTable
Commit Transaction (if window is still alive, else rollback)
...is valid anyway.
funkheads
Dec 15th, 1999, 12:05 AM
ghost...i don't know if you saw this (i missed mit my first time trying to run this piece of code) but you have to use the InsertMenu function instead of the RemoveMenu function WITH the MF_INSERT parameter in order to re-insert the "X" into your program. it should work fine then. any other problems try e-mailing me with specifics and i will see what's going on...
hope this helps. happy programming!!
--michael
mpdulle@loyno.edu
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.