Show OpenWindow()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Show OpenWindow()

Post by mestnyi »

look as implemented

Code: Select all

Procedure CreateWindow(ParentID=0,Flag = #PB_Window_SystemMenu|#PB_Window_SizeGadget);|#PB_Window_NoActivate)
  Static Count, Window =-1
  Protected W=400,H=300
   Window = OpenWindow(#PB_Any,0,0, W,H, "Window_"+Str(Count),Flag, ParentID) :Count +1 
   
    If IsWindow(Window)
    For i = 0 To 1000
      ButtonGadget(i,5,5,25,25,"")
    Next
    
    EndIf
  ProcedureReturn Window  
EndProcedure

Window = CreateWindow()
ResizeWindow(Window,300,300,#PB_Ignore,#PB_Ignore)

Window = CreateWindow()
ResizeWindow(Window,500,300,#PB_Ignore,#PB_Ignore)

Window = CreateWindow()
ResizeWindow(Window,700,300,#PB_Ignore,#PB_Ignore)

      
Repeat 
  Until WaitWindowEvent() = #PB_Event_CloseWindow
show how it should be

Code: Select all

Enumeration #PB_Event_FirstCustomValue
  #PB_Event_ShowActiveWindow
  #PB_Event_ShowDeactiveWindow
EndEnumeration

Procedure ShowActiveWindowCallBack()
  ProcedureReturn HideWindow(EventWindow(), #False)
EndProcedure
Procedure ShowDeactiveWindowCallBack()
  ProcedureReturn HideWindow(EventWindow(), #False, #PB_Window_NoActivate)
EndProcedure

Procedure __OpenWindow(Window,X,Y,Width,Height,Title$,Flags,ParentID)
  Protected Hide
  If Not (Flags & #PB_Window_Invisible)
    Hide = #PB_Window_Invisible|#PB_Window_NoActivate
  EndIf
  
  Protected WindowID = OpenWindow(Window,X,Y,Width,Height,Title$,Hide|Flags,ParentID) :If Window =-1 :Window = WindowID :EndIf
  
  If Not (Flags & #PB_Window_Invisible)
    If Flags & #PB_Window_NoActivate
      BindEvent( #PB_Event_ShowDeactiveWindow, @ShowDeactiveWindowCallBack(), Window )
      PostEvent(#PB_Event_ShowDeactiveWindow, Window, -1)
    Else
      BindEvent( #PB_Event_ShowActiveWindow, @ShowActiveWindowCallBack(), Window )
      PostEvent(#PB_Event_ShowActiveWindow, Window, -1)
    EndIf
  EndIf
  
  ProcedureReturn Window  
EndProcedure

Macro OpenWindow(Window,X,Y,Width,Height,Title,Flags=0,ParentID =0) :__OpenWindow(Window,X,Y,Width,Height,Title,Flags,ParentID) :EndMacro

;______________________________

Procedure CreateWindow(ParentID=0,Flag = #PB_Window_SystemMenu|#PB_Window_SizeGadget);|#PB_Window_NoActivate)
  Static Count, Window =-1
  Protected W=400,H=300
   Window = OpenWindow(#PB_Any,0,0, W,H, "Window_"+Str(Count),Flag, ParentID) :Count +1 
   
    If IsWindow(Window)
    For i = 0 To 1000
      ButtonGadget(i,5,5,25,25,"")
    Next
    
    EndIf
  ProcedureReturn Window  
EndProcedure

Window = CreateWindow()
ResizeWindow(Window,300,300,#PB_Ignore,#PB_Ignore)

Window = CreateWindow()
ResizeWindow(Window,500,300,#PB_Ignore,#PB_Ignore)

Window = CreateWindow()
ResizeWindow(Window,700,300,#PB_Ignore,#PB_Ignore)

      
Repeat 
  Until WaitWindowEvent() = #PB_Event_CloseWindow
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Show OpenWindow()

Post by Little John »

look as implemented
The effect that we can see is not "implemented" in PB, but it is caused by your code.
show how it should be
If you want it to work that way, just write your code accordingly:

Code: Select all

Procedure CreateWindow(x, y, ParentID=0,Flag = #PB_Window_SystemMenu|#PB_Window_SizeGadget);|#PB_Window_NoActivate)
   Static Count
   Protected Window, W=400, H=300
   
   Window = OpenWindow(#PB_Any,x,y, W,H, "Window_"+Str(Count), Flag, ParentID)
   Count + 1
   Delay(200)
   
   ProcedureReturn Window 
EndProcedure

Window = CreateWindow(300, 300)
Window = CreateWindow(500, 300)
Window = CreateWindow(700, 300)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Show OpenWindow()

Post by mestnyi »

Do you think my goal is to bring these Windows? you really think so? :)
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Show OpenWindow()

Post by Little John »

mestnyi wrote:Do you think my goal is to bring these Windows? you really think so? :)
I don't know what your goal is.
Maybe you can explain it (in understandable English)?
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Show OpenWindow()

Post by mestnyi »

Maybe you can explain it (in understandable English)?
I want to time it so happened that I study Puric that he was the best
I want when writing code that I wrote less code
I want every step I did not expect surprises
I want to be alone behavior on all platforms.
And so I suggest to improve what is
......
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Show OpenWindow()

Post by Little John »

mestnyi wrote:
Maybe you can explain it (in understandable English)?
I want to time it so happened that I study Puric that he was the best
I want when writing code that I wrote less code
I want every step I did not expect surprises
I want to be alone behavior on all platforms.
Aha! ;-)
Post Reply