gettingstarted
[Top] [All Lists]

Re: Array of Canvas Controls

To: "Getting Started" <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Array of Canvas Controls
From: "CV" <atauqua at hit dot net>
Date: Fri, 31 Oct 2003 16:00:45 -0600
References: <BBC731B7 dot 159E%bart at atkinsimages dot com>
Bart,

If you decide to use a grid of separate canvases, you can create the grid as
you would for any rectangle control using some basic considerations.

In order to clone controls, you first place a control of the right type on
your window,
say it is a canvas named c in the Property window, indexed to 0. The first
cloned control
will be index 1.

You can generate the new controls like this:

dim b as canvas

For i = 1 to NumControls - 1 // NumControls is the total number of controls
    b = new c
Next

All the new controls are located directly on top of c(0). To create
a grid of NumColumns, in two steps for clarity, you would have code like
this after assigning values to NumColumns, VertSpacing, and HorizSpacing:

//Place them into rows:
row = 1
For i = 1 to NumControls - 1
    If i >= row*NumColumns then
        row = row + 1
    End if
    c(i).top = c(0).top + (row-1)*(c(0).height + VertSpacing)
Next
//Sort into the columns
For j = 0 to NumColumns - 1
    For i = 0 to NumControls - 1 then
        If (i-j) mod NumColumns = 0 then
            c(i).left = c(0).left + (j)*(c(0).width + HorizSpacing)
        End if
    Next
Next

If flicker (on Windows) is a problem, just set c(0) to not visible, then
loop through at the end and set all to visible.

Jack


>I imagine I must make a dynamic array consisting of
> the number of images in a folder/directory, but how then do I display them
> in a grid fashion on the window?
>
> Any thoughts/ideas are graciously welcomed.
>



 - - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>