gettingstarted
[Top] [All Lists]

RE: MenuItems.

To: "'Getting Started'" <gettingstarted at lists dot realsoftware dot com>
Subject: RE: MenuItems.
From: "POIDINGER, Michael [JJRAU]" <MPOIDING at MEDAU dot JNJ dot com>
Date: Tue, 1 Mar 2005 09:12:36 +1100
Delivered-to: gettingstarted at lists dot realsoftware dot com

  

> -----Original Message-----
> From: gettingstarted-bounces at lists dot realsoftware dot com 
> [mailto:gettingstarted-bounces at lists dot realsoftware dot com] On 
> Behalf Of Michael
> Sent: Tuesday, March 01, 2005 7:27 AM
> To: Getting Started
> Subject: MenuItems.
> 
> Hi List,
> I have a question about dynamic menuItems.
> I am able to create them ok, but they are not enabled...and I 
> think the reason is they do not have menuhandler code. But, I 
> cannot create the code for this as the menuItems are not 
> created until run time. So, how does one create the code for 
> the menuhandlers for a menuItem which has not yet been created?
> If this is not too articulate, then it is probably because I 
> do not yet fully understand the issue.
> Thanks in advance.

You have two options
1) Create the dynamic menuItems as a control array, and have the menuhandler
code be able to handle the menu item based on its index

2) Subclass MenuItem, give it code in its action event, and add the dynamic
menuItems as instances of your subclass, rather than just menuItem.  In this
case you are obviously free to add other methods and properties to the
object, giving you greater flexibility as to what clicking on the menuitem
does.  As an example, I have created a WindowMenuItem as a subclass of
MenuItem.  The action event contains

  dim i as integer
  dim w as expwindow  //a subclassed window
  
  i = val(me.name)
  w = MainWindow.childWindows.value(i)   //a dictionary of windows that
hangs off the mainwindow
  w.show()


elsewhere I have
    m = MainMenuBar.child("myWindows")
    newM = new windowMenu
    newM.Name = str(eKey)
    newM.Text = t.title
    newM.autoEnable = true
    m.append(newM)

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

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

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