PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Douglas McDonald on February 25, 2010, 02:22:16 PM

Title: Menu issue
Post by: 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.
Using FF_Control_Enable( IDC_TCASFRM_MNUPRINT ) does not ungray / enable the menu item.

how do I enable the menu item?

Thnks
Doug
Title: Re: Menu issue
Post by: Paul Squires on February 25, 2010, 09:33:21 PM
Have you tried the FF_Menu_SetState function?
Title: Re: Menu issue
Post by: Douglas McDonald on February 26, 2010, 11:06:05 AM
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
Title: Re: Menu issue
Post by: Rolf Brandt on February 26, 2010, 02:03:19 PM
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.
Title: Re: Menu issue
Post by: Douglas McDonald on February 26, 2010, 02:21:45 PM
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
Title: Re: Menu issue
Post by: Rolf Brandt on February 26, 2010, 02:56:00 PM
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.
Title: Re: Menu issue
Post by: Paul Squires on February 26, 2010, 03:46:16 PM
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).
Title: Re: Menu issue
Post by: José Roca on February 26, 2010, 04:08:53 PM
Use the API function DrawMenuBar.
Title: Re: Menu issue
Post by: Douglas McDonald on February 26, 2010, 08:18:11 PM
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
Title: Re: Menu issue
Post by: Paul Squires on February 26, 2010, 08:24:44 PM
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

Title: Re: Menu issue
Post by: José 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.
Title: Re: Menu issue
Post by: Rolf Brandt on February 27, 2010, 04:00:35 AM
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!
Title: Re: Menu issue
Post by: Rolf Brandt on February 27, 2010, 11:44:22 AM
That would be exactly the right place, Jim.

But maybe you should wait. Paul might have some different idea or extra enhancement.
Title: Re: Menu issue
Post by: Paul Squires on February 27, 2010, 12:27:46 PM
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!!!!  :)
Title: Re: Menu issue
Post by: Douglas McDonald on February 27, 2010, 12:34:57 PM
Paul,

I emailed you the project with the menu issue. Thank you for your help

Doug
Title: Re: Menu issue
Post by: Rolf Brandt on February 28, 2010, 05:45:48 AM
OMG = Oh my Guinness?
Title: Re: Menu issue
Post by: Douglas McDonald on February 28, 2010, 12:27:38 PM
Rolf, I don't get the meaning of your last post
Title: Re: Menu issue
Post by: Marc van Cauwenberghe on February 28, 2010, 01:17:16 PM
I do  ;D :D ;D :D ;D
Title: Re: Menu issue
Post by: Rolf Brandt on February 28, 2010, 05:13:54 PM
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'.
Title: Re: Menu issue
Post by: Douglas McDonald on February 28, 2010, 05:42:30 PM
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
Title: Re: Menu issue
Post by: Paul Squires on March 01, 2010, 12:15:27 PM
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.
Title: Re: Menu issue
Post by: Paul Squires on March 01, 2010, 12:23:19 PM
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

Title: Re: Menu issue
Post by: Douglas McDonald on March 01, 2010, 03:40:33 PM
Thank you Paul it works as expected.

Doug