Page 1 of 1

TextGadget on Frame3DGadget

Posted: Sun Aug 22, 2004 9:18 pm
by Hi-Toro
Can anyone tell what's wrong with this? When I resize the window the TextGadgets named "Minimum size" and "Extension" screw up (text moves, blurs and disappears/reappears!)...

Code: Select all

Enumeration
  #Tree
  #Text_0
  #MinList
  #Frame3D_0
  #Text_1
  #ExtList
  #Parents
  #Children
  #Kill
EndEnumeration

Procedure WindowHook (window, message, wparam, lparam)
    Select message
        Case #WM_SIZE
            ResizeGadget(#Tree, 10, 10, WindowWidth () - 170, WindowHeight () - 20)
            ResizeGadget(#MinList, WindowWidth () - 140, 60, 120, 30)
            ResizeGadget(#Frame3D_0, WindowWidth () - 150, 10, 140, 160)
            ResizeGadget(#Text_0, WindowWidth () - 140, 40, 110, 20)
            ResizeGadget(#Text_1, WindowWidth () - 140, 100, 110, 20)
            ResizeGadget(#ExtList, WindowWidth () - 140, 120, 120, 30)
            ResizeGadget(#Parents, WindowWidth () - 150, 190, 140, 30)
            ResizeGadget(#Children, WindowWidth () - 150, 230, 140, 30)
            ResizeGadget(#Kill, WindowWidth () - 150, WindowHeight () - 40, 140, 30)
    EndSelect
    ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

If OpenWindow(0, 280, 209, 640, 480,  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Duplicity")
    If CreateGadgetList(WindowID())
      TreeGadget(#Tree, 10, 10, WindowWidth () - 170, WindowHeight () - 20, #PB_Tree_CheckBoxes)
      ComboBoxGadget(#MinList, WindowWidth () - 140, 60, 120, 30, #PB_ComboBox_Editable)
      Frame3DGadget(#Frame3D_0, WindowWidth () - 150, 10, 140, 160, "Find files with")
      TextGadget(#Text_0, WindowWidth () - 140, 40, 110, 20, "Minimum size")
      TextGadget(#Text_1, WindowWidth () - 140, 100, 110, 20, "Extension")
      ComboBoxGadget(#ExtList, WindowWidth () - 140, 120, 120, 30, #PB_ComboBox_Editable)
      ButtonGadget(#Parents, WindowWidth () - 150, 190, 140, 30, "Select parent items")
      ButtonGadget(#Children, WindowWidth () - 150, 230, 140, 30, "Select child items")
      ButtonGadget(#Kill, WindowWidth () - 150, WindowHeight () - 40, 140, 30, "Delete selected items")
    EndIf
EndIf

SetWindowCallback (@WindowHook ())

Repeat

Until WaitWindowEvent () = #PB_Event_CloseWindow
I made a little test version in case there was a problem between Frame3DGadgets and TextGadgets but this works fine, so it must be something I'm missing!

Code: Select all

Procedure WindowHook (WindowID, Message, wParam, lParam) 
    result = #PB_ProcessPureBasicEvents
    Select Message
        Case #WM_SIZE
            ResizeGadget (0, 0, 0, WindowWidth (), WindowHeight ())
            ResizeGadget (1, WindowWidth () - 120, 20, 100, 30)
    EndSelect
    ProcedureReturn result
EndProcedure

OpenWindow (0, 320, 200, 320, 200, #PB_Window_SystemMenu | #PB_Window_SizeGadget, "Test")

CreateGadgetList (WindowID ())
Frame3DGadget (0, 0, 0, WindowWidth (), WindowHeight (), "Test panel")
TextGadget (1, WindowWidth () - 120, 20, 100, 30, "Hello")

SetWindowCallback (@WindowHook ())

Repeat

Until WaitWindowEvent () = #PB_Event_CloseWindow

End

Re: TextGadget on Frame3DGadget

Posted: Sun Aug 22, 2004 9:48 pm
by PB
Happens to me too. Quickest fix I found was to lock and unlock your window
during the resize code, so put LockWindowUpdate_(WindowID()) after the
Case #WM_SIZE command and put LockWindowUpdate_(0) after the last
ResizeGadget command. Don't know why we need to do this, though.

Posted: Sun Aug 22, 2004 10:14 pm
by Hi-Toro
Hmm, that makes all other windows flicker here, which is worse (thanks though!)... I wonder if this should go in the Bugs section? Not sure since it works in the second example!

Posted: Sun Aug 22, 2004 10:38 pm
by PB
> that makes all other windows flicker here

Okay, try putting this at the end of the resize commands:

Code: Select all

RedrawWindow_(WindowID(),0,0,#RDW_INVALIDATE)
This will redraw the window after all resizing is done. Looks okay to me.

Posted: Sun Aug 22, 2004 10:43 pm
by Hi-Toro
Ah, that looks fine, PB -- thanks!