Looking at ways to close the application. It seems I need to send the parent a message using PostQuitMessage 0 which (I'm guessing) is the same in effect as DIALOG CLOSE 0.
Looking at messages in my message pump, I can trap the SYSCOMMAND message if the user right-clicks and closes the dialog, or uses F4, but not if the X box gets clicked. I deduce that the message is not passed on by DDT if no callback function is declared. In the code below, if you click the X to close the application, you will have to kill it by other means (Windows Task Manager), but if you right click the dialog caption it closes OK. I don't suppose DDT DIALOGS were designed to be abused this way.
Looking at messages in my message pump, I can trap the SYSCOMMAND message if the user right-clicks and closes the dialog, or uses F4, but not if the X box gets clicked. I deduce that the message is not passed on by DDT if no callback function is declared. In the code below, if you click the X to close the application, you will have to kill it by other means (Windows Task Manager), but if you right click the dialog caption it closes OK. I don't suppose DDT DIALOGS were designed to be abused this way.
Code:
#COMPILE EXE #REGISTER NONE #DIM ALL #INCLUDE "Win32Api.Inc" '-------------------------------------------------------------------------- FUNCTION PBMAIN() LOCAL Msg AS tagMsg, hDlg AS LONG, i AS LONG DIALOG NEW 0 ,"CLOSE PROBLEM", 7, 62, 408, 161, %WS_CAPTION OR %WS_SYSMENU TO hDlg DIALOG SHOW MODELESS hDlg 'CALL DlgProc WHILE GetMessage(Msg, %NULL, 0, 0) IF msg.message = %WM_syscommand THEN IF (msg.wParam AND &HFFF0) = %SC_CLOSE THEN BEEP PostQuitMessage 0 END IF END IF ' IF IsDialogMessage(hDlg, Msg) = %FALSE THEN TranslateMessage Msg DispatchMessage Msg END IF LOOP END FUNCTION
Comment