I have a menu item that is "grayed", if I go back to the menu editor the grayed check box is un uhecked but its still grayed.
Using FF_Control_Enable( IDC_TCASFRM_MNUPRINT ) does not ungray / enable the menu item.
how do I enable the menu item?
Thnks
Doug
Have you tried the FF_Menu_SetState function?
FF_Menu_SetState( HWND_TCASFRM_TOPMENU, IDC_TCASFRM_MNUPRINT, %MFS_ENABLED )
Paul, this does work kinda. The problem is that after the line of code is executed the menu item stays grayed until another menu item is selected. In other words the user wouldn't know its enabled until it or another menu item is clicked on and since its still grayed out they wouldn't click on it. I added
FF_Control_Redraw( HWND_TCASFRM_TOPMENU )
FF_Control_Redraw( IDC_TCASFRM_MNUPRINT)
but it didn't help.
There is still the problem that in the menu editor you can't un-gray a menu item once its grayed, the check box becomed un-checked even though its still grayed out.
FF3 ver 3.07 I can send an exe if that would help show the problem or whatever file you need.
thank you
QuoteThere is still the problem that in the menu editor you can't un-gray a menu item once its grayed, the check box becomed un-checked even though its still grayed out.
That's not exactly true. Once you have set a menu item to grayed, it will not show that checkbox as checked when you reopen the menu editor. But if you check and uncheck it then the menu item will be un-grayed afterwards.
Rolf, your correct but it should come up checked if its grayed. You shouldn't have to check it(its already grayed) then un-check it. Its not that big a deal but it needs to be corrected at some point.
The biggest problem it unchecking it in code as stated in my last post.
Doug
QuoteThe biggest problem it unchecking it in code as stated in my last post.
That is obviously true when it is the top item visible in the menubar. Makes no difference for subitems since you have to click the topmenu first anyway, so they show properly. The menubar should be redrawn properly of course.
If you could send me the project then that would be great. It would certainly be easier for me to visualize the problem (especially the part about the enable/disable not taking effect immediately).
Use the API function DrawMenuBar.
Jose, thanks I'll give it a try. Paul I'll email you the project but it won't be till Monday since its at work.
Thank you
Quote from: Jose Roca on February 26, 2010, 04:08:53 PM
Use the API function DrawMenuBar.
The FireFly function already calls DrawMenuBar....
Function FF_Menu_SetState( ByVal hMenu As Dword, _
ByVal idItem As Long, _
ByVal nState As Long _
) As Long
Local mType As MenuItemInfo
mType.cbSize = SizeOf(mType)
mType.fMask = %MIIM_STATE
mType.fState = nState
'%MFS_ENABLED, %MFS_GRAYED, %MFS_DISABLED, %MFS_CHECKED, %MFS_UNCHECKED
'%MFS_DEFAULT, %MFS_HILITE, %MFS_UNHILITE
' Function returns 0 on fail.
Function = SetMenuItemInfo( hMenu, idItem, %FALSE, mType )
DrawMenuBar hMenu
End Function
But you're using DrawMenuBar hMenu, and it must be the handle of the window whose menu bar needs redrawing, not the handle of the menu.
Ah, that's why I had no success!
That works:
FF_Menu_SetState(HWND_FRMMAIN_TOPMENU, IDC_FRMMAIN_MNUDATENFUNK, %MFS_ENABLED )
DrawMenuBar hWndForm
Better might be if the FF_Menu_SetState Function gets an additional parameter for the parent form, like:
Function FF_Menu_SetState( ByVal hWndForm As Dword, _
ByVal hMenu as Dword, _
ByVal idItem As Long, _
ByVal nState As Long _
) As Long
Local mType As MenuItemInfo
mType.cbSize = SizeOf(mType)
mType.fMask = %MIIM_STATE
mType.fState = nState
'%MFS_ENABLED, %MFS_GRAYED, %MFS_DISABLED, %MFS_CHECKED, %MFS_UNCHECKED
'%MFS_DEFAULT, %MFS_HILITE, %MFS_UNHILITE
' Function returns 0 on fail.
Function = SetMenuItemInfo( hMenu, idItem, %FALSE, mType )
DrawMenuBar hWndForm
End Function
Then call it:
FF_Menu_SetState(hWndForm, HWND_FRMMAIN_TOPMENU, IDC_FRMMAIN_MNUDATENFUNK, %MFS_ENABLED )
Works!
Thanks Jose!
That would be exactly the right place, Jim.
But maybe you should wait. Paul might have some different idea or extra enhancement.
Quote from: Jose Roca on February 26, 2010, 09:49:29 PM
But you're using DrawMenuBar hMenu, and it must be the handle of the window whose menu bar needs redrawing, not the handle of the menu.
OMG - how embarrassing!!!! :)
Paul,
I emailed you the project with the menu issue. Thank you for your help
Doug
OMG = Oh my Guinness?
Rolf, I don't get the meaning of your last post
I do ;D :D ;D :D ;D
Douglas, it was just a remark to Paul's abbreviation: OMG.
The Irish Guinness Brewery used to have a lot of funny cartoons out as commercials where the replaced 'Oh my goodness' with 'Oh my Guinness'.
Thanks Rolf, I should have known. Stout is the best and about now I could use a good pub. I guess I had a dimwitted moment there, humm...... coming more often as I get older
Thank you, your a good soul
Doug
Quote from: Douglas McDonald on February 25, 2010, 02:22:16 PM
I have a menu item that is "grayed", if I go back to the menu editor the grayed check box is un uhecked but its still grayed.
This was a bonehead ommission on my part. For top level items in the menu, I have now corrected the problem where the "graying" would not be correctly displayed while in the menu Editor.
Fix will be in the next update.
With regard to setting the state via code, you should update the current FF_Menu_SetState and FF_Menu_SetText functions in the Functions Library (these updated functions will bein the v1.08 update as well).
Function FF_Menu_SetState( ByVal hWndForm As Dword, _
ByVal hMenu As Dword, _
ByVal idItem As Long, _
ByVal nState As Long _
) As Long
Local mType As MenuItemInfo
mType.cbSize = SizeOf(mType)
mType.fMask = %MIIM_STATE
mType.fState = nState
'%MFS_ENABLED, %MFS_GRAYED, %MFS_DISABLED, %MFS_CHECKED, %MFS_UNCHECKED
'%MFS_DEFAULT, %MFS_HILITE, %MFS_UNHILITE
' Function returns 0 on fail.
Function = SetMenuItemInfo( hMenu, idItem, %FALSE, mType )
DrawMenuBar hWndForm
End Function
Function FF_Menu_SetText( ByVal hWndForm As Dword, _
ByVal hMenu As Dword, _
ByVal idItem As Long, _
ByVal sText As String _
) As Long
Local mType As MenuItemInfo
mType.cbSize = SizeOf(mType)
mType.fMask = %MIIM_STRING
mType.dwTypeData = StrPtr(sText)
mType.cch = Len(sText)
SetMenuItemInfo hMenu, idItem, %FALSE, mType
DrawMenuBar hWndForm
End Function
Thank you Paul it works as expected.
Doug