Try it for your self:
Define a popumenu and load it in an MDI-Window
VisMenuDisable(hMenu, nCount ) - returns 1
EDIT: Set Enabled When : FALSE
VisMenuIsEnabled(hMenu, nCount ) - returns 0
=> Menuitem is disabled
VisMenuEnable(hMenu, nCount ) - returns 1
EDIT: Set Enabled When : TRUE
VisMenuIsEnabled(hMenu, nCount ) - returns 0
=> Menuitem is enabled
UseNativeSalMenus = 0 and I also tried it via WinAPI hacking, GetMenuState and even with GetMenuItemInfoW - there is actually no chance to get the correct initial state of menuitems.
EDIT: VisMenuIsEnabled(hMenu, nCount ) only returns 1 if the referenced menuitem is an other (active) submenu.
TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
Last edited by OeavDev on 15 May 2024, 12:29, edited 3 times in total.
Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
Do you have a small sample code showing the problem?
We had another problem with popup menus in TD 7.4.x and got a fix for this.
Maybe the problem is fixed in the latest 7.4.6?
I could check this for you...
Rainer
We had another problem with popup menus in TD 7.4.x and got a fix for this.
Maybe the problem is fixed in the latest 7.4.6?
I could check this for you...
Rainer
Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
The actual situation is a little bit different to my initial findings (see my EDIT)
VisMenuIsEnabled does not get the original defined state:
On MenuItems VisMenuIsEnabled always return 0, no matter if "Enabled When" is set to TRUE or FALSE
On PopupMenis VisMenuIsEnabled always return 1, no matter if "Enabled When" is set to TRUE or FALSE
Only after VisMenuEnable / VisMenuDisable is called, VisMenuIsEnabled returns the correct state.
You can reproduce this behaviour with the attached sample code (just change the values in the combobox with arrow up/down and see the state of the checkbox)
EDIT - more findings:
- After you disable/enable the popupmenu (Item4), the states of all other items in the menu are correctly returned - even if they were not manually disabled/enabled before...
- enabling the pupupmenu (Item4) does not seem to work for the popupmenu. it is stil disabling (just like its initial state was)
- disabling/enabling menuitems is working fine
maybe I overlooked something, but this really seems not to work as it should
VisMenuIsEnabled does not get the original defined state:
On MenuItems VisMenuIsEnabled always return 0, no matter if "Enabled When" is set to TRUE or FALSE
On PopupMenis VisMenuIsEnabled always return 1, no matter if "Enabled When" is set to TRUE or FALSE
Only after VisMenuEnable / VisMenuDisable is called, VisMenuIsEnabled returns the correct state.
You can reproduce this behaviour with the attached sample code (just change the values in the combobox with arrow up/down and see the state of the checkbox)
EDIT - more findings:
- After you disable/enable the popupmenu (Item4), the states of all other items in the menu are correctly returned - even if they were not manually disabled/enabled before...
- enabling the pupupmenu (Item4) does not seem to work for the popupmenu. it is stil disabling (just like its initial state was)
- disabling/enabling menuitems is working fine
maybe I overlooked something, but this really seems not to work as it should
You do not have the required permissions to view the files attached to this post.
Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
I have checked this with TD 7.4.6 ONEOFF12 (as of 24.04.2024): The behaviour is the same as in your version.
And I figured out:
VisMenuIsEnabled() does work without first enabling the submenu, if you first display the menu in the MDI and then click on 'Get Item Info'.
I've looked at the online help and it tells:
"...Uses the Windows enable state to test whether a menu item is enabled. VisMenuIsEnabled must be called in the Enabled When section of the SQLWindows outline in order to properly display the enable status of a SQLWindows menu item."
=> This explains why the function does not work as you want to use it. It only works, if SQLWindows previously did load the menu (which obviously also happens, if you try to modify the submenu).
Regarding enabling the Submenu:
I can confirm the behaviour seen by you.
We never disable submenus, but only the items within.
And sometime we call VisMenuDelete() to delete a whole submenu.
Side note:
Something with your window handle getting (in df1) is weired.
Rainer
And I figured out:
VisMenuIsEnabled() does work without first enabling the submenu, if you first display the menu in the MDI and then click on 'Get Item Info'.
I've looked at the online help and it tells:
"...Uses the Windows enable state to test whether a menu item is enabled. VisMenuIsEnabled must be called in the Enabled When section of the SQLWindows outline in order to properly display the enable status of a SQLWindows menu item."
=> This explains why the function does not work as you want to use it. It only works, if SQLWindows previously did load the menu (which obviously also happens, if you try to modify the submenu).
Regarding enabling the Submenu:
I can confirm the behaviour seen by you.
We never disable submenus, but only the items within.
And sometime we call VisMenuDelete() to delete a whole submenu.
Side note:
Something with your window handle getting (in df1) is weired.
Rainer
Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
Thank you very much, for your findings.
ad side note: The 'weird' menu-handle -unction allows to get handels of submenus
ad side note: The 'weird' menu-handle -unction allows to get handels of submenus
Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
Yes, I did see this.
But I meant that if I click on "Get Window Handle" the wrong handle or no handle is written in df1.
E.g. if I do the following, 0 is the result in df1:
- Open and close the "Items" Menu
- Select "2" in the Combobox
- Click on "Get Window Handle
-> df1 get's 0
-->> the program does not work any longer, "Get Infos of Item#" does not work any more
--->>> Restart ist required (or Item 1 must be choosen and "Get Window Handle" must be clicked)
This is no problem, but I was asking myself, if there is eventually a similar problem in your real application...
Regards,
Rainer
aus dem Auenland in Nordelbien
Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)
ad: "df1 get's 0"
You can still click on "Get Window Handle" after deleting the "0" manually from df1.
BTW: If the window handle is a popup menu, this does the trick to get the correct state of VisMenuIsEnabled: "Call SalSendMsg( hWndMDI, WM_INITMENUPOPUP, hMenu, 0 )"
You can still click on "Get Window Handle" after deleting the "0" manually from df1.

BTW: If the window handle is a popup menu, this does the trick to get the correct state of VisMenuIsEnabled: "Call SalSendMsg( hWndMDI, WM_INITMENUPOPUP, hMenu, 0 )"
Who is online
Users browsing this forum: [Ccbot] and 0 guests