Page 1 of 2

Posted: Sat Oct 26, 2002 3:26 pm
by BackupUser
Restored from previous forum. Originally posted by blueb.

Hi,
I'm working on a PB demo program which will feature some "beginner examples".

I'm having trouble making this small Font / Trackbar example scroll smoothly. I've tried various combinations without too much success.

The trackbar value appears to "start at zero" every time you use the
right arrow to scroll the trackbar.

Any ideas?

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Horizontal Scroll Bar example file
;
;    (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;

hWnd = OpenWindow(0, 200, 200, 320, 240, #PB_Window_WindowCentered | #PB_Window_SystemMenu | #PB_Window_MaximizeGadget, "A Trackbar Example Window")
  If CreateGadgetList(hWnd)
      ;Slider
        TrackBarGadget(1, 10, 168, 310, 25, 1, 100)

      ; Quit button
        ButtonGadget(2, 200, 210, 90, 25,"Quit")
        TextGadget(3, 10, 10, 220, 150, "Slide the Trackbar control")
  EndIf
  
;Message Loop
 Repeat
  EventID.l = WaitWindowEvent()

   Select EventID

     Case #PB_EventGadget                     ; gadget event happened
         Select EventGadgetID()               ; find out which gadget
          
               Case 1                         ; if Trackbar Control (Scroll bar)
                    Result.l = GetGadgetState(1)
                    LoadFont(1, "Arial", Result)                    
                    ;UseFont(1)
                    SetGadgetFont(FontID())
                    ;SetGadgetText(3, Str(result))
                    TextGadget(3, 10, 10, 220, 150, Str(Result))
 
 
                Case 2                         ; Quit button
                     EventID = #PB_EventCloseWindow
                     
                Default
                  
          EndSelect
   EndSelect

 Until EventID = #PB_EventCloseWindow
; ----------------------------------------
End

Posted: Sat Oct 26, 2002 3:32 pm
by BackupUser
Restored from previous forum. Originally posted by fweil.

Hello blueb,

I do not understand exactly what you would like to do. Is it to track smoothly when clicking at right side of the gadget ?

Francois Weil
14, rue Douer
F64100 Bayonne

Posted: Sat Oct 26, 2002 3:38 pm
by BackupUser
Restored from previous forum. Originally posted by fweil.

Mmmm ... I teste it putting a Delay(250 just before the Until last event loop line.

It's funny because it seems that each time you add a trackbar event it queues the event somewhere and playback the whole queue.

Test it just clicking 3 or 4 times at precise places of the trackbar without sliding it ...


Francois Weil
14, rue Douer
F64100 Bayonne

Posted: Sat Oct 26, 2002 4:18 pm
by BackupUser
Restored from previous forum. Originally posted by blueb.

Yes Francois,

Adding the Delay shows the problem better. Even though we
set the textgadget to be the value of the Trackbar, it seems
as if it wants to start over from 1. Adding the delay gives it
a life of it's own. :cry:

--blueb

Posted: Sat Oct 26, 2002 5:18 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> The trackbar value appears to "start at zero" every time you use
> the right arrow to scroll the trackbar.

It's because you're re-creating the gadget without freeing it each time.
Put FreeGadget(3) before TextGadget(3,...) and it works fine.


PB - Registered PureBasic Coder

Posted: Sat Oct 26, 2002 10:49 pm
by BackupUser
Restored from previous forum. Originally posted by blueb.

That's great Paul!

I guess I misunderstood the help file.

Regards,
--blueb

Posted: Sun Oct 27, 2002 10:50 am
by BackupUser
Restored from previous forum. Originally posted by PB.

> I guess I misunderstood the help file.

I took a look in the help file and you're right in that it doesn't
say that you must free a gadget before re-creating it. But I think I
read in a post here that it must be done, which is why I tried it and
it worked when done that way.


PB - Registered PureBasic Coder

Posted: Sun Oct 27, 2002 2:18 pm
by BackupUser
Restored from previous forum. Originally posted by Andre.

If this is true for every gadget re-creating than we/I should add this to the help files. Anyone could confirm this or should we wait for Fred to answer ?

Regards
André

*** German PureBasic Support ***

Posted: Sun Oct 27, 2002 2:21 pm
by BackupUser
Restored from previous forum. Originally posted by blueb.

Thanks again Paul.

That's why this forum is a *LOT* better
than any manual! [grin]

blueb

Posted: Tue Oct 29, 2002 7:10 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

Andre:
Its true, gadgets are not freed automatically for a reason.

For example, you can use Gadget-Number 0 for all TextGadgets
that never change... like in the Editor Sources. :)

cya,
...Danilo

(registered PureBasic user)

Posted: Tue Oct 29, 2002 2:53 pm
by BackupUser
Restored from previous forum. Originally posted by blueb.

Hmmm...
I think gadgets should be freed automatically.

When I create a new gadget using an existing gadget number,
it simply frees that gadget number (if it existed)
then creates a new gadget with that number.

It may not be possible, I'll await the judges decision.

regards,
--blueb

Posted: Wed Oct 30, 2002 6:01 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

Everything is possible and its done for stuff
like Images and such.
Fred didnt do it for Gadgets for the reason
i said above.

cya,
...Danilo

(registered PureBasic user)

Posted: Wed Oct 30, 2002 5:03 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Originally posted by Danilo

Andre:
Its true, gadgets are not freed automatically for a reason.

For example, you can use Gadget-Number 0 for all TextGadgets
that never change... like in the Editor Sources. :)
No offense, but IMO this is a bad way to code :)
I see no advantage of this - perhaps saving a few bytes.

Have a nice day...

Franco

Posted: Thu Oct 31, 2002 6:18 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

> No offense, but IMO this is a bad way to code

So Frederic is a bad coder... OK, thats your opinion.

> I see no advantage of this - perhaps saving a few bytes.

If you write a compiler with your opinion
for all the hundreds commands, you will get
a bloated compiler that produces 100k .EXE
for a simple "Hello World".

But all you guys seem to forget 1 thing:
All this are features you _CAN_ use, but nobody said
you _MUST_ use it.

cya,
...Danilo

(registered PureBasic user)

Posted: Thu Oct 31, 2002 6:38 am
by BackupUser
Restored from previous forum. Originally posted by Franco.

> So Frederic is a bad coder... OK, thats your opinion.

LOL :) that's not what I had in mind...

>If you write a compiler with your opinion
>for all the hundreds commands, you will get
>a bloated compiler that produces 100k .EXE
>for a simple "Hello World".

Nop, you said this possibility was for TextGadgets that never change.
Not for all commands. And I was refering to it.
And I see still no advantage of doing it (regarding TextGadgets!)

Regarding 100K .exe for a simple "Hello World" - it's doable
But it's a huge task in PureBasic :)

Have a nice day...

Franco