PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Sub Menu help  (Read 228 times)

Dennis Allen

  • FireFly3 Registered User
  • Little Newbie FireFly
  • *
  • Posts: 13
  • FF3 User
Sub Menu help
« on: June 07, 2017, 01:59:00 PM »

Hi,
I am trying to implemet a context menu with a sub menu.
When the "Views" item is selected I would like the sub menu to appear.
What am I doing wrong here?

'--------------------------------------------------------------------------------
'Menu items
%IDM_FIT       = 2001   ' Fit
%IDM_ROTATE    = 2002   ' Rotate
%IDM_ZOOMIN    = 2003   ' Zoom In
%IDM_ZOOMOUT   = 2004   ' Zoom Out
%IDM_PAN       = 2005   ' Pan
%IDM_LASTVIEW  = 2006   ' Last View
%IDM_NEXTVIEW  = 2007   ' Next View
%IDM_REPAINT   = 2008   ' Repaint
%IDM_VIEWS     = 2009   ' Views
%IDM_DELETE    = 2010   ' Delete
%IDM_TRANSFORM = 2011   ' Transform
%IDM_OPMNGR    = 2002   ' Operations Manager

%IDM_TOP       = 3001   ' Top
%IDM_FRONT     = 3002   ' Front
%IDM_BACK      = 3003   ' Back
%IDM_BOTTOM    = 3004   ' Bottom
%IDM_RIGHT     = 3005   ' Right
%IDM_LEFT      = 3006   ' Left
%IDM_ISOMETRIC = 3007   ' Isometric

'--------------------------------------------------------------------------------
Function MAIN_WM_CONTEXTMENU ( _
                             hWndForm      As Dword, _  ' handle of Form
                             xPos          As Long,  _  ' x-coordinate of cursor
                             yPos          As Long   _  ' y-coordinate of cursor
                             ) As Long
               
               Local hPopUpMenu As Dword         'handle for main popup
               Local subMenu As Dword            'handle for sub menu                                                       
               Local lngRetVal            As Long
               Local ptScreenCursorPos    As Point             
               
               hPopUpMenu = CreatePopupMenu       ' create handle for context menu
               subMenu = CreatePopupMenu          ' create handle for sub menu menu 
                                       
               subMenu =  GetSubMenu(hPopUpMenu,9) ' create handle for sub menu
               
              'Build the context menu
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_FIT, "&Fit"
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_ROTATE, "&Rotate"
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_ZOOMIN, "&Zoom In"
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_ZOOMOUT, "&Zoom Out"               
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_PAN, "&Pan"
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_LASTVIEW, "&Last View"
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_NEXTVIEW, "&Next View"
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_REPAINT, "&Repaint"
                AppendMenuW hPopUpMenu, %MF_SEPARATOR, 0, ""
                AppendMenuW hPopUpMenu, %MF_POPUP, %IDM_VIEWS, "&Views" To subMenu
                AppendMenuW hPopUpMenu, %MF_SEPARATOR, 0, ""               
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_DELETE, "&Delete"
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_TRANSFORM, "&Transform"
                AppendMenuW hPopUpMenu, %MF_SEPARATOR, 0, ""
                AppendMenuW hPopUpMenu, %MF_ENABLED, %IDM_OPMNGR, "&Operations Manager"               
                'Build the sub menu
                AppendMenuW subMenu, %MF_ENABLED, %IDM_TOP, "&Top"
                AppendMenuW subMenu, %MF_ENABLED, %IDM_FRONT, "&Front"
                AppendMenuW subMenu, %MF_ENABLED, %IDM_BACK, "&Back"
                AppendMenuW subMenu, %MF_ENABLED, %IDM_BOTTOM, "&Bottom"               
                AppendMenuW subMenu, %MF_ENABLED, %IDM_RIGHT, "&Right"
                AppendMenuW subMenu, %MF_ENABLED, %IDM_LEFT, "&Left"
                AppendMenuW subMenu, %MF_ENABLED, %IDM_ISOMETRIC, "&Isometric"
                       
               lngRetVal = GetCursorPos(ptScreenCursorPos)  'read the pointer position to locate the popup menu
   
               If lngRetVal <> 0 Then  'display the context menu
                    TrackPopupMenu hPopupMenu, %TPM_LEFTALIGN Or %TPM_LEFTBUTTON, ptScreenCursorPos.x, ptScreenCursorPos.y, 0, hWndForm, ByVal %Null                   
               End If
               
               DestroyMenu hPopupMenu                   

End Function




Thanks for any help in advance!

Ron
Logged

Pierre Bellisle

  • FireFly3 User
  • Junior FireFly Member
  • *
  • Posts: 57
Re: Sub Menu help
« Reply #1 on: June 07, 2017, 03:47:00 PM »

Hi Denis,

Try...

Rem out subMenu =  GetSubMenu(hPopUpMenu,9) ' create handle for sub menu

Rem out AppendMenuW hPopUpMenu, %MF_POPUP, %IDM_VIEWS, "&Views" To subMenu
Add AppendMenuW hPopUpMenu, %MF_POPUP OR %MF_ENABLED, subMenu, "&Views"

Pierre
Logged

Dennis Allen

  • FireFly3 Registered User
  • Little Newbie FireFly
  • *
  • Posts: 13
  • FF3 User
Re: Sub Menu help
« Reply #2 on: June 07, 2017, 04:52:14 PM »

Hi,

Thank you very much.
Don't know how you found that in the docs, but it now works and I am grateful!

regards,
Ron
Logged

Pierre Bellisle

  • FireFly3 User
  • Junior FireFly Member
  • *
  • Posts: 57
Re: Sub Menu help
« Reply #3 on: June 07, 2017, 05:07:28 PM »

Hi Dennis,

From MSDN AppendMenu function

AppendMenu(hMenu, uFlags, uIDNewItem, lpNewItem)

Look at uIDNewItem...
uIDNewItem: The identifier of the new menu item or, if the uFlags parameter is set to MF_POPUP, a handle to the drop-down menu or submenu.

Pierre
Logged