Tracking whats in Each Picturebox 
Author Message
 Tracking whats in Each Picturebox

I have multiple pictureboxes.
Picturebox 0 is design and the rest are created at run time.
I want to draw three line in picturebox 0.
Prior to drawing I update my structure

Type TPBox(PBoxNumber)
      LineNo As Long
      FirstInPBox As Boolean
End Type

For the 1st line  I set "FirstInPBox = True" (this controls
the scale values)
For the Second and Third Lines I just draw the lines
All works well.

=================
I now wish to move one of the lines to Box "1".
If it is LineNo 2 or 3, I just delete the LineNo Reference
for PBox 0 and put it into the PBox1 Structure and Also
Set the FirstInPbox = True.

However, If I move Line #1 to PBox1, I loose "FirstInPBox = True"
which controls the Scale, which forces me to loop through the
structure and update the next line number to use as the scale for PBox 0.

Anyone got a better or easier way?



Tue, 31 Jul 2012 07:55:19 GMT  
 Tracking whats in Each Picturebox


Quote:
>I have multiple pictureboxes.
> Picturebox 0 is design and the rest are created at run time.
> I want to draw three line in picturebox 0.
> Prior to drawing I update my structure

> Type TPBox(PBoxNumber)

You can't declare a type as an array like that so that isn't valid VB code

Quote:
>      LineNo As Long
>      FirstInPBox As Boolean
> End Type

> For the 1st line  I set "FirstInPBox = True" (this controls
> the scale values)
> For the Second and Third Lines I just draw the lines
> All works well.

> =================
> I now wish to move one of the lines to Box "1".
> If it is LineNo 2 or 3, I just delete the LineNo Reference
> for PBox 0 and put it into the PBox1 Structure and Also
> Set the FirstInPbox = True.

I've read this post several times and have no idea what you are doing or
what you are having trouble with.  "delete the LineNo Reference for PBox 0"
doesn't make sense unles syou mean you're just setting it to 0.

Quote:
> However, If I move Line #1 to PBox1, I lo[o]se "FirstInPBox = True"

How are you "moving" a line from one picturebox to another?  If what you're
doing changes the contents of an element in an array of TPBox types then
your code must be doing that.

Quote:
> which controls the Scale, which forces me to loop through the
> structure and update the next line number to use as the scale for PBox 0.

I think you need to post actual code that demonstrates the problem and/or
clarify the question.


Tue, 31 Jul 2012 08:15:14 GMT  
 Tracking whats in Each Picturebox
Mr. Butler:
Thanks for taking a look see.

First your correct on this declare

Quote:
>> Type TPBox(PBoxNumber)

> You can't declare a type as an array like that so that isn't valid VB code

My error, was trying to cut corners and show that the structure was an
array.

======================

There is a lot of code (many procedures) so difficult to post.
========================

Bottom line is I'm trying to track different objects (e.g. lines) which can
be drawn and moved -- at user selection -- between different pictureboxes.

Since the first line drawn in each picturebox determines the scale for the
picturebox, the movement of that line to a "new" picturebox would corrupt
any other lines in the "old" picturebox.

Looking for a simple yet effective method to do this.


Quote:



>>I have multiple pictureboxes.
>> Picturebox 0 is design and the rest are created at run time.
>> I want to draw three line in picturebox 0.
>> Prior to drawing I update my structure

>> Type TPBox(PBoxNumber)

> You can't declare a type as an array like that so that isn't valid VB code

>>      LineNo As Long
>>      FirstInPBox As Boolean
>> End Type

>> For the 1st line  I set "FirstInPBox = True" (this controls
>> the scale values)
>> For the Second and Third Lines I just draw the lines
>> All works well.

>> =================
>> I now wish to move one of the lines to Box "1".
>> If it is LineNo 2 or 3, I just delete the LineNo Reference
>> for PBox 0 and put it into the PBox1 Structure and Also
>> Set the FirstInPbox = True.

> I've read this post several times and have no idea what you are doing or
> what you are having trouble with.  "delete the LineNo Reference for PBox
> 0" doesn't make sense unles syou mean you're just setting it to 0.

>> However, If I move Line #1 to PBox1, I lo[o]se "FirstInPBox = True"

> How are you "moving" a line from one picturebox to another?  If what
> you're doing changes the contents of an element in an array of TPBox types
> then your code must be doing that.

>> which controls the Scale, which forces me to loop through the
>> structure and update the next line number to use as the scale for PBox 0.

> I think you need to post actual code that demonstrates the problem and/or
> clarify the question.



Tue, 31 Jul 2012 10:00:50 GMT  
 Tracking whats in Each Picturebox


Quote:
> Mr. Butler:
> Thanks for taking a look see.

> First your correct on this declare

>>> Type TPBox(PBoxNumber)

>> You can't declare a type as an array like that so that isn't valid VB
>> code

> My error, was trying to cut corners and show that the structure was an
> array.

> ======================

> There is a lot of code (many procedures) so difficult to post.
> ========================

> Bottom line is I'm trying to track different objects (e.g. lines) which
> can be drawn and moved -- at user selection -- between different
> pictureboxes.

> Since the first line drawn in each picturebox determines the scale for the
> picturebox, the movement of that line to a "new" picturebox would corrupt
> any other lines in the "old" picturebox.

> Looking for a simple yet effective method to do this.

OK, setting aside how to do it for a moment...  I as a user draw a few lines
on the first PB, a couple on the second, and none on the third...

Now I "move" the first line from the first PB to the second (which already
has some)
-- what happens on the first PB?  does the second line drawn now become the
basis for scaling?  Does the first line remain since it set the scale?
-- what happens on the second PB?  does the line being moved get re-scaled
to fit the scale already set or does it become the new "first" line and
cause whatever is there already to be rescaled?

If I move the line to the third PB instead (which has nothing already) I'd
assume it would become the first line there but the question of what happens
on the first PB still holds?

I'm unclear how one line defines scale for the others but it one line is
different than all others in a set then I'd probably consider treating it
differently... maybe *always* having a scale line on each PB that the user
can manipulate but not move to another PB; possibly having these scaling
lines in an array of their own or otherwise defined apart from the arrays of
"regular" lines for each PB.



Tue, 31 Jul 2012 10:12:27 GMT  
 Tracking whats in Each Picturebox
OK -- Trying to keep this post simple, but I have a number of different
scales that can be assigned.  In all cases these scales will be based on the
1st line in the PBox UNLESS each line is allowed to "float" -- that is use
each lines own scale.

========  Re:  Your Questions =============
1)  The first line in any PBox determines the scale.  So movement of
      1st line to third PBox would cause the 1st line scale to be used in
       that PBox.

2)  1st line to second PBox presents a little more of an issue.  Based on
     my criteria, I would say that it would now scale to the 1st line
already
     in the 2nd PBox.

3)  The second line in the 1st PBox would now be used to scale the 1st PBox,
since the 1st line is no longer in the 1st PBox.


Quote:



>> Mr. Butler:
>> Thanks for taking a look see.

>> First your correct on this declare

>>>> Type TPBox(PBoxNumber)

>>> You can't declare a type as an array like that so that isn't valid VB
>>> code

>> My error, was trying to cut corners and show that the structure was an
>> array.

>> ======================

>> There is a lot of code (many procedures) so difficult to post.
>> ========================

>> Bottom line is I'm trying to track different objects (e.g. lines) which
>> can be drawn and moved -- at user selection -- between different
>> pictureboxes.

>> Since the first line drawn in each picturebox determines the scale for
>> the picturebox, the movement of that line to a "new" picturebox would
>> corrupt any other lines in the "old" picturebox.

>> Looking for a simple yet effective method to do this.

> OK, setting aside how to do it for a moment...  I as a user draw a few
> lines on the first PB, a couple on the second, and none on the third...

> Now I "move" the first line from the first PB to the second (which already
> has some)
> -- what happens on the first PB?  does the second line drawn now become
> the basis for scaling?  Does the first line remain since it set the scale?
> -- what happens on the second PB?  does the line being moved get re-scaled
> to fit the scale already set or does it become the new "first" line and
> cause whatever is there already to be rescaled?

> If I move the line to the third PB instead (which has nothing already) I'd
> assume it would become the first line there but the question of what
> happens on the first PB still holds?

> I'm unclear how one line defines scale for the others but it one line is
> different than all others in a set then I'd probably consider treating it
> differently... maybe *always* having a scale line on each PB that the user
> can manipulate but not move to another PB; possibly having these scaling
> lines in an array of their own or otherwise defined apart from the arrays
> of "regular" lines for each PB.



Tue, 31 Jul 2012 11:17:51 GMT  
 Tracking whats in Each Picturebox
One thought is something like this:

1)  Set Property FirstInPBox for all Line to False

For i = 0 To UBound(TLines)
          TLines(i).FirstInPBox = False
Next

2)  Now Flag the !st line in Each PBox

For i = 0 to UBound(PBox)
     For j = 0 to UBound(TLines)
           If i = TLines(j).ThisPBox THen
                 TLines(j).FirstInPBox = True
                  Exit For
           End If
     Next
Next


Quote:



>> Mr. Butler:
>> Thanks for taking a look see.

>> First your correct on this declare

>>>> Type TPBox(PBoxNumber)

>>> You can't declare a type as an array like that so that isn't valid VB
>>> code

>> My error, was trying to cut corners and show that the structure was an
>> array.

>> ======================

>> There is a lot of code (many procedures) so difficult to post.
>> ========================

>> Bottom line is I'm trying to track different objects (e.g. lines) which
>> can be drawn and moved -- at user selection -- between different
>> pictureboxes.

>> Since the first line drawn in each picturebox determines the scale for
>> the picturebox, the movement of that line to a "new" picturebox would
>> corrupt any other lines in the "old" picturebox.

>> Looking for a simple yet effective method to do this.

> OK, setting aside how to do it for a moment...  I as a user draw a few
> lines on the first PB, a couple on the second, and none on the third...

> Now I "move" the first line from the first PB to the second (which already
> has some)
> -- what happens on the first PB?  does the second line drawn now become
> the basis for scaling?  Does the first line remain since it set the scale?
> -- what happens on the second PB?  does the line being moved get re-scaled
> to fit the scale already set or does it become the new "first" line and
> cause whatever is there already to be rescaled?

> If I move the line to the third PB instead (which has nothing already) I'd
> assume it would become the first line there but the question of what
> happens on the first PB still holds?

> I'm unclear how one line defines scale for the others but it one line is
> different than all others in a set then I'd probably consider treating it
> differently... maybe *always* having a scale line on each PB that the user
> can manipulate but not move to another PB; possibly having these scaling
> lines in an array of their own or otherwise defined apart from the arrays
> of "regular" lines for each PB.



Tue, 31 Jul 2012 11:59:18 GMT  
 Tracking whats in Each Picturebox

Quote:
> 1)  The first line in any PBox determines the scale.

You are ommitting important stuff, David. Exactly HOW does the first line
determine the scale? And what EXACTLY does it determine the scale of? Do you
mean that it alters the ScaleMode of the PictureBox, and if so then by what
mechanism does it do so. Otherwise, if it is not the ScaleMode you are
altering then what alternative method are you using. Is it something about
the property of the line itself? In other words, is it not really a line you
have "drawn". You seem to be missing out important parts of your code and
details about the lines themselves is one of them. You say that you are
"drawing" them, and yet you also say that you are sometimes "moving" some of
them into another different PictureBox without expanding on the code you are
using to actually perform that task. It is of course possible to move actual
drawn lines, but it requires code to do so and also a record somewhere of
the drawn line's coordinates (which do not appear in the Type structure you
posted) and so your ommission of any remarks regarding such data or code
makes me think that you are actually placing Line Controls in the PictureBox
instead of actually "drawing" the lines. Is that what you are doing?
Whatever it is, I think you need to tell us a lot more about what you are
actually doing. A rough outline overview of the entire job in ordinary
English without any mention of code or methods is perhaps the best place to
start, because the methods you are currently using may or may not be the
best way to do it.

Mike



Tue, 31 Jul 2012 17:04:11 GMT  
 Tracking whats in Each Picturebox


Quote:
> One thought is something like this:

This is yet another example of a person asking what a forest is, when
they bring you a leaf.  "I've got this leaf, how do I connect it to a branch?"

So far, its told:

1. There are pictureboxes
2. There are lines in the pictureboxes.
3. The first line in a picturebox determines the scale.
4. Lines can be moved among pictureboxes.

And the question;

How does a picturebox know what line governs the scale?

How about this for an answer....

Associate a Collection of lines to each picturebox and make the first
line in the collection the controlling entity.

LFS



Tue, 31 Jul 2012 21:24:44 GMT  
 Tracking whats in Each Picturebox


Quote:
> OK -- Trying to keep this post simple,

I don't think you'll be able to get much more help unless you can elaborate.
From what you've said so far I'd either have the "first lines" in their own
array or having the first entry in each array controlling the scale
(whatever that means) and forget about the "FirstInPB" flag.


Tue, 31 Jul 2012 21:41:30 GMT  
 Tracking whats in Each Picturebox
Mr. Williams
    Not using a line control but API Moveto, Lineto

Mr. Butler
    Using the first in the PBox, with the "FirstInPBox" flag because
    if I expand this to include circles and rectangles
    it may be required.

    In relooking at my loop code, it will work well for just lines but
    has issues if circles and rectangles are added to the same
    picturebox.  Hence another tracking method is needed.

Mr. Serflaten:

   Originally had thought of using a collection of lines -- a structured
array
   is basically the same thing, but wasn't sure how to go about handling
    the addition of circles and rectangles within the "line" collection.

==========================
After playing with this last evening, looks like some form of MetaFile
may work best.  The biggest issue with a MetaFile as I see it is
finding the right entry to delete and then flag when one object is moved.


Quote:


>> One thought is something like this:

> This is yet another example of a person asking what a forest is, when
> they bring you a leaf.  "I've got this leaf, how do I connect it to a
> branch?"

> So far, its told:

> 1. There are pictureboxes
> 2. There are lines in the pictureboxes.
> 3. The first line in a picturebox determines the scale.
> 4. Lines can be moved among pictureboxes.

> And the question;

> How does a picturebox know what line governs the scale?

> How about this for an answer....

> Associate a Collection of lines to each picturebox and make the first
> line in the collection the controlling entity.

> LFS



Tue, 31 Jul 2012 22:37:51 GMT  
 Tracking whats in Each Picturebox


Quote:
>    Originally had thought of using a collection of lines -- a structured
> array
>    is basically the same thing, but wasn't sure how to go about handling
>     the addition of circles and rectangles within the "line" collection.

Forms have a collection of controls, (even a Shape control) and it is
capable of showing each type of control as they are meant to be shown.
Plus Form's seem to keep track of the one control that has the focus.

As you see, the form's collection contains different types of controls.

How did they do that?  And, isn't that about the same thing that you
want to do?

LFS



Tue, 31 Jul 2012 22:54:13 GMT  
 Tracking whats in Each Picturebox
Regarding

Quote:
>>As you see, the form's collection contains different types of controls.
>>How did they do that?  And, isn't that about the same thing that you

want to do?

=============
Never made that "link", but good analogy.
Now the issue is -- How did they do that??


Quote:


>>    Originally had thought of using a collection of lines -- a structured
>> array
>>    is basically the same thing, but wasn't sure how to go about handling
>>     the addition of circles and rectangles within the "line" collection.

> Forms have a collection of controls, (even a Shape control) and it is
> capable of showing each type of control as they are meant to be shown.
> Plus Form's seem to keep track of the one control that has the focus.

> As you see, the form's collection contains different types of controls.

> How did they do that?  And, isn't that about the same thing that you
> want to do?

> LFS



Wed, 01 Aug 2012 00:28:36 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Help!! Loading PictureBox FromStream and PictureBox.Image.Save

2. Best way to preview a font in a PictureBox (WAS: Question on Picturebox or an alternative)

3. copying a modified picturebox into a new picturebox

4. Copy picturebox to another picturebox

5. PictureBox inside PictureBox...

6. Best way to preview a font in a PictureBox (WAS: Question on Picturebox or an alternative)

7. copying offscreen picturebox to another picturebox

8. Best way to preview a font in a PictureBox (WAS: Question on Picturebox or an alternative)

9. WHATS WRONG with this outlook!!please HELP!!!

10. Whats wrong with SQL statement for OpenForm

11. Whats wrong with withis code???

12. Whats Wrong with this CODE!

 

 
Powered by phpBB® Forum Software