Parent Loses Gadgets when Child Screen Opens

Just starting out? Need help? Post your questions and find answers here.
User avatar
C87
Enthusiast
Enthusiast
Posts: 176
Joined: Mon Jul 17, 2017 7:22 am
Location: Cotswolds England

Parent Loses Gadgets when Child Screen Opens

Post by C87 »

Hello PB_All,
I have a set of about ten standard buttons and some or all are used on different screens in different Modules. They are initialised in a Enumeration/EndEnumeration in each module. My problem is that the initialisation tends to allocate the same values Module to Module. The actual Variable Name is ignored. So when the subsequent screen opens, then buttons and StringGadgets disappear from the calling screen and aren't returned until it is closed and re-opened. It is a situation I can recreate in a simple example.

I can of course add a number to the Enumeration initialisation but I do not know if one of those numbers may be allocated later, and unexpectedly remove another Gadget. I have noticed this same issue with the odd disappearing menu. How would I know that #PB_Any will not reuse one of these values and cause unexpected results later?

Basically I'm surprised that values set in one Module can be reused in another with different Variable Names and I haven't noticed this type of issue before (in other development languages)

Further to the above, is there a simple way of making the Parent/Child screens operate as modal screens to prevent a Child Screen from being Orphaned?
If it's falling over......just remember the computer is never wrong!
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Parent Loses Gadgets when Child Screen Opens

Post by mk-soft »

For this case there is the constant #PB_Any for the creation of dynamic windows and gadgets. Here you create a structure where you store the ID of the window and the IDs for the gadgets. To process the event correctly, you then use BindEvent and BindGadgetEvent. You use Set/GetGadgetData and Set/GetWindowData as pointers to the structure data in order to have the correct data for an event.

Make a small example ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
C87
Enthusiast
Enthusiast
Posts: 176
Joined: Mon Jul 17, 2017 7:22 am
Location: Cotswolds England

Re: Parent Loses Gadgets when Child Screen Opens

Post by C87 »

Hi Mk, I've prepared 4 files. The start .pb and three .pbi modules. Can't just see how to send a zip file, so 4 separate code blocks

Code: Select all

;PBT001.pb
;╔═════════════════════════════════════════════════════════════════════════════════════════════════════════╗
;║ Start program 1 of 4 showing reuse of variables from modules and their effect which results in Gadgets  ║
;║ being removed from a parent screen after opening a child screen. Also unable to stop the child screen   ║
;║ from being orphaned                                                                                     ║
;║ by William, C87 at Purebasic Forums                                                                     ║
;║ 30thNov21                                                                                               ║
;║ 4 programs make the set: PBT001.pb ;PBT002.pbi ; PBT110.pbi ; PBT120.pbi                                ║
;╚═════════════════════════════════════════════════════════════════════════════════════════════════════════╝

 EnableExplicit
UseSQLiteDatabase()
UsePNGImageDecoder()  


XIncludeFile "PBT120.pbi"   ; Subscreen to PBT110 usually  single record detail screen
XIncludeFile "PBT110.pbi"   ; First operations screen which usually give access to the main data 
XIncludeFile "PBT002.pbi"   ; MENU TO ACCESS THE PROGRAM SECTIONS



 PBTStart002::DoStartMenu()
  

;;
;;********************************************** The main program loop *****************************************
 Repeat
   ;
   Select WaitWindowEvent()
      ;
  EndSelect    

ForEver
;
;
;**************************************************************************************************************
;
;
; ┌───────────────────────────────────────────────┐
; │ ██████████   PROGRAM PBT001 END    ██████████ │
; └───────────────────────────────────────────────┘ 

;EndOfCode 001

Code: Select all

; PBT002.pbi
; ┌────────────────────────────────────────────────────────────┐
; │ PROGRAM PBT002 Opening Menu  to open PBT110                │
; │ 30thNov21    PureBasicTest Code                            │
; │ PBT001, PBT002, PBT110, PBR120                             │
; └────────────────────────────────────────────────────────────┘ 
;		
DeclareModule PBTStart002
  Declare DoStartMenu()
  Declare bExit002()
  Declare Menu002Select()
  Declare ProgShutDown()
  Declare Open110()
EndDeclareModule  ; ACS002

 Global.i Screen1 = #PB_Any   ;
  

