Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Code to Create Menus from Database List (Help!)

5 posts in Objects Last posting was on 2008-02-25 00:22:49.0Z
ccurzon Posted on 2008-02-12 01:11:13.0Z
From: ccurzon@hmsy.com
Newsgroups: sybase.public.powerbuilder.objects
Subject: Code to Create Menus from Database List (Help!)
Date: Mon, 11 Feb 2008 17:11:13 -0800 (PST)
Organization: http://groups.google.com
Lines: 43
Message-ID: <4ebdc9e8-a3fc-4aae-9267-9808f4e242e3@u10g2000prn.googlegroups.com>
NNTP-Posting-Host: 65.89.248.222
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1202778673 1656 127.0.0.1 (12 Feb 2008 01:11:13 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 12 Feb 2008 01:11:13 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: u10g2000prn.googlegroups.com; posting-host=65.89.248.222; posting-account=aogDZQoAAAB4CWjuN32sPYd7jay4LSWd
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe)
Path: forums-1-dub!forums-master!newswest.sybase.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!u10g2000prn.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.objects:9605
Article PK: 736748

(My apologies, I first directed this post to the futures discussion.
But it doesn't really belong there. Sorry, this is the first time
I've posted to a newsgroup.)


I need a PowerBuilder library, or some good example of source code
which can take a hierarchically structured list and turn it into a
functioning menu structure. (I'm not a PB programmer but would like
to show this example to our PB programmer on staff.)

For example, this list:

1 File
1.1 New
1.2 Open
1.3 Close
2 Edit
2.1 Undo
2.2 Send To
2.2.1 Mail Recipient
2.2.2 Routing Recipient
2.2.3 Exchange Folder

Would let the library create top level File and Edit menus. The File
menu would have 3 choices (New, Open, Close). The Edit menu would
have 2 choices (Undo, Send To) and the Send To sub-menu would have 3
choices (Mail Recipient, Routing Recipient, Exchange Folder).

The ultimate goal is to store the list in a relational database
(Oracle), Upon starting the application, this list would be fed to PB
and PB would set up the menus for the current user.

Please tell me this is not hard.

Now, please tell me truthfully whether this actually more difficult
than I imagine!

:-) :-)

Thanks for any help.

-- Chris


Jeremy Lakeman Posted on 2008-02-12 22:35:39.0Z
From: Jeremy Lakeman <jeremy.lakeman@gmail.com>
Newsgroups: sybase.public.powerbuilder.objects
Subject: Re: Code to Create Menus from Database List (Help!)
Date: Tue, 12 Feb 2008 14:35:39 -0800 (PST)
Organization: http://groups.google.com
Lines: 93
Message-ID: <cfd377a2-50a0-49c2-a080-7ff105fb46fb@s13g2000prd.googlegroups.com>
References: <4ebdc9e8-a3fc-4aae-9267-9808f4e242e3@u10g2000prn.googlegroups.com>
NNTP-Posting-Host: 203.8.163.252
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1202855739 22417 127.0.0.1 (12 Feb 2008 22:35:39 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 12 Feb 2008 22:35:39 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: s13g2000prd.googlegroups.com; posting-host=203.8.163.252; posting-account=euaBtgoAAAC_vDxfsxmpMKlBxHaHpmRS
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 fly.essential.com.au:3128 (squid/2.5.STABLE8)
Path: forums-1-dub!forums-master!newswest.sybase.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!s13g2000prd.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.objects:9606
Article PK: 736753

It's not that difficult, but it's not really supported by sybase
either.

create a class inherited from menu say m_dynamic.

in m_dynamic create a function called of_create()
edit the source of m_dynamic and add a call to of_create at the end of
the on.create method like this;

if isvalid(getapplication()) then of_create()

NEVER EVER EVER open and save this class in the IDE again, or you will
have to repeat that step to add the function call back

Now create a class inherited from m_dynamic.

In the of_create function you can create any number of menu classes,
assigned them to the item array, and set their properties.
for example;

subroutine of_create();
of_create_children(0,this)
end subroutine

subroutine of_create_children(long al_parent, menu am_parent);
long ll_row
m_menu_item lm_item
gds_menu_items.setfilter('parent = '+al_parent)
gds_menu_items.filter()
for ll_row = 1 to gds_menu_items.rowcount()
lm_item=create m_menu_item
// todo, set the properties of the menu item from the datastore
item[ll_row]=lm_item
next
end subroutine

Then you will need a menu class that can do something when you click
on it based on its configuration.
For example;

event m_menu_item.clicked();
window lw_win
choose case is_command_type
case 'open'
opensheet(lw_win,is_window_class,w_frame,0,original!)
case 'event'
parentwindow.triggerevent(is_event_name)
end choose
end event

On Feb 12, 11:11 am, ccur...@hmsy.com wrote:
> (My apologies, I first directed this post to the futures discussion.
> But it doesn't really belong there. Sorry, this is the first time
> I've posted to a newsgroup.)
>
> I need a PowerBuilder library, or some good example of source code
> which can take a hierarchically structured list and turn it into a
> functioning menu structure. (I'm not a PB programmer but would like
> to show this example to our PB programmer on staff.)
>
> For example, this list:
>
> 1 File
> 1.1 New
> 1.2 Open
> 1.3 Close
> 2 Edit
> 2.1 Undo
> 2.2 Send To
> 2.2.1 Mail Recipient
> 2.2.2 Routing Recipient
> 2.2.3 Exchange Folder
>
> Would let the library create top level File and Edit menus. The File
> menu would have 3 choices (New, Open, Close). The Edit menu would
> have 2 choices (Undo, Send To) and the Send To sub-menu would have 3
> choices (Mail Recipient, Routing Recipient, Exchange Folder).
>
> The ultimate goal is to store the list in a relational database
> (Oracle), Upon starting the application, this list would be fed to PB
> and PB would set up the menus for the current user.
>
> Please tell me this is not hard.
>
> Now, please tell me truthfully whether this actually more difficult
> than I imagine!
>
> :-) :-)
>
> Thanks for any help.
>
> -- Chris


