Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29238 Discussions

Interception of the close button event

belsim
Beginner
1,135 Views
Compiler : Compaq Visual Fortran 6.6.0
I have a QuickWin application and I would like to perform an action when the user close the application via the Close Button of the Window ( at the right top of the window).
0 Kudos
6 Replies
david_jones
Beginner
1,135 Views
There is a CVF sample file which does this .... look under

.....SAMPLESQUICKWINMENUDRIV

David Jones

0 Kudos
belsim
Beginner
1,135 Views
Ok, thank you but with that example I can remove the possibility of pushing on the
but what I would like to do is to allow the user to push on the button and perform some action before the application close.
0 Kudos
david_jones
Beginner
1,135 Views

You need to insert some code ... for example look for HCBT_SYSCOMMAND and insert a few lines into the code after it ...

if((nCode.eq.HCBT_SYSCOMMAND).and.(wParam.eq.SC_CLOSE)) then
write(*,3000)
3000 format(/ 'Close pressed ---- ')
stoprun=1
CBTProc = 1 ! we have processed the message so discard it.
return
endif

where "stoprun" is a variable passed via common block or module. Then in your main Quickwin code, test for whether "stoprun" is set to 1, and stop the program. Otherwise put the test in the sort of thread that the example sets up. Or put your extra code inside the if()then... endif and allow the program to stop from there by not setting CBTProc = 1 in the above.

David Jones
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,135 Views
I don't have time to look at the above mentioned sample, but ain't subclassing and handling WM_CLOSE much simpler way than installing a WH_CBT hook? OK, hooks are not that complicated, but they look like overkill to me.
You can find numerous posts re subclassing in this Forum -- search for "subclassing" and/or "GWL_WNDPROC".
Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,135 Views
...and here's a very relevant one.
0 Kudos
belsim
Beginner
1,135 Views
Thanks a lot :smileyhappy:
0 Kudos
Reply