TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Report bugs and possible workarounds.
OeavDev
Austria
Posts: 103
Joined: 15 May 2018, 11:18
Location: Vienna

TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Post by OeavDev » 14 May 2024, 16:27

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.
Last edited by OeavDev on 15 May 2024, 12:29, edited 3 times in total.

RainerE
Germany
Posts: 2283
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Post by RainerE » 15 May 2024, 06:40

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

OeavDev
Austria
Posts: 103
Joined: 15 May 2018, 11:18
Location: Vienna

Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Post by OeavDev » 15 May 2024, 10:40

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
You do not have the required permissions to view the files attached to this post.

RainerE
Germany
Posts: 2283
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Post by RainerE » 15 May 2024, 13:00

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

OeavDev
Austria
Posts: 103
Joined: 15 May 2018, 11:18
Location: Vienna

Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Post by OeavDev » 16 May 2024, 09:02

Thank you very much, for your findings.

ad side note: The 'weird' menu-handle -unction allows to get handels of submenus

RainerE
Germany
Posts: 2283
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Post by RainerE » 16 May 2024, 09:11

OeavDev wrote:
16 May 2024, 09:02
ad side note: The 'weird' menu-handle -unction allows to get handels of submenus
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

OeavDev
Austria
Posts: 103
Joined: 15 May 2018, 11:18
Location: Vienna

Re: TD7.3.5 VisMenuIsEnabled is always 0 on menuitems! (sample included)

Post by OeavDev » 21 May 2024, 06:25

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 )"

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ccbot] and 0 guests