Module PBTStart002 

  ;
  Global.i bDataCheck, OpenPWButton, Text_0, mYear, mMonth, mDay, mD_0, X, mDataCheck, mLocalExist,tVer,bExit002Start, Menu002

  Global.i BtnOpen110, mMsgBox2  : 
  Global.i Scrn1X, Scrn1Y : Scrn1X= 800 : Scrn1Y = 600
  ;
  Define.i BtnFirst, BtnBack, BtnNext, BtnLast, BtnAdd, BtnSave, BtnEdit, BtnRefr, BtnUtil, BtnDele, BtnFind, BtnPrin
  ;   ;
  Enumeration 50
    #Font_Screen1
    #Menu110
    #Menu_002Main
    #Menu_002Data
    #Menu_002Quit
    #Menu_002Utils
    #Menu_002Sys
    #Menu_002Etc1
    #Menu_002Etc2
    #Menu_002Help
    ;#10G
  EndEnumeration
  ;

  LoadFont(#Font_Screen1,"Tahoma",16) ;, #PB_Font_Bold)   ; FONT USED FOR APP NAME
  Procedure DoStartMenu()
    If OpenWindow(Screen1, #PB_Ignore, #PB_Ignore, Scrn1X, Scrn1Y, "MAIN START SCREEN", #PB_Window_WindowCentered)  ; 
      ;
      ; MENU 002
      Menu002 = CreateMenu(#Menu110, WindowID(Screen1))
      MenuTitle("PROGRAM FILES") ;"&" + Language(#SECTION, "About"))
      MenuItem(#Menu_002Data,"Browse Data" ) ;
      
      MenuItem(#Menu_002Quit,"Quit")
      MenuTitle("Utilities") ;"&" + Language(#SECTION, "Languages"))
      MenuItem(#Menu_002Utils,"Address") ; "&" + Language(#SECTION, "English")) 
      MenuBar()
      MenuItem(#Menu_002Etc1,"Sections") 
      MenuBar();
      MenuItem(#Menu_002Etc2,"Census")   ;German,  "&" + Language(#SECTION, "German"))
      MenuTitle("SYSTEM") 
      MenuItem(#Menu_002Sys,"System Master")
      MenuItem(#Menu_002Help,"HELP") 
      ; 
      SetWindowColor(Screen1,RGB(47,216,194))  ;32,190,222)) ;#Cyan) ;0)
      BtnOpen110    = ButtonGadget(#PB_Any, 100, 100, 160, 70,"Open Browse Screen") : SetGadgetFont(BtnOpen110, #Font_Screen1) ; repeat of menu option 
      ;
      bExit002Start = ButtonGadget(#PB_Any,660,380, 70,70,"Exit") :    SetGadgetFont(bExit002Start, #Font_Screen1)
      ; 
      SetGadgetState(bExit002Start,1)
      ;
      BindEvent(#PB_Event_Menu,           @Menu002Select())   ; BindEvent() the xxxxx() is a proc and the @ effectively calls it
      BindGadgetEvent(bExit002Start,      @bExit002())
      BindGadgetEvent(BtnOpen110,         @Open110())  
      BindEvent(#PB_Event_CloseWindow,    @ProgShutDown())    ; @Windowclose())   ;@Win_Main_Close())
                                                              ;
      mMsgBox2 = TextGadget(#PB_Any, 10, 350, 300,80,"Either the button or the menu opens the next screen. When that opens it is fine but when the child (PBT120) screen opens, gadgets are removed from parent (PBT110)")
      SetGadgetFont(mMsgBox2, #Font_Screen1)
    EndIf
    ;
  EndProcedure  ; OpenSTART()
                ;
  Procedure bExit002()
    ;
    If MessageRequester("EXIT SELECTED", "Ok To close the program down? ", 36) = 6  ;  #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
      ProgShutDown() ; WindowClose()
    EndIf
    ;
  EndProcedure
  ;
  Procedure Menu002Select()
    ;
    Select EventMenu()
      Case #Menu_002Main
        
      Case #Menu_002Data
        ;MessageRequester("Main Data ",iniDBPathDBF,0)
        Open110::DoOpen110()  
      Case #Menu_002Quit
        If MessageRequester("EXIT SELECTED", "Ok To close this screen? ", 36) = 6  ;  #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
          ProgShutDown()  ; WindowClose()
        EndIf
      Case #Menu_002Utils
        MessageRequester("UTILITY Section","maybe popup menu here?",0)
        SetMenuItemState(menu002,#Menu_002Utils,1)
        SetMenuItemState(menu002,#Menu_002Etc1,0)
        SetMenuItemState(menu002,#Menu_002Etc2,0)
      Case #Menu_002Etc1
        SetMenuItemState(menu002,#Menu_002Utils,0)
        SetMenuItemState(menu002,#Menu_002Etc1,1)
        SetMenuItemState(menu002,#Menu_002Etc2,0) 
      Case #Menu_002Etc2 
        SetMenuItemState(menu002,#Menu_002Utils,0)
        SetMenuItemState(menu002,#Menu_002Etc1,0)
        SetMenuItemState(menu002,#Menu_002Etc2,1) 
      Case #Menu_002Sys
     
      Case #Menu_002Help
        MessageRequester("HELP FILE","Help file selected",0)
    EndSelect
    ;
  EndProcedure  ; Menu002Select(
  ;             
  Procedure Open110()
    Open110::DoOpen110()
  EndProcedure
  ;
  Procedure ProgShutDown()
    ;Debug #Datafile1
    ;CloseDatabase(#DataFile1)
    End 0
  EndProcedure ; ProgShutDown()
  
 ; Macros::WindowClose
    
EndModule   ; PBTStart002
;
; ┌───────────────────────────────────────────────┐
; │ ██████████   PROGRAM PBT002 END    ██████████ │
; └───────────────────────────────────────────────┘ 

Code: Select all

;  PBT110.pbi
; ┌────────────────────────────────────────────────────────────┐
; │   PROGRAM PBT110  Opened from Menu PBT110                  │
; │ 30thNov21    PureBasicTest Errors losing gadgets           │
; │ PBT001, PBT002, PBT110, PBR120                             │
; └────────────────────────────────────────────────────────────┘ 
;
DeclareModule Open110
  Declare FnBtn1()
  Declare FnBtn2()
  Declare FnBtn3()
  Declare FnExitWin1()
  Declare DoOpen110()
EndDeclareModule ; DoScreen1
;
;
Module Open110
  ;
  ;!!!***  If I alter the Enumeration to be "Enumeration 110"  and similarly in PBT120 it works as expected
  ;        However I cannot be sure that these values will Not be used later, giving in unexpected results 
  ;        How would I know that #PB_Any will not use one of these values later?
  ;
  Enumeration      
    
    #Button_1     
    #BUTTON_2
    #BUTTON_3
    ;BUTTON_X
    #TEXT_Show
    #TestScrVar
    #AnotherVar1
    #AnotherVar2
  EndEnumeration
  ;
  ;!!!***  If I alter this to be "Enumeration 120"  and similarly in PBT120 it works as expected
  Enumeration 120  
    #WIN_110
    #Button_X
    ;
  EndEnumeration
  ;
   ;
  Procedure DoOpen110()
    ;
    If OpenWindow(#Win_110, 0, 0, 500, 500, "Test Windows Operation *** PBT110  ***", #PB_Window_ScreenCentered)
      StickyWindow(#Win_110, #True)
      
      StringGadget(#TestScrVar,20,300,80,25,"")                   : TextGadget(#PB_Any, 300, 300, 50,50,Str(#TestScrVar))
      
      ButtonGadget(#BUTTON_1, 10, 10, 50, 50, "Btn1")             : TextGadget(#PB_Any, 300,  10, 50,50, Str(#Button_1))
      ButtonGadget(#BUTTON_2, 10, 90, 150, 50, "Open Subscreen")  : TextGadget(#PB_Any, 300,  90, 50,50, Str(#Button_2))
      ButtonGadget(#BUTTON_3, 10,170, 50, 50, "Btn3")             : TextGadget(#PB_Any, 300, 170, 50,50, Str(#Button_3))
      ;
      ButtonGadget(#BUTTON_X,420,420, 60, 60, "Exit")
      ;
      BindEvent(#PB_Event_CloseWindow, @FnExitWin1())
      ;
      BindGadgetEvent(#BUTTON_1, @FnBtn1())
      BindGadgetEvent(#BUTTON_2, @FnBtn2())
      BindGadgetEvent(#Button_3, @FnBtn3())
      BindGadgetEvent(#Button_X, @FnExitWin1())
      ; 
      TextGadget(#PB_Any, 10, 350, 250,90,"This is fine. But when the [Open Subscreen] is clicked Gadgets are permanently lost here. The gadget numbers are shown to the right")
      
    EndIf
  EndProcedure ; DoOpen110()
  ;
  Procedure FnBtn1()
    TextGadget(#TEXT_Show, 100,10,70,25,"Message1") 
  EndProcedure
  ;
  Procedure FnBtn2()
    
    Open120::DoOpen120()    ; In PBT120.pbi
    
  EndProcedure
  ; 
  Procedure FnBtn3()
    TextGadget(#TEXT_Show, 100,10,70,25,"        ") 
  EndProcedure
  ;
  Procedure FnExitWin1()
    
    CloseWindow(#Win_110) 
    ;
  EndProcedure   
  ; 
EndModule  ; Open110
;
; ┌───────────────────────────────────────────────┐
; │ ██████████   PROGRAM PBT110 END    ██████████ │
; └───────────────────────────────────────────────┘ 

Code: Select all

;  PBT120.pbi
; ┌────────────────────────────────────────────────────────────┐
; │   PROGRAM PBT120       SubForm to PBT110                   │
; │ 30thNov21    PureBasicTest Errors losing gadgets           │
; │ PBT001, PBT002, PBT110, PBR120                             │
; └────────────────────────────────────────────────────────────┘ 
;
;
DeclareModule Open120
  Declare FnBtn13()
  Declare FnBtn23()
  Declare FnBtn33()
  Declare FnExitWin13()
  Declare DoOpen120()
EndDeclareModule ; DoScreen1


Module Open120
  ;
  Enumeration        ;!!!!*** If I alter this to be "Enumeration 210"  and similar in PBT110 it works as expected
    ;#WIN_120
    #BUTTON_13
    #BUTTON_23
    #BUTTON_33
    ;#BUTTON_X3
    #TEXT_Show3
    #TestScrVar3
  EndEnumeration
  ;
  Enumeration 220          ;!!!!*** If I alter this to be "Enumeration 220"  and similar in PBT110 it works as expected
    #Win_120
    #BUTTON_X3
    
  EndEnumeration
  ;
   ;
  ;
  Procedure DoOpen120()
    ;
    If OpenWindow(#WIN_120, 100, 100, 500, 500, "***  PBT120   ***")
      StickyWindow(#Win_120,#True)     ; Doesn't stop 110 from closing and leaving this open 
      ;
      StringGadget(#TestScrVar3,20,300,80,25,"")        : TextGadget(#PB_Any, 300, 300, 50,50,Str(#TestScrVar3))
      
      ButtonGadget(#BUTTON_13, 10, 10, 50, 50, "Btn1")  : TextGadget(#PB_Any, 300,  10, 50,50,Str(#Button_13))
      ButtonGadget(#BUTTON_23, 10, 90, 50, 50, "Btn2")  : TextGadget(#PB_Any, 300,  90, 50,50,Str(#Button_23))
      ButtonGadget(#BUTTON_33, 10,170, 50, 50, "Btn3")  : TextGadget(#PB_Any, 300, 170, 50,50,Str(#Button_33))
      ButtonGadget(#BUTTON_X3,420,420, 60, 60, "Exit")
      ;
      BindEvent(#PB_Event_CloseWindow, @FnExitWin13())
      ;
      BindGadgetEvent(#BUTTON_13, @FnBtn13())
      BindGadgetEvent(#BUTTON_23, @FnBtn23())
      BindGadgetEvent(#Button_33, @FnBtn33())
      BindGadgetEvent(#Button_X3, @FnExitWin13())
      TextGadget(#PB_Any, 10, 350, 250,80,"As this opens the Gadgets are permanently lost from the calling PBT110 screen.  Also, despite StickyWindow() this can become 'Orphaned' from PBT110 which I need to prevent")
      ; 
    EndIf
EndProcedure ; DoOpen120()
;
 Procedure FnBtn13()
    TextGadget(#TEXT_Show3, 100,10,70,25,"Message1") 
  EndProcedure
  ;
  Procedure FnBtn23()
    ;
    ;
  EndProcedure
  ; 
  Procedure FnBtn33()
    TextGadget(#TEXT_Show3, 100,10,70,25,"        ") 
  EndProcedure
  ;
  Procedure FnExitWin13()
    
    CloseWindow(#Win_120) 
    
    ;
    
  EndProcedure    
  ;
EndModule  ; Open120
;
; ┌───────────────────────────────────────────────┐
; │ ██████████   PROGRAM PBT120 END    ██████████ │
; └───────────────────────────────────────────────┘ 

Regards
If it's falling over......just remember the computer is never wrong!
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Parent Loses Gadgets when Child Screen Opens

Post by mk-soft »

Example with #PB_Any

Code: Select all

;-TOP by mk-soft

DeclareModule MyWindow
  
  Declare NewWindow(Title.s, Parend.i = 0)
  
EndDeclareModule

Module MyWindow
  
  EnableExplicit
  
  Structure udtMyWindowData
    Window.i
    Editor.i
    ; Data
    Text.s
  EndStructure
  
  Declare ReleaseWindow(*MyWindowData.udtMyWindowData)
  
  ; ----
  
  Procedure DoEventCloseWindow()
    Protected *MyWindowData.udtMyWindowData
    
    With *MyWindowData
      *MyWindowData = GetWindowData(EventWindow())
      Debug \Text
      ReleaseWindow(*MyWindowData)
    EndWith
  EndProcedure
  
  Procedure DoEventSizeWindow()
    Protected *MyWindowData.udtMyWindowData
    
    With *MyWindowData
      *MyWindowData = GetWindowData(EventWindow())
      ResizeGadget(\Editor, 0, 0, WindowWidth(\Window), WindowHeight(\Window))
    EndWith
  EndProcedure
  
  Procedure DoEventEditor()
    Protected *MyWindowData.udtMyWindowData
    
    With *MyWindowData
      *MyWindowData = GetGadgetData(EventGadget())
      Select EventType()
        Case #PB_EventType_Change
          \Text = GetGadgetText(\Editor)
          
        Case #PB_EventType_Focus
          
        Case #PB_EventType_LostFocus
        
      EndSelect
      
    EndWith
  EndProcedure
  
  ; ----
          
  Procedure NewWindow(Title.s, Parend.i = 0)
    Protected *MyWindowData.udtMyWindowData
    
    *MyWindowData = AllocateStructure(udtMyWindowData)
    If Not *MyWindowData
      ProcedureReturn 0
    EndIf
    
    With *MyWindowData
      \Window = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 400, 300, Title, #PB_Window_SystemMenu | #PB_Window_SizeGadget, Parend)
      \Editor = EditorGadget(#PB_Any, 0, 0, 400, 300)
      SetWindowData(\Window, *MyWindowData)
      SetGadgetData(\Editor, *MyWindowData)
      BindEvent(#PB_Event_CloseWindow, @DoEventCloseWindow(), \Window)
      BindEvent(#PB_Event_SizeWindow, @DoEventSizeWindow(), \Window)
      BindGadgetEvent(\Editor, @DoEventEditor())
    EndWith
    ProcedureReturn *MyWindowData
  EndProcedure
  
  Procedure ReleaseWindow(*MyWindowData.udtMyWindowData)
    With *MyWindowData
      UnbindEvent(#PB_Event_CloseWindow, @DoEventCloseWindow(), \Window)
      UnbindEvent(#PB_Event_SizeWindow, @DoEventSizeWindow(),  \Window)
      UnbindGadgetEvent(\Editor, @DoEventEditor())
      CloseWindow(\Window)
      FreeStructure(*MyWindowData)
    EndWith
  EndProcedure
  
EndModule

;-TOP

Enumeration Windows
  #Main
EndEnumeration

Enumeration Gadgets
  #MainButtonNewWindow
EndEnumeration

Enumeration Status
  #MainStatusBar
EndEnumeration

Procedure Main()
  Protected cnt_window
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 600, 300, "Main Window" , #MainStyle)
    ButtonGadget(#MainButtonNewWindow, 10, 10, 120, 25, "New Window")
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case #Main
              Break
              
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #MainButtonNewWindow
              cnt_window + 1
              MyWindow::NewWindow("MyWindow (" + cnt_window + ")", WindowID(#Main))
              
          EndSelect
             
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Parent Loses Gadgets when Child Screen Opens

Post by mk-soft »

For enumeration, use the this module "Common" over all, also in the modules and main , and then use named enumeration over all.

Code: Select all

DeclareModule Common
  Enumeration Windows
  EndEnumeration
  
  Enumeration Menus
  EndEnumeration
  
  Enumeration MenuItems
  EndEnumeration
  
  Enumeration Gadgets
  EndEnumeration
  
  Enumeration Toolbars
  EndEnumeration
  
  Enumeration Statusbars
  EndEnumeration
  
  Enumeration Fonts
  EndEnumeration
  
  Enumeration Images
  EndEnumeration
  
EndDeclareModule

Module Common
  
EndModule

;- Example
UseModule Common

Enumeration Windows
  #Main
EndEnumeration

Enumeration Gadgets
  #Gadget1
  #Gadget2
  #Gadget3
EndEnumeration

Debug "Main Window: " + #Main
Debug "Main Gadgets"
Debug #Gadget1
Debug #Gadget2
Debug #Gadget3

DeclareModule MyModule
  
EndDeclareModule

Module MyModule
  
  UseModule Common
  
  Enumeration Windows
    #ModuleWindow
  EndEnumeration
  
  Enumeration Gadgets
    #Gadget1
    #Gadget2
    #Gadget3
  EndEnumeration

  Debug "Module Window: " + #ModuleWindow
  Debug "Module Gadgets:"
  Debug #Gadget1
  Debug #Gadget2
  Debug #Gadget3
  
EndModule
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
C87
Enthusiast
Enthusiast
Posts: 176
Joined: Mon Jul 17, 2017 7:22 am
Location: Cotswolds England

Re: Parent Loses Gadgets when Child Screen Opens

Post by C87 »

Whilst MK-SOFT's solution of using an included Module with the Common Module appears to be the accepted solution,
it does have it's problems.........well for me anyway.

If I (say) just use the Enumeration Names "Gadgets" and "Windows" in Enumeration, then the first Static to each will be zero,
then increment on. This then creates within this trivial three form analysis, a duplicated Static of at least 0 and maybe 1 & 2.
The only way to avoid this I found was to set all Enumeration/End Statics to the Name "Gadgets". Then there will be only one
Static set in the Enumeration sequence starting 0.

It does appear that in this example the incremented numbers are allocated by the compiler first, to the last opened Form/Window
(PBT120), then with the highest number finishing on the final but initial opening Form/Window (PBT002). In the maybe more commonly
used PureBasic analysis with a program consisting of Code followed with the Repeat/Forever loop at the end, the use of multiple
Enumeration Names or sections may well not be a problem. But I intended to use separate Modules for each Form/Window.

I was hoping to convert several database applications to PureBasic, first in Windows and then in Linux when PureBasicV6 is available.
One of these applications has 53 Tables and 148 Forms/Windows in their current language and I cannot see that these numbers
would decrease in PureBasic. Clearly some Forms are Combination Forms, with one Form having one and up to three others embedded,
plus screen variables. But I do see each mainly as separate Modules. My worry is whether this issue will cause unexpected, or difficult
to trace problems when I am deep into the conversion.

I have also noticed that if I add a high starting Constant for a Name in Enumeration, from 400 to 1000 then the shape of buttons on
the opening screen changes but are still operational. Which was odd and unexplainable. This effect probably excludes the option to add
a Constant to the Enumeration Names to avoid a repeating number if multiple Enumeration Names are used.
If it's falling over......just remember the computer is never wrong!
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Parent Loses Gadgets when Child Screen Opens

Post by mk-soft »

Since you are working with Bind(Gadget)Event anyway, the number of the constant doesn't matter. The main thing is that there is no double assignment and object numbering is continuous and thus the object number distribution is optimised.

However, it is important for the optimisation that the object types are not mixed. That means keeping the enumeration for windows, gadgets, etc. separate. See PB help "Purebasic objects overview".

The next step to optimise the call of the event procedures would be to store the addresses of the procedures in a virtual table and call them via the index EventGadget() or EventWindow().
I use this optimisation method in my EventDesigner V3.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply