PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Art Araya on April 28, 2005, 02:00:54 PM

Title: FF functions to work with menus?
Post by: Art Araya on April 28, 2005, 02:00:54 PM
I'm looking for FireFly functions to work with menus.  Are there any or do I need to do this using PB code?

What I need to do is to checkmark a menu item in response to the user selecting it.

I am able to create the menu in FF using the Menu editor and and I am able to recognize that the menu item has been selected in FRMMAIN_WM_COMMAND using the menu's ID.  But I don't know how to work with the menu item now.  How do I checkmark it or disable it or do anything else with it now?

TIA
Title: FF functions to work with menus?
Post by: Art Araya on April 28, 2005, 02:10:36 PM
I just found out how to do this in PB using Menu Set State.  

It would be great if this was just added to FF for consistency sake.  Something like:

FF_Menu_SetCheck(wID, nCheckState)

and of course, its compliment:

FF_Menu_GetCheck(wID)

But being a newbie, I'm sure there's some reason that this has not been incorporated that I just am not aware of.
Title: FF functions to work with menus?
Post by: TechSupport on April 28, 2005, 05:39:17 PM
Quote from: Art ArayaBut being a newbie, I'm sure there's some reason that this has not been incorporated that I just am not aware of.
Nope, no reason, just haven't added any menu manipulation functions (yet). Likewise for the toolbar.

:)
Title: FF functions to work with menus?
Post by: Art Araya on April 28, 2005, 05:49:52 PM
I'm working with the Toolbar now and was thinking the same thing!  Hope you get around to them one day.

:D
Title: FF functions to work with menus?
Post by: John Dunbar on May 12, 2005, 04:35:29 PM
>" just found out how to do this in PB using Menu Set State. "

Art Araya,

Could you post one or two lines of your code for checking the menu item within FF? I can get menues to work OK but I can't get them to check themselves.

THANKS,

John
Title: FF functions to work with menus?
Post by: Art Araya on May 12, 2005, 04:53:59 PM
Hi John,

I am not entirely clear on what you are having problems with.  What do you mean when you say that you can't get the menus to check themselves?

Art
Title: FF functions to work with menus?
Post by: John Dunbar on May 12, 2005, 05:45:25 PM
Art, I've used the Menu Editor to create an menu. I capture the FRMMAIN_WM_COMMAND (my main form) messages and can bring up an About dialog. No problem on responding to menus. But now I want to mark a series of menu options with a check mark.

I can set the marks in the menu editor. But I can't turn them on/off from within the FRMMAIN_WM_COMMAND function. In fact, GetMenuState() keeps returning -1 which means it can't even find the menu.

I've tried many combinations of CheckMenuItem() and Menu Set State() and GetMenu() (that returns a handle to a menu). I just don't seem to be able to turn the little checks on and off at will.

I'm missing something basic. Like I must be using an invalid handle to a menu, or a handle to the wrong menu/submenu, an invalid identifier to the  menu item, or an invalid set of flags.

John Dunbar
Title: FF functions to work with menus?
Post by: Art Araya on May 12, 2005, 06:02:51 PM
Hi John,

As a newbie myself, I can't answer all of your questions.  All I can tell you is that I don't actually try to set the checkmarks ON/OFF in WM_COMMAND itself.  I call a routine and do it in there.  

For example, if the user has selected the Include Subfolders option menu in my app, I'll capture that in WM_COMMAND and call a routine ChangeIncludeSubFolderOption() where I do all of the toggling of checkmarks and related code.

HTH

Art
Title: FF functions to work with menus?
Post by: John Dunbar on May 12, 2005, 07:35:11 PM
That worked like a charm.

MUCHO THANKS!!

I don't know why I didn't think of that. I normally keep my stuff out of the FF window handlers.

Here's my routine for a menu item toggler and it works. Rereading it I should have used an ELSEIF in the IF statement to be cleaner but I was debugging and left it in.

John

in FRMMAIN_WM_COMMAND()
Select Case wID
Case IDC_FRMMAIN_mnuSoundOnGamewithMistakes                        
Call ToggleMenuItem(HWND_FRMMAIN,IDC_FRMMAIN_mnuSoundOnGamewithMistakes)
------
outside in a module...

Function ToggleMenuItem(hWndOfMainForm As Dword,IDCOfMenuItem As Dword) As Long
'pass in HWND_FRMMAIN (main form) and menu item identifier found in Resource file, i.e. IDC_FRMMAIN_MNUSOUNDON

Local nResult&
'returns -1 when menu does not exist, else menu flags
nResult = GetMenuState(GetMenu(hWndOfMainForm), IDCOfMenuItem, %MF_CHECKED)  
If nResult = -1 Then
ToggleMenuItem = 0
Exit Function
End If
If nResult = 0 Then
Call CheckMenuItem GetMenu(hWndOfMainForm), IDCOfMenuItem, %MF_CHECKED
Else  'decimal 8
Call CheckMenuItem GetMenu(hWndOfMainForm), IDCOfMenuItem, %MF_UNCHECKED
End If                        
ToggleMenuItem = 1

End Function