Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HELP: Getting menu items

1 view
Skip to first unread message

Kevin O'Malley

unread,
Mar 15, 1995, 11:48:24 AM3/15/95
to
I am writing a program where I keep a menu of user created plots. The menu
is structured as follows:

title: Plots
item 1: Delete Current Plot (created in .rc file)
item 2: Seperater
item 3..n: plot names created by the user during program execution

I am adding menu items using the AppendMenu function, with the "idNewItem"
argument being the plot number. So, the 1st plot idNewItem is 1, 2nd plot
idNewItem is 2, and so on.

I would like a function that would return the menu item selected from
the "Plots" menu. So, if the user selects item n, I know what plot they
would like to display.

I have looked through the Petzold book but am unable to find any examples.
What is the best way to implement such a thing?

--
Kevin O'Malley
Programmer/Analyst
Transportation Research Institute
University of Michigan (UMTRI)
oma...@umich.edu

John Grant

unread,
Mar 15, 1995, 1:51:23 PM3/15/95
to
In article <omalley-1503...@erdpc-13.umtri.umich.edu> oma...@umich.edu (Kevin O'Malley) writes:
>I am writing a program where I keep a menu of user created plots. The menu
>is structured as follows:
>
> title: Plots
> item 1: Delete Current Plot (created in .rc file)
> item 2: Seperater
> item 3..n: plot names created by the user during program execution
>
>I am adding menu items using the AppendMenu function, with the "idNewItem"
>argument being the plot number. So, the 1st plot idNewItem is 1, 2nd plot
>idNewItem is 2, and so on.
>
>I would like a function that would return the menu item selected from
>the "Plots" menu. So, if the user selects item n, I know what plot they
>would like to display.
>
>I have looked through the Petzold book but am unable to find any examples.
>What is the best way to implement such a thing?

When you use AppendMenu(), you will give each one a number, i.e.
perhaps 1000+i (where i=0,1,2,3,4). When you get WM_COMMAND
message, it will tell you the menu id number. Simply subtract
1000 and you will get 'i'.
--
John A. Grant jag...@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa

Ed McCreary

unread,
Mar 15, 1995, 2:32:41 PM3/15/95
to
In article <omalley-1503...@erdpc-13.umtri.umich.edu> oma...@umich.edu (Kevin O'Malley) writes:
I am writing a program where I keep a menu of user created plots. The menu
is structured as follows:

title: Plots
item 1: Delete Current Plot created in .rc file)


item 2: Seperater
item 3..n: plot names created by the user during program execution

I am adding menu items using the AppendMenu function, with the "idNewItem"
argument being the plot number. So, the 1st plot idNewItem is 1, 2nd plot
idNewItem is 2, and so on.

I would like a function that would return the menu item selected from
the "Plots" menu. So, if the user selects item n, I know what plot they
would like to display.

When you create the menu's, you need to maintain a table that maps item
id to the plot function. When a user selects a menu item, a WM_COMMAND
is sent to the window which owns the menu. wParam is the menu
id. Just use the id to look up which function to call.

--
.__o Ed McCreary "The Information Superhighway, sanitized
_-\ <,- Compaq Computers for your protection."
(*)/ (*) e...@twisto.compaq.com

0 new messages