PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Art Araya on May 25, 2005, 03:47:00 PM

Title: menu accelerator keys
Post by: Art Araya on May 25, 2005, 03:47:00 PM
i think i'm missing something here.  do i have to write some code in order for my menu accelerator keys to work?

I've defined  the accelerators in the menu editor.  i've got code for each of the menu items that works fine when i manually select the menu item with my mouse.  but nothing happens when i try use the keyboard shortcuts to execute the same functions.

TIA

Art
Title: menu accelerator keys
Post by: TechSupport on May 25, 2005, 11:00:48 PM
Seems to work okay for me. I created a simple menu and set the Ctrl+O key as the shortcut.


Function FORM1_WM_COMMAND ( _
                         hWndForm     As Dword, _  ' handle of Form
                         hWndControl  As Dword, _  ' handle of Control
                         wNotifyCode  As Long,  _  ' notification code
                         wID          As Long   _  ' item, control, or accelerator identifer
                         ) As Long

Select Case wID
  Case IDC_FORM1_MNUOPEN
     MsgBox "Open"
End Select
     
End Function
Title: menu accelerator keys
Post by: Art Araya on May 25, 2005, 11:52:10 PM
Hi Paul,

Thanks for your response.

Yeah, if I create a test app with only a menu on it I can also duplicate your results.  

But for some reason it's not working on my real app where there's alot of stuff going on with many forms and modules, etc..  Anyone have any ideas about what I may have done to interrupt the accelerator keys from working?

I tried commenting out some stuff that I thought may be causing the interference but still no luck and I'm just too new to FF to know all of the possible causes for this.
Title: menu accelerator keys
Post by: Roger Garstang on May 26, 2005, 05:23:30 AM
Are these Ctrl combos or Alt(Underlined letter)?  If Alt it could be other labels/buttons with that Alt combo grabbing the keys.
Title: menu accelerator keys
Post by: Art Araya on May 26, 2005, 09:21:52 AM
Hi Roger,

These are CTRL combos and there are no collisions causing this.  Checked that already.

So, I was thinking about this problem some more and trying to remember at what point the accelerator keys stopped working.  After testing some of my theories, I stumbled on the problem but I have no idea how to resolve it or if it is a FF bug.

The menu in question appears on my app's main form.  The main form used to be the Startup form.  Then I changed things around and added a Nag Screen and made that the Startup form and the main form is loaded from within the Nag Screen when the user presses a Continue button.  All of this works properly.

But, here's the problem... when the main form is the startup form, the accelerator keys work fine.  When the main form is not the startup form, the menu accelerators do not work at all.

Is this something that I am doing wrong or is this a FF problem?
Title: menu accelerator keys
Post by: Art Araya on May 26, 2005, 12:09:02 PM
Here's some more info for you...

You can reproduce this behavior yourself using these steps:

1) Create a form and add a menu item to it with accelerator key that displays  a message box when the accelerator keystroke is used (Just like Paul did above)

2) Add a second form to the project and add a command button to it.  Make this second form the Startup form.  Add this code to the button click event:

Form1_Show hWnd, %FALSE

Now run the project.  Form 2 will come up properly.  Press the button.  Form 1 will now come up.  Press the accelerator keystroke to fire the menu event.   Nothing happens now.

The key to this is loading Form1 non-modally.  If it is loaded modally like this - Form1_Show hWnd, %TRUE - the accelerator works.

Sounds like a solution, right?  Wrong!  For various reasons I need Form1 to be non-modal.

Is this a bug or this working as it's supposed to under these circumstances?

TIA
Title: menu accelerator keys
Post by: Art Araya on May 26, 2005, 10:53:08 PM
Any ideas Paul?

TIA
Title: menu accelerator keys
Post by: TechSupport on May 27, 2005, 08:19:58 AM
Hi Art,

I will work on the problem today to see what solution there is. I will post back as soon as I can.
Title: menu accelerator keys
Post by: TechSupport on May 27, 2005, 11:28:19 AM
Art,

I found the problem. It is the code generation for the message pump for the main, startup Form. The TranslateAccelerator function was only looking for accelerators for the hWndForm (the main form) rather than the currently active form. Because a non-modal form uses the message pump of it's parent, I modified the function call to check for the "GetActiveWindow" window handle rather than hWndForm. This is the same thing that I did a few versions ago with the IsDialogMessage function.

I will create a new FFengine.exe program and email it to you later today.
Title: menu accelerator keys
Post by: Art Araya on May 27, 2005, 11:45:04 AM
Awesome support Paul!  

I'm glad that this wasn't something I was doing wrong.  As a FF and PB newbie my first thought is that the problem must be due to my ignorance.

TIA
Title: menu accelerator keys
Post by: Art Araya on May 29, 2005, 08:35:19 PM
Hi Paul,

Not being a nag here, honestly.  You said I'd receive a new file from you later on Friday and now it is Sunday evening and still nothing.

My only concern is that you sent it to me and my SPAM filter caught it.  Can you confirm for me the status of this.  Did you send me a new file yet?

TIA

Art
Title: menu accelerator keys
Post by: TechSupport on May 29, 2005, 10:27:25 PM
Yes, I emailed it to you on Friday night (7:13 pm my time).

I will post it to the website so that you can download it instead.
Title: menu accelerator keys
Post by: TechSupport on May 29, 2005, 10:31:21 PM
Here is the file:

http://www.planetsquires.com/files/FFengine.zip
Title: menu accelerator keys
Post by: Art Araya on May 30, 2005, 12:58:13 PM
Thanks Paul!  Yup, the anti-spam filter must have trapped it.  I never got it.  I downloaded, installed, recompiled, and all works great so far!

Any other changes in this new release that I need to be aware of?  I already plan on throroughly retesting my app but just wondering if there are any other changes under the hood that I should keep an eye out for.

Thanks again!

Art
Title: menu accelerator keys
Post by: TechSupport on May 30, 2005, 04:56:21 PM
I believe these are the changes in the version of the EXE that you have (in addition to the keyboard accelerator fix):

- Changed FF_SetRegistryDWord to use %REG_DWORD instead of %REG_SZ

- Corrected display of Form in the Designer when the WS_CAPTION style
is toggled off.

- FireFly now correctly displays the various window styles and borders
in the designer.

- When a Form's "TabControlChild" property is set to "True", then the
Caption bar for the Form is toggled off.

- The Workspace's ToolBox icons will now display a tooltip regardless
of whether the Workspace dialog has focus or not.

- Fixed typo in "Use block style prototypes for new features". The
word "features" has been changed to "functions".