Menu issue

Started by Douglas McDonald, February 25, 2010, 02:22:16 PM

Previous topic - Next topic

Douglas McDonald

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
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Paul Squires

Have you tried the FF_Menu_SetState function?
Paul Squires
PlanetSquires Software

Douglas McDonald

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
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Rolf Brandt

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 Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Douglas McDonald

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
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Rolf Brandt

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.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Paul Squires

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).
Paul Squires
PlanetSquires Software

José Roca

Use the API function DrawMenuBar.

Douglas McDonald

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
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?

Paul Squires

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

Paul Squires
PlanetSquires Software

José Roca

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.

Rolf Brandt

#11
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!
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Rolf Brandt

That would be exactly the right place, Jim.

But maybe you should wait. Paul might have some different idea or extra enhancement.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Paul Squires

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 Squires
PlanetSquires Software

Douglas McDonald

Paul,

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

Doug
Doug McDonald
KD5NWK
www.redforksoftware.com
Is that 1's and 0's or 0's and 1's?