Xojo Conferences
XDCMay2019MiamiUSA

Dim On-the-Fly (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: Best practice for passing data between two windows
Next thread: PPAT


RB Database   -   tom.russell transport.alstom.com
  Dim On-the-Fly   -   Chuck Pelto
   Re: Dim On-the-Fly   -   Steve Garman
   Re: Dim On-the-Fly   -   Arnaud Nicolet

Dim On-the-Fly
Date: 06.02.06 22:11 (Mon, 6 Feb 2006 14:11:20 -0700)
From: Chuck Pelto
How would one go about doing a dim statement on the fly in an
application?

Situation: Building multiple menu items in a contextual menu and
multiple submenu items to go with said menu items, when the number of
menu items with submenus is variable.

Looking at the New ContextualMenu Build example, they've got just one
submenu. In there one has to dim the submenu and give it a name. This
is all well and good in hard-wiring code when one knows the number of
items that will have submenus, but what if any number of menu items
could have submenus associated with them?

It looks like one has to dim submenus as they come up. One can't just
use the statement...

dim submenu as new MenuItem("SubMenu")

....over and over again. One would lose anything that was built in
any previous 'submenu' items. Would they not?

So, what is to be done? I'm sure this issue has come up before, but
I'm unfamiliar with the solution.

Regards,

Chuck
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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

Re: Dim On-the-Fly
Date: 06.02.06 22:31 (Mon, 6 Feb 2006 21:31:01 +0000)
From: Steve Garman
In a message regarding Dim On-the-Fly dated Mon, 6 Feb 2006 14:11:20 -0700,
Chuck Pelto said that ...

> How would one go about doing a dim statement on the fly in an
> application?

> Situation: Building multiple menu items in a contextual menu and
> multiple submenu items to go with said menu items, when the number of
> menu items with submenus is variable.

Oversimplified example:

for i as integer = 1 to 10
dim submenu as new MenuItem("SubMenu"+cstr(i))
MenuBar1.Child("FileMenu").append Submenu
next i

Re: Dim On-the-Fly
Date: 07.02.06 01:10 (Tue, 7 Feb 2006 01:10:40 +0100)
From: Arnaud Nicolet
Le 6 févr. 06, à 22:11, Chuck Pelto a écrit :

> How would one go about doing a dim statement on the fly in an
> application?
>
> Situation: Building multiple menu items in a contextual menu and
> multiple submenu items to go with said menu items, when the number of
> menu items with submenus is variable.
>
> Looking at the New ContextualMenu Build example, they've got just one
> submenu. In there one has to dim the submenu and give it a name. This
> is all well and good in hard-wiring code when one knows the number of
> items that will have submenus, but what if any number of menu items
> could have submenus associated with them?
>
> It looks like one has to dim submenus as they come up. One can't just
> use the statement...
>
> dim submenu as new MenuItem("SubMenu")
>
> ....over and over again. One would lose anything that was built in any
> previous 'submenu' items. Would they not?
>
> So, what is to be done? I'm sure this issue has come up before, but
> I'm unfamiliar with the solution.
>

When I tried RB2005, I created an application with a multicolumns
listbox. The user enters texts in some cells (like a menu: the left
column is the base menu; the second column is the submenu of the item
in left). When the user control-clicked a canvas, I built the menu
entered in the listbox.
Basically, I did so:

'"Base" is the parameter for the base menu item
dim n As MenuItem

n=new MenuItem
n.Enabled=True
n.Tag=j*1000+i 'Used to identify the menu; i and j are loop variables
n.Text=s(i) 'You know what to assign ;-)
base.append n

so, when you do "n=new MenuItem" for the second time, n is not
forgotten (it is kept in "base"). If you want to retrieve it, look for
an item with the tag you assigns.

I'm completely wrong, or you asked for something like that?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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