Page 1 of 1

PostPosted: Sat Mar 17, 2001 8:32 pm
by Velvis
I am trying to turn on & off bitmaps using an increment/decrement using Ccontrols.
I have 6 bitmaps defined h1-h6.
I have a add button and a subtract button.
I would like to be able to add/remove individually the h1-h6 bitmaps.

heres the code:
temp="h"+(string)counter;// make temp = h1,h2,h3...

When I call Cdraw normally (ie Cdraw(h1); it works fine) but I'd like to have the number part variable so it can automatically draw based on counter. So I assumed converting it to a string would work.
However it never draws the control. (no errors or crashes)

Any ideas?

PostPosted: Sun Mar 18, 2001 12:47 am
by Vilmos
Your string will indeed be say h1, but when you CDraw(h1) you are telling it to use the information at the address of a pointer named h1. That information isn't in the string.

An easy way to do what you want is to put all of your variables in an array.

<pre id=code><font face=courier size=2 id=code>
pointer Pictures[6];
then call them from your routine.

</font id=code></pre id=code>

Just access each element of the array as you would an individual Chandle. Remember that a CHandle is just a pointer. All CControls does is define them to be the same thing.


PostPosted: Sun Mar 18, 2001 11:48 am
by Velvis
Thanks. I knew I was doing it a strange way, thanks for explaining why it didnt work and showing me how to do it correctly. I appreciate it.