Board index » cppbuilder » slider with more than 1 marker?

slider with more than 1 marker?


2007-03-24 05:07:45 PM
cppbuilder5
Hi,
does exist a control like the trackbar able to show more than 1 marker?
 
 

Re:slider with more than 1 marker?

"4N" < XXXX@XXXXX.COM >wrote:
Quote

does exist a control like the trackbar able to show more than 1 marker?
Two TrackBars?
~ JD
 

Re:slider with more than 1 marker?

well, I tought I could place them one ofter the other and resize them when
needed, but there will be a gap so I was thinking to draw it myself using a
TPaint control. That's a boring task though
 

{smallsort}

Re:slider with more than 1 marker?

4N wrote:
Quote
well, I tought I could place them one ofter the other and resize them when
needed, but there will be a gap so I was thinking to draw it myself using a
TPaint control. That's a boring task though


I found a free Delphi control to do this and translated it to BCB and
added a few things. I could send you the source for the component if
you'd like or I could put it in the Attachments group if you prefer. It
has two sliders on one track. It has one problem in that I couldn't
figure out how to get it to redraw itself when you resize is in design
mode. But other than that, it has worked well for a number of years.
The other option is to look at Torrie's site. I'll bet there are some there.
Regards,
Jim Dodd
Onset Computer Corp.
 

Re:slider with more than 1 marker?

Quote
I found a free Delphi control to do this and translated it to BCB and
added a few things. I could send you the source for the component if you'd
like or I could put it in the Attachments group if you prefer.
It'd be really nice of you If you'd post it in the attachments group.
If I'll be able to solve your resize problem I'll post the modified code in
the same group.
Thanks.
 

Re:slider with more than 1 marker?

4N wrote:
Quote

It'd be really nice of you If you'd post it in the attachments group.
If I'll be able to solve your resize problem I'll post the modified code in
the same group.
Thanks.


I've attached a Zip file with the source, header and DCR file in
borland.public.attachments under the subject "Source code for a
two-slider track bar". You're welcome to do anything you like with this
component. I hope it helps.
Jim
 

Re:slider with more than 1 marker?

Jim Dodd < XXXX@XXXXX.COM >wrote:
Quote

[...] I couldn't figure out how to get it to redraw itself
when you resize is in design mode.
Did you try InvalidateRect instead of Invalidate?
~ JD
 

Re:slider with more than 1 marker?

I've attached a Zip file with the source, header and DCR file in
Quote
borland.public.attachments under the subject "Source code for a two-slider
track bar". You're welcome to do anything you like with this component. I
hope it helps.
I received lot of errors during compiling phase due to Trect that doesn't
belong to Windows class and references to &RECT(r) that didn't like the & in
front of RECT.
After that I could install the component but now I get memory access
violations in vcl60.bpl (maybe I broke something removing the & in front of
RECT).
Well, I'll try to get rid of that issue.
About the redraw problem you have resizing it in design mode...what do you
mean? the only problem I get when I resize it on a form is the mentioned
access violation....
Anyway, thanks again.
 

Re:slider with more than 1 marker?

4N wrote:
Quote

I received lot of errors during compiling phase due to Trect that doesn't
belong to Windows class and references to &RECT(r) that didn't like the & in
front of RECT.
After that I could install the component but now I get memory access
violations in vcl60.bpl (maybe I broke something removing the & in front of
RECT).
Well, I'll try to get rid of that issue.
About the redraw problem you have resizing it in design mode...what do you
mean? the only problem I get when I resize it on a form is the mentioned
access violation....

Anyway, thanks again.



I'm sorry for the trouble. As you see by the date in my comments, I
hadn't touched that code for years and it was written for a project in
C++ Builder 3. When I move it to Builder 6, I see the same errors you
do. When I fixed those, I get the memory access violations, too. I will
look into this and see if I can figure where they are coming from. If I
can fix it, I'll put a note on this newsgroup and put an updated source
file in Attachments.
By the way, the reason for the &RECT() was that the Windows function
PtInRect needs an address. I fixed the "errors" that Builder 6 shows
by changing:
if( PtInRect(&RECT(ClientRect),Point(X,Y)) )
to:
RECT cr = RECT(ClientRect);
if( PtInRect(&cr,Point(X,Y)) )
I'm not sure why that makes a difference.
As far as the resizing problem - I must have fixed that and forgot about
it. I did find that in some circumstances, the sliders don't update
their relative positions after resizing but that it hard to reproduce.
And it's in design mode only so I'm not too worried about it.
Thanks for getting me to take a look at this again. I will try to
resolve the memory problems.
Jim
 

Re:slider with more than 1 marker?

JD wrote:
Quote
Jim Dodd < XXXX@XXXXX.COM >wrote:
>[...] I couldn't figure out how to get it to redraw itself
>when you resize is in design mode.

Did you try InvalidateRect instead of Invalidate?

~ JD

Thank you thinking about this, JD. I do use Invalidate in the code
but it turns out that I must have fixed the problem and forgot about it.
So, it was something other than using Invalidate. This was done about
five years ago!
Jim
 

Re:slider with more than 1 marker?

4N wrote:
Quote

I received lot of errors during compiling phase due to Trect that doesn't
belong to Windows class and references to &RECT(r) that didn't like the & in
front of RECT.
After that I could install the component but now I get memory access
violations in vcl60.bpl (maybe I broke something removing the & in front of
RECT).
Well, I'll try to get rid of that issue.
About the redraw problem you have resizing it in design mode...what do you
mean? the only problem I get when I resize it on a form is the mentioned
access violation....

Anyway, thanks again.

I think I found the problem and I've uploaded the revised source in
another Zip file (as a reply to the previous message). The old version
was 1.03.00 and this is version 1.04.00.
Besides making the modifications to get it to compile under Builder 6, I
fixed a problem where the off-screen Buffer was not always valid (that
seems to have been the source of the memory errors). Now, I allocate the
off-screen Buffer in the Constructor and only delete the Buffer in the
Destructor.
Let me know if this works for you.
Regards,
Jim Dodd
Onset Computer Corp.
 

Re:slider with more than 1 marker?

Quote
Let me know if this works for you.
Hi Jim,
at first glance this control works fine now, thanks a lot.
btw there's no license file inside the zip, this means that the code is free
for both not commercial and commercial software, right?
 

Re:slider with more than 1 marker?

4N wrote:
Quote
>Let me know if this works for you.

Hi Jim,

at first glance this control works fine now, thanks a lot.

btw there's no license file inside the zip, this means that the code is free
for both not commercial and commercial software, right?


Yes, that was the way I found it in the original component (TjanTracker
by Jan Verhoeven in Delphi) and decided to leave it that way in the
modified version.
Thank you for getting me to look at this component again. There are a
lot of things that could be improved on it (pointers instead of
rectangles, tick marks, sliders on the side instead of over the center
etc) but that's for others to add.
Jim