PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: wfxPopupMenu  (Read 74 times)

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9109
  • Windows 10
    • PlanetSquires Software
wfxPopupMenu
« on: March 07, 2020, 01:28:57 PM »

A little preview from next WinFBE update (2.0.8).

I thought it would be convenient to have a simple popup menu class.

Here is an example for displaying a popup menu when a TreeView node is right-clicked:

Code: [Select]
''
''
Function frmMain_TreeView1_MouseDown( ByRef sender As wfxTreeView, ByRef e As EventArgs ) As LRESULT
   
   if e.RButton then
      ' Determine if we have clicked on a TreeNode
      dim as wfxPoint wpt = e.pt
      wpt.Convert( frmMain.TreeView1.hWindow )
     
      ' Only continue if the TreeNode is valid
      dim byref TreeNode as wfxTreeNode = sender.GetNodeAt( wpt )
      if TreeNode.hNode = 0 then exit function
     
      ' Ensure that the node right clicked on is now selected
      TreeNode.Selected = true
     
      dim as wfxPopupMenu PopMenu
      PopMenu.AddItem( "Menu Option 1", 1 )
      PopMenu.AddItem( "Menu Option 2", 2 )
      PopMenu.AddItem( "Menu Option 3", 3 )
      PopMenu.AddSeparator
      PopMenu.AddItem( "Menu Option 4", 4 )
     
      ' Show the popup menu (need to use screen coordinates rather than client coordinates)
      dim as long nResult = PopMenu.Show( sender.hWindow, e.x, e.y )
     
      AfxMsg( "You selected menu option: " & nResult )
     
      select case nResult
         case 1
         case 2
         case 3
         case 4   
      end select
   end if
   
   Function = 0
End Function

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer