Page 1 of 1

Floating EditorGadget

Posted: Sat Jul 22, 2006 8:39 pm
by applePi
i want to use the EditorGadget in a second window to display
the results of random numbers produced by clicking on a Button
on the First main window many times.
the folowing lines will only print the result of the first click
i could not display more until i close the second window and re click
on the button, indeed i have no idea about how to manage this situation
and how to access gadgets (controls) on other window from within the
main window.
thanks for any help.

Code: Select all

Procedure OpenNew(rnd.l) 
  OpenWindow(1,30,30,250,300,"window2",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget) 
  CreateGadgetList(WindowID(1)) 
  EditorGadget(9, 40, 40, 300, 150)
  SetGadgetText(9,Str(Int(rnd)))
  Repeat    
    ev=WaitWindowEvent()
    If EventWindow()=1 
      If ev=#PB_Event_Gadget Or ev=#PB_Event_CloseWindow 
        If ev=#PB_Event_CloseWindow 
          CloseWindow(1) 
          ProcedureReturn 
        EndIf 
      EndIf 
    EndIf 
  ForEver 
EndProcedure 

If OpenWindow(0,0,0,300,300,"window1",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
ButtonGadget(1, 50, 50, 55, 35, "windows2" ) 
Repeat 
  Event = WaitWindowEvent()
      Select Event
        Case #PB_Event_Gadget
         Select EventGadget()
           Case 1 :
           rnd.l=Random(100)
           OpenNew(rnd)
          EndSelect
       EndSelect
   
Until Event = #PB_Event_CloseWindow
EndIf  
[/code]

Re: Floating EditorGadget

Posted: Sun Jul 23, 2006 12:45 am
by Phoenix
Because when window 1 is opened your code then goes into a windowevent loop with that window, so clicking in window 0 can't happen until the event loop in window 1 is finished, but that only happens if you close window 1.... you can see this if you close window 1 - the event loop of window 0 then works again....

Remove the entire Repeat/Forever loop in the window 1 code and it'll work like you want....

Posted: Sun Jul 23, 2006 4:21 am
by applePi
thanks, it works, but the modified code still have two problems,

Code: Select all

Procedure OpenNew(rnd.l) 
  OpenWindow(1,30,30,250,300,"window2",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget) 
  CreateGadgetList(WindowID(1)) 
  EditorGadget(9, 40, 40, 300, 150) 
  SetGadgetText(9,Str(Int(rnd))) 
EndProcedure 

If OpenWindow(0,0,0,300,300,"window1",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
ButtonGadget(1, 50, 50, 55, 35, "windows2" ) 
Repeat 
  Event = WaitWindowEvent() 
      Select Event 
        Case #PB_Event_Gadget 
         Select EventGadget() 
           Case 1 : 
           rnd.l=Random(100) 
           OpenNew(rnd) 
          EndSelect 
       EndSelect 
    
Until Event = #PB_Event_CloseWindow 
EndIf  
when i close the second window it will close also the first window,
the other problem is the flicker that happend to both windows,
in visual basic 6 attaching
the code to the Form1 button click event:

Code: Select all

'VB6 code
Private Sub Command1_Click()
Form2.Visible = True
Form2.Text1.Text = Rnd
End Sub
here clicking on the button will not flicker either the Form1 nor the Form2.
[/code]