ResizeGadget() + window refresh

Windows specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

Hi,

I was experimenting with the ResizeGadget() command today, and found that if I resized my window (gadget resize was linked to that) vertically, so that perhaps some of the previous gadgets horizontal borders would now be in the middle of a new gadget, it did not remove all of the old gadgets imagery from the window properly. Clicking on the gadgets drew them properly.

So:
is there some way to force a redraw/refresh of the contents of a window?
is ResizeGadget() supposed to do that and this is a bug?
is there something I've mised (like I need to remove the gadgets from a window before resizing them)? My code ATM checks the window size in the event loop and if it is different, goes through all my gadgets and calls ResizeGadget() for them. it does nothing else apart from that.

If you cannot imagine what the "corrupt" gadgets look like, I will try to arrange a screenshot or demo program or something.

Thanks.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Have you tried to call:
WindowEvent() : WindowEvent() ; call it twice...

In early days this worked out (Mr.Skunks tip)


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Have you tried to call:
WindowEvent() : WindowEvent() ; call it twice...
You mean after I resize the gadgets? I tried it there just now and it did not work. Thanks for the advice though.

In case anyone is interested I have now uploaded an archive with a demo program and a picture of the corruption to my homepage - http://www.david-mcminn.co.uk

--
It's not minimalist - I'm increasing efficiency by reducing input effort.

Edited by - tinman on 17 April 2002 00:22:48
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Cant say without seeing the source.

And the tip by Franco:
> (WindowEvent() : WindowEvent() ; call it twice

should be

Code: Select all

 While WindowEvent(): Wend 
This makes sure that all messages waiting
in the queue are processed now.
I had some repaint problems too, and with
this single line everything is gone and
repainting is fast.

But maybe thats another problem here -
cant say without seeing the source.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Cant say without seeing the source.
Yeah, I thought as much. I was hoping that it was something simple that someone might have seen before, but it seems not. Thanks for the help though, I'll go back and figure out some more tests.



--
It's not minimalist - I'm increasing efficiency by reducing input effort.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Yeah, I thought as much. I was hoping that it was something simple that someone might have seen before, but it seems not. Thanks for the help though, I'll go back and figure out some more tests.
Sorry for replying, but it will highlight this top as having new posts, perhaps attracting new readers :wink:

Anyway, here is some code that will replicate the problem:

Code: Select all

if initgadget(10)=0:end:endif

if openwindow(0,400,300,300,140,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget, "Layout Test")

    if creategadgetlist(windowid())

        ButtonGadget(0,20,22,200,20,"First")
        ButtonGadget(1,20,46,200,20,"Second")
    
        while quit.w=0
            ev.l=WaitWindowEvent()
            If ev=#PB_EventCloseWindow : quit=1 : endif

            If WindowHeight()140
                ; Resize gadgets so they overlap
                ResizeGadget(0,20,44,200,20)
                ResizeGadget(1,20,91,200,20)
                ; I tried sticking a "While WindowEvent():Wend" loop here but it did not help
                quit=1
            EndIf
        wend

        quit=0
        while quit.w=0
            ev.l=WaitWindowEvent()
            If ev=#PB_EventCloseWindow : quit=1 : endif
        wend
        
    endif

    closewindow(0)
endif
end
Hope this can throw some more light on the problem.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hi Tinman, thanks for the sample code.
This helps a lot to track down the bug.

I have two solutions for you:

First:
Change the sequence of ResizeGadget to:

ResizeGadget(1,20,91,200,20)
ResizeGadget(0,20,44,200,20)

Second:
Call the Gadgets this way to get the handle of the gadgets:

Butt0=ButtonGadget(0,20,22,200,20,"First")
Butt1=ButtonGadget(1,20,46,200,20,"Second")

than call right after:

ResizeGadget(0,20,44,200,20)
ResizeGadget(1,20,91,200,20)

RedrawWindow_(Butt1,0,0,7)

Well this is an API command that I normally use for Windows (Frames) not for Controls.
But it works.
Hope this works with your WindowsOS as well.


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> is there some way to force a redraw/refresh of the contents of a window?

Does my tip found here help in any way?

viewtopic.php?t=932


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
> is there some way to force a redraw/refresh of the contents of a window?

Does my tip found here help in any way?
Doh! This is what I'm used to doing from the Amiga (freeing gadgets and creating them again). And it is probably what I would have tried first rather than ResizeGadget() if FreeGadget() was mentioned in the manual! Grrrr.

I'll try it tonight, but I'm sure it will work. Thanks.
Additional: Yes, it works perfectly now. Woohoo!

--
It's not minimalist - I'm increasing efficiency by reducing input effort.

Edited by - tinman on 17 April 2002 19:41:53
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Fixed.

Fred - AlphaSND
Post Reply