WebGadget disappears

Just starting out? Need help? Post your questions and find answers here.
wombats
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Dec 29, 2011 5:03 pm

WebGadget disappears

Post by wombats »

Hi,

Sometimes when the window is maximized/restored, the WebGadget will disappear until the window is resized again. It doesn't happen on macOS, but it does on Windows.

Is there a way to force the WebGadget to reappear?

Code: Select all

If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
  ContainerGadget(1, 0, 0, 580, 280, #PB_Container_Single)
  WebGadget(0, 0, 0, 580, 280, "http://www.purebasic.com")
  CloseGadgetList()
  StringGadget(2, 0, 0, 0, 0, "...")
  SplitterGadget(3, 0, 0, WindowWidth(0), WindowHeight(0), 2, 1, #PB_Splitter_Vertical | #PB_Splitter_FirstFixed)
  SetGadgetState(3, 150)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
      Case #PB_Event_SizeWindow
        ResizeGadget(3, 0, 0, WindowWidth(0), WindowHeight(0))
        ResizeGadget(0, 0, 0, GadgetWidth(1), GadgetHeight(1))
    EndSelect
  ForEver
EndIf
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: WebGadget disappears

Post by TI-994A »

wombats wrote:...when the window is maximized/restored, the WebGadget will disappear until the window is resized again....
Works perfectly fine (PureBasic v5.62, Windows 10).
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
wombats
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Dec 29, 2011 5:03 pm

Re: WebGadget disappears

Post by wombats »

The thing is, though...it doesn't always happen. Sometimes it happens frequently and other times not.
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: WebGadget disappears

Post by the.weavster »

For me it works if you take out the container:

Code: Select all

If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
  ;ContainerGadget(1, 0, 0, 580, 280, #PB_Container_Single)
  WebGadget(0, 0, 0, 580, 280, "http://www.purebasic.com")
  ;CloseGadgetList()
  StringGadget(2, 0, 0, 0, 0, "...")
  SplitterGadget(3, 0, 0, WindowWidth(0), WindowHeight(0), 2, 0, #PB_Splitter_Vertical | #PB_Splitter_FirstFixed)
  SetGadgetState(3, 150)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
      Case #PB_Event_SizeWindow
        ResizeGadget(3, 0, 0, WindowWidth(0), WindowHeight(0))
        ;ResizeGadget(0, 0, 0, GadgetWidth(1), GadgetHeight(1))
    EndSelect
  ForEver
EndIf
Otherwise the WebGadget doesn't refresh when you move the splitter
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: WebGadget disappears

Post by TI-994A »

wombats wrote:The thing is, though...it doesn't always happen. Sometimes it happens frequently and other times not.
weavster's right; the web gadget disappears when resizing with the splitter, although still only occasionally.

And removing the container seems to solve the issue.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: WebGadget disappears

Post by the.weavster »

Changing the ContainerGadget() to a CanvasGadget() with the #PB_Canvas_Container flag set works for me:

Code: Select all

If OpenWindow(0,0,0,600,300,"WebGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget)
  ;ContainerGadget(1,0,0,580,280,#PB_Container_Single)
  CanvasGadget(1,0,0,580,280,#PB_Canvas_Container)
  WebGadget(0,0,0,580,280,"http://www.purebasic.com")
  CloseGadgetList()
  StringGadget(2,0,0,0,0,"...")
  SplitterGadget(3,0,0,WindowWidth(0),WindowHeight(0),2,1,#PB_Splitter_Vertical|#PB_Splitter_FirstFixed)
  SetGadgetState(3,150)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
      Case #PB_Event_SizeWindow
        ResizeGadget(3,0,0,WindowWidth(0),WindowHeight(0))
        ResizeGadget(0,0,0,GadgetWidth(1),GadgetHeight(1))

    EndSelect
  ForEver
EndIf
Edit:
Actually I take that back, it doesn't quite work because resizing with the splitter doesn't always make the container fill all the available width but the WebGadget() is now being redrawn.
wombats
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Dec 29, 2011 5:03 pm

Re: WebGadget disappears

Post by wombats »

Changing it to a CanvasGadget with the #PB_Canvas_Container flag is definitely better. It still happens occasionally, but not nearly as often. I guess that's acceptable.

It was only in a ContainerGadget for the border the ContainerGadget provides. It's not a big deal to draw it manually with the CanvasGadget.

Thanks.
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: WebGadget disappears

Post by the.weavster »

Even better:

Code: Select all

If OpenWindow(0,0,0,600,300,"WebGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget)
  ;ContainerGadget(1,0,0,580,280,#PB_Container_Single)
  CanvasGadget(1,0,0,580,280,#PB_Canvas_Container)
  WebGadget(0,0,0,580,280,"http://www.purebasic.com")
  CloseGadgetList()
  StringGadget(2,0,0,0,0,"...")
  SplitterGadget(3,0,0,WindowWidth(0),WindowHeight(0),2,1,#PB_Splitter_Vertical|#PB_Splitter_FirstFixed)
  SetGadgetState(3,150)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
      Case #PB_Event_SizeWindow
        ResizeGadget(3,0,0,WindowWidth(0),WindowHeight(0))
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            If EventType() = #PB_EventType_Resize
              ResizeGadget(0,0,0,GadgetWidth(1),GadgetHeight(1))
            EndIf
        EndSelect

    EndSelect
  ForEver
EndIf
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: WebGadget disappears

Post by RASHAD »

If the problems appears with windows only

Code: Select all

Global Oldproc
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  Procedure SplitCB(hWnd,uMsg,wParam,lParam)
     Select uMsg
        Case #WM_LBUTTONUP
          ResizeGadget(0, 0, 0, GadgetWidth(1), GadgetHeight(1))
  
     EndSelect   
     ProcedureReturn CallWindowProc_(Oldproc,hWnd,uMsg,wParam,lParam)
  EndProcedure
CompilerEndIf

If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
  ContainerGadget(1, 0, 0, 580, 280, #PB_Container_Single)
    WebGadget(0, 0, 0, 580, 280, "http://www.purebasic.com")
  CloseGadgetList()
  StringGadget(2, 0, 0, 0, 0, "...")
  SplitterGadget(3, 0, 0, WindowWidth(0), WindowHeight(0), 2, 1, #PB_Splitter_Vertical | #PB_Splitter_FirstFixed)
  SetGadgetState(3, 150)
 
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    Oldproc = SetWindowLongPtr_(GadgetID(3),#GWL_WNDPROC,@SplitCB())
  CompilerEndIf

  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
         
      Case #PB_Event_SizeWindow
        ResizeGadget(3, 0, 0, WindowWidth(0), WindowHeight(0))
        ResizeGadget(0, 0, 0, GadgetWidth(1), GadgetHeight(1))
    EndSelect
  ForEver
EndIf
Egypt my love
Post Reply