
Attempt 1
Trap the close window event.
I've found out how to do something before the window closes, but can't figure out how to ignore the close event. The window still closes after console_handler() is called
Code: Select all
EnableExplicit
Procedure console_handler(my_event.l)
If my_event = #CTRL_CLOSE_EVENT
PrintN("Close in 3 seconds... Can't stop it!")
Delay(3000)
EndIf
EndProcedure
OpenConsole()
SetConsoleCtrlHandler_(@console_handler(), 1)
PrintN("Try and stop the console closing...Close the window now")
Input()
CloseConsole()
Disable the close button
If the close button and system menu option are disabled the user can't easily close the window. The code below does not work.
con_handle shown as 7
system_menu shown as 0
Code: Select all
EnableExplicit
Global con_handle.l
Global system_menu.l
OpenConsole()
con_handle = GetStdHandle_(#STD_OUTPUT_HANDLE)
Debug "con_handle = " + Str(con_handle)
system_menu = GetSystemMenu_(con_handle, #False)
Debug "system_menu = " + Str(system_menu)
EnableMenuItem_(system_menu, #SC_CLOSE, #MF_BYCOMMAND | #MF_DISABLED)
DrawMenuBar_(con_handle)
PrintN("Close window should be disabled but isn't")
Input()
CloseConsole()