@TI-994A :
Thank you. As I follow along, I'm quickly getting the hang of this. As you demonstrate,
#PB_Event_DeactivateWindow appears to be the solution to my requirement. I'll work around that to code specific exceptions, such as
NOT letting the child window get deactivated when it opens its own message box !
By the way, your idea of using a text clock to demonstrate that processes are still working is brilliant in its simplicity.
@ the.weavster :
Glad you're back. As you can see, your code is being put to good use; it's turning into a great pedagogical tool.
Thank you for that.
I agree with you about avoiding specific OS API calls; as you suggest, it seems possible to determine through flags
when exactly to close the child window.
I modified your code slightly (see below) and obtained exactly what I needed. The child window now stays alive when it opens its own message box, but otherwise closes whenever the user clicks outside its boundaries. Thanks for pointing out an intelligent use of the WindowData feature.
Code: Select all
;; modified by Blue
Procedure frmChild_Open()
If OpenWindow(#frmChild,#PB_Ignore,#PB_Ignore,200,150,"child",#PB_Window_SystemMenu)
ButtonGadget(#frmChild_btnOK,10,10,150,30,"Message Box") ; <<< changed
TextGadget(#frmChild_txtClock,20, 110, 160, 30,
FormatDate("%hh:%ii", Date()), #PB_Text_Right)
AddWindowTimer(#frmChild, #frmChild_tmrClock, 1000)
;#############################
SetWindowData(#frmChild,#True) ; deactivating the window will close it ; <<< changed
ResizeWindow(#frmChild,WindowX(#frmMain)+80,WindowY(#frmMain)+80,#PB_Ignore,#PB_Ignore) ;so we can always see it
SetWindowTitle(#frmChild,"Closes automatically") ; <<< changed
;#############################
EndIf
EndProcedure
Procedure frmChild_onGadget(nGadget,nEventType,nX,nY)
Select nGadget
Case #frmChild_btnOK
;##############################
SetWindowData(#frmChild,#False)
SetWindowTitle(#frmChild,"Remains active")
nResponse = MessageRequester("Message","something important... or not !",#PB_MessageRequester_Ok)
SetWindowData(#frmChild,#True)
SetWindowTitle(#frmChild,"Closes automatically") ; <<< changed
;##############################
EndSelect
EndProcedure
@User_Russian :
if you close the child window BEFORE opening it again, as in
Code: Select all
If EventGadget() = 2
If IsWindow(1)
CloseWindow(1) ; <<< work around for memory leak ?
EndIf
Child()
EndIf
won't that stop the memory leak ?
By the way, how do you determine that there's a memory leak ? Through the task manager ?