ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6


3 - Listening and Talking

Once you have a menu, how do you interact with it? Your window's message handler needs to respond to two messages - one to display the menu, and one to perform the action:


S32 CWindow1::MsgHandler(MSG_TYPE type,CViewable*from,S32 data)
{
  switch (type)
  {
    case MSG_KEY: // menu to be displayed?
      if (data == K_MENU)
        m_menu->Show(); // then show it
      return 1;
    case MSG_MENU_SELECT: // menu now visible & selection made
    {
      int value=0;
      switch ((U16)data)
      {
        case IDM_HELP: // our selection for help

          <help code here>

        case IDM_EXIT: // our selection for quitting

          <exit code here>

<...and so on...>

The K_MENU flag is sent to show the menu; once visible, pen presses on message items will trigger the appropriate MSG_MENU_SELECT message.

In the SetRow() calls, another entry follows the menu row caption - the shortcut character. When the menu is visible, this letter can be entered to activate the option. If left off, there is no shortcut to the menu. Note that the window must be open - if you want to detect menu shortcuts when the menu is closed, you'll need to add a specific test when processing your MSG_KEY messages.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice