I think we talked about this before, but I cannot find it.
I have a modal dialog where I want to intercept clicking the close box so that I can ask the user if she means it.
Catch the WM_CLOSE message in your window/dialog procedure and proceed from there.
I've tried that. It doesn't appear to recognize the message.
Select @MESSAGE
Case WM_CLOSE
MessageBox 0, "Closing", "L", 0
The messagebox does not appear and the dialog closes.
Adding this code worked for me with EB long time ago:
case @IDCANCEL
MESSAGEBOX(dlg,"Are You sure?","error",@MB_ICONSTOP | @MB_RETRYCANCEL)
Unpack enclosed example. Maybe thats what you are trying to do?
Egil
EDIT: Posted an incorrect example, sorry. Have to search my old archive for the right one. Will post it as soon as it is found. :-[ :-[
Just in case I can make an example of this but not in Aurora code
Quote from: Egil on October 27, 2016, 01:06:16 PM
Adding this code worked for me with EB long time ago:
case @IDCANCEL
MESSAGEBOX(dlg,"Are You sure?","error",@MB_ICONSTOP | @MB_RETRYCANCEL)
Egil
Closer. The messagebox appears, but the dialog still closes.
Bruce
I think you'll have to sub-class your dialog's message handler so that the WM_CLOSE message is handled in the sub-classed handler which is where the messagebox will be coded also. If the answer to the MB is ok-close then the sbuclass returns to the regular handler; if the answer is don't close then the regular handler is bypassed.
For all other messages other than WM_CLOSE the subclass handler simply returns to the regular handler.
hope that makes sense.
Bruce,
Have searched my old backups for hours now, whitout success, can't remember what I called the file. Will continue searching.
But when I think of it, the idea for my EB code was ignited by a post in the Aurora section. And after some searching I found the origin:
http://www.ionicwind.com/forums/index.php?topic=2214.msg19420#msg19420
Guess that's what you are looking for?
Egil
Egil's solution looks the easiest in this case
I think I finally got it. While looking for articles on subclassing, I found a technique, here in IWB.
Select @MESSAGE
Case WM_SYSCOMMAND
If (@CODE == SC_CLOSE) and (dlgAgenda_ItemsPending() > 0)
If MessageBox( dlgAgenda, msg, "Warning", @MB_YESNO|@MB_ICONEXCLAMATION) == @IDYES
CloseDialog(dlgAgenda)
EndIf
Return true
EndIf
I am not positive why it works, but I am too tired tonight to figure it out.
Thanks for all of the suggestions.
Glad you solved your problem.
QuoteI am not positive why it works, but I am too tired tonight to figure it out.
To avoid the Dialog to exit, you have to return a non-zero value.
(Unable to test it in Aurora on this computer, so posting a working snippet in the IWB section)
Egil
Oops. This thread is not supposed to be in the Aurora section.