However, I am trying to disable one of the menu entries and I see no evidence that disable worked. The menu item is not grayed, and I can still click it.
The line, DisableMenuItem(PopupMenuOfCtlPorts,MenuItem,Bool(CommPortSim = thisSerialPort)) compares two strings, and if they are equal should disable one of the menu items.
I tried replacing Bool(CommPortSim = thisSerialPort) with a 1, and I expected all of the menuitems to disable in the foreach. It doesn't seem to happen. They are not grayed and are clickable.
Anything obvious?
Code: Select all
PopupMenuOfCtlPorts = CreatePopupMenu(#PB_Any)
ListCommPorts(ListOfCommPorts())
MenuItem = #MenuItemCtlFirstPort
ForEach ListOfCommPorts()
thisSerialPort = ListOfCommPorts()
; add the comm port to the menu
MenuItem(MenuItem,thisSerialPort)
; if the simulator has claimed it, disable it
DisableMenuItem(PopupMenuOfCtlPorts,MenuItem,Bool(CommPortSim = thisSerialPort))
; if it was the last one selected, check it
SetMenuItemState(PopupMenuOfCtlPorts,MenuItem,Bool(CommPortCtl = thisSerialPort))
BindMenuEvent(PopupMenuOfCtlPorts,MenuItem,@onPortSelected())
MenuItem = MenuItem + 1
Next
DisplayPopupMenu(PopupMenuOfCtlPorts,Window_0)