Roland Smith [TeamSybase] Posted on 2008-02-22 18:39:44.0Z
From: "Roland Smith [TeamSybase]" <rsmith_at_trusthss_dot_com>
Newsgroups: sybase.public.powerbuilder.objects
References: <cfd377a2-50a0-49c2-a080-7ff105fb46fb@s13g2000prd.googlegroups.com> <47befb91.747.1681692777@sybase.com>
Subject: Re: Code to Create Menus from Database List (Help!)
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47bf16f0$1@forums-1-dub>
Date: 22 Feb 2008 10:39:44 -0800
X-Trace: forums-1-dub 1203705584 10.22.241.152 (22 Feb 2008 10:39:44 -0800)
X-Original-Trace: 22 Feb 2008 10:39:44 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.objects:9609
Article PK: 736754

Steven,

I have been using PowerBuilder for 15 years and I have no idea how to create
a menu on the fly. As a beginner perhaps you should stick to the basics of
PowerBuilder until you are more experienced.

There is a much easier way of creating dynamic menus that you should try.

First create a menu object in the menu painter and add every possible menu
item. Add a function to the menu object. Inside that function, you can
change the visible property to False for any items you do not want to see.

In the window open event, code something like this:

Menu lm_menu

lm_menu = this.MenuID

lm_menu.Dynamic mf_myfunc()

Roland


Jeremy Lakeman Posted on 2008-02-25 00:22:49.0Z
From: Jeremy Lakeman <jeremy.lakeman@gmail.com>
Newsgroups: sybase.public.powerbuilder.objects
Subject: Re: Code to Create Menus from Database List (Help!)
Date: Sun, 24 Feb 2008 16:22:49 -0800 (PST)
Organization: http://groups.google.com
Lines: 134
Message-ID: <d5ce7387-0dfa-40c8-a6a4-392cd0df8422@m23g2000hsc.googlegroups.com>
References: <cfd377a2-50a0-49c2-a080-7ff105fb46fb@s13g2000prd.googlegroups.com> <47befb91.747.1681692777@sybase.com>
NNTP-Posting-Host: 203.122.242.105
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1203898969 22578 127.0.0.1 (25 Feb 2008 00:22:49 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 25 Feb 2008 00:22:49 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: m23g2000hsc.googlegroups.com; posting-host=203.122.242.105; posting-account=euaBtgoAAAC_vDxfsxmpMKlBxHaHpmRS
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 asp.essential.intranet:3128 (squid/2.5.STABLE8)
Path: forums-1-dub!forums-master!newssvr.sybase.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!m23g2000hsc.googlegroups.com!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.objects:9610
Article PK: 736757

According to google, there are a couple of ways;

http://eric.aling.tripod.com/PB/tips/pbtip37.htm
http://www.softtreetech.com/hightech/tips.htm#Secrets%20of%20Menus%20-%20Dynamically%20Adding%20New%20Menu%20Items

Though both of these seem to be using hide() show() to trick PB into
rebuilding the win32 menu objects after manipulating the item array.

Then there is the method I outlined previously which replaces the
normal static on.create with a dynamic process. Which I have used a
couple of times.

But as Roland suggested, if you don't really need a dynamic menu,
don't try to create one. If all you want is to hide menu items that
are not currently relevant, just do that.

On Feb 23, 2:42 am, Steven wrote:
> Hi Jeremy;
> Seems you're so active this recently. given contribute lots
> of answers.
>
> Would you to give me a concept to creating of menu via
> script.
> Because I don't have the basic of understanding to creating
> menu by script.
>
> just do a simple on as :
> menubar = "File"
> menuitem = {"open", "Edit" }
>
> Then guide me, when user clicking the menuitem of "open"
> let say just opening window "w_1"
>
> Please advice & thanks in advance
>
> Regards,
> Steven
>
> > It's not that difficult, but it's not really supported by
> > sybase either.
>
> > create a class inherited from menu say m_dynamic.
>
> > in m_dynamic create a function called of_create()
> > edit the source of m_dynamic and add a call to of_create
> > at the end of the on.create method like this;
>
> > if isvalid(getapplication()) then of_create()
>
> > NEVER EVER EVER open and save this class in the IDE again,
> > or you will have to repeat that step to add the function
> > call back
>
> > Now create a class inherited from m_dynamic.
>
> > In the of_create function you can create any number of
> > menu classes, assigned them to the item array, and set
> > their properties. for example;
>
> > subroutine of_create();
> > of_create_children(0,this)
> > end subroutine
>
> > subroutine of_create_children(long al_parent, menu
> > am_parent); long ll_row
> > m_menu_item lm_item
> > gds_menu_items.setfilter('parent = '+al_parent)
> > gds_menu_items.filter()
> > for ll_row = 1 to gds_menu_items.rowcount()
> > lm_item=create m_menu_item
> > // todo, set the properties of the menu item from the
> > datastore
> > item[ll_row]=lm_item
> > next
> > end subroutine
>
> > Then you will need a menu class that can do something when
> > you click on it based on its configuration.
> > For example;
>
> > event m_menu_item.clicked();
> > window lw_win
> > choose case is_command_type
> > case 'open'
> > opensheet(lw_win,is_window_class,w_frame,0
> > ,original!)
> > case 'event'
> > parentwindow.triggerevent(is_event_name)
> > end choose
> > end event
>
> > On Feb 12, 11:11 am, ccur...@hmsy.com wrote:
> > > (My apologies, I first directed this post to the futures
> > > discussion. But it doesn't really belong there. Sorry,
> > > this is the first time I've posted to a newsgroup.)
>
> > > I need a PowerBuilder library, or some good example of
> > > source code which can take a hierarchically structured
> > > list and turn it into a functioning menu structure.
> > > (I'm not a PB programmer but would like to show this
> > example to our PB programmer on staff.) >
> > > For example, this list:
>
> > > 1 File
> > > 1.1 New
> > > 1.2 Open
> > > 1.3 Close
> > > 2 Edit
> > > 2.1 Undo
> > > 2.2 Send To
> > > 2.2.1 Mail Recipient
> > > 2.2.2 Routing Recipient
> > > 2.2.3 Exchange Folder
>
> > > Would let the library create top level File and Edit
> > > menus. The File menu would have 3 choices (New, Open,
> > > Close). The Edit menu would have 2 choices (Undo, Send
> > > To) and the Send To sub-menu would have 3 choices (Mail
> > Recipient, Routing Recipient, Exchange Folder). >
> > > The ultimate goal is to store the list in a relational
> > > database (Oracle), Upon starting the application, this
> > > list would be fed to PB and PB would set up the menus
> > for the current user. >
> > > Please tell me this is not hard.
>
> > > Now, please tell me truthfully whether this actually
> > > more difficult than I imagine!
>
> > > :-) :-)
>
> > > Thanks for any help.
>
> > > -- Chris