Page 1 of 1

Resizing ExplorerList gadgets from a callback

Posted: Mon Jun 23, 2003 9:19 pm
by tinman
Hello,

(fr34k, this is what I asked you about a few days ago ;)

I'm trying to resize some gadgets from a window callback. The code below shows the problem I am having - when I resize the gadgets only the one on the right is redrawn. It also happens with ExplorerTree gadgets.

In this code you can move the mouse left and right over the window (but NOT! over the explorerList gadgets) to resize the gadgets.

Code: Select all

Procedure.l Balance_Callback(*window.l, Message.l, wParam.l, lParam.l)
    DefType.l   result

    If Message=#WM_MOUSEMOVE And UseWindow(0)
        mx = WindowMouseX()
        my = WindowMouseY()
        
        If mx>10 And mx<390 And my>10 And my<390
            LockWindowUpdate_(WindowID())
            width1 = mx
            ResizeGadget(1, -1, -1, width1, -1)
            ResizeGadget(2, 4 + width1 + 4, -1, 400 - width1, -1)
            LockWindowUpdate_(0)
            
            UpdateWindow_(WindowID())
        EndIf
    EndIf
    
    result = #PB_ProcessPureBasicEvents
    ProcedureReturn result
EndProcedure


If OpenWindow(0, 400, 400, 412, 300, 0, "fghjk", 0)
    SetWindowCallback(@Balance_Callback())

    width1.l = 200

    If CreateGadgetList(WindowID())
        ExplorerListGadget(1, 4, 50, width1, 200, "c:\*.*", 0)
        ExplorerListGadget(2, 4 + width1 + 4, 50, 400 - width1, 200, "c:\*.*", 0)
        ButtonGadget(3, 156, 4, 100, 20, "Redraw", 0)
    EndIf

    While ev.l <> #PB_Event_CloseWindow
        ev.l = WaitWindowEvent()
        If ev=#PB_Event_Gadget
            If EventGadgetID()=3
            EndIf
        EndIf
    Wend
    
EndIf
End
Now, it's either because I'm doing something naughty with the callbacks or the explorer list gadget is screwed. Either answer will suit me as long as some explanation comes with it ;p

Thanks.

Posted: Mon Jun 23, 2003 9:34 pm
by LarsG
...doing something naughty with the callbacks...
Hehehe... 8O

Posted: Mon Jun 23, 2003 10:24 pm
by freak
Hum, strange thing...

Works just fine here, what system do you use?

I guess I'll have to pass this on to fred anyway, as this Gadget uses the
generic resize function of PB.

Fred: can you please have a look?

btw: can you please test this with two ListIconGadgets() ? ListIconGadget
should be exactly the same as ExplorerListGadget() from the resize point
of view.

[sarcastic]
2 more questions...
- what misterious thing does that 'Redraw' button in your code do?
- ever heared of SplitterGadget() ?
:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
[/sarcastic]

... sorry, just had to say that :wink:

Timo

Posted: Mon Jun 23, 2003 11:20 pm
by freak
Well... fred and me, none of us has an answer. :cry:

Maybe you really do "...doing something naughty with the callbacks..." :wink:

Can anyone else confirm this behaviour, and provide me with some
info ? OS, IE version, etc...

thanks,

Timo

Posted: Mon Jun 23, 2003 11:29 pm
by LarsG
I don't see any problems.. or maybe I just don't get it... :roll:

Posted: Mon Jun 23, 2003 11:31 pm
by tinman
freak wrote:Works just fine here, what system do you use?
See my signature ;p
btw: can you please test this with two ListIconGadgets() ? ListIconGadget
should be exactly the same as ExplorerListGadget() from the resize point
of view.
Yes, it works fine with ListIcon gadgets.
- what misterious thing does that 'Redraw' button in your code do?
It was from when I was testing the resizing code before realising it must be callback related.
- ever heared of SplitterGadget() ?
Given the amount of time I've wast^H^H^H^Hspent on this code I'm going to have to get it working. Besides, my own splitter gadget doesn't have all the bugs of Fred's ;p

Posted: Tue Jun 24, 2003 9:18 pm
by tinman
Well, I found a workaround. Not pleasant, but I suppose it works (we love you Win98!). Rather simple too - just let the window message come all the way back out to your main event loop and do the redrawing from there.

Yum.