Page 2 of 4

Re: Deactivation of main or context menu

Posted: Tue Apr 27, 2010 12:45 am
by Roberto Lopez
Roberto Lopez wrote: I'll continue researching to determine if this behavior is inherited from Windows API or not and (in both cases) if it is 'fixable'.

The fix (if possible) could take a long time for me to make it, so, if someone has additional information that helps on this, please post here!
TIA.
Grigory,

Does this problem exists (existed) in minigui ext.?

If so and you've fixed, could be you so kind to give some guidance about how to solve it?

Thanks in advance.

Re: Deactivation of main or context menu

Posted: Tue Apr 27, 2010 9:12 am
by gfilatov
Roberto Lopez wrote:
Roberto Lopez wrote: I'll continue researching to determine if this behavior is inherited from Windows API or not and (in both cases) if it is 'fixable'.

The fix (if possible) could take a long time for me to make it, so, if someone has additional information that helps on this, please post here!
TIA.
Grigory,

Does this problem exists (existed) in minigui ext.?

If so and you've fixed, could be you so kind to give some guidance about how to solve it?

Thanks in advance.
Hello Roberto,

Yes, we had the similar problem in the minigui ext. :shock:
If a window has a menu, and it has a shortcut that opens a second
window, and you activate the menu (via mouse click or shortcut), and
then press the shortcut key that opens the second window, the whole
program freezes (described by Kevin Carmody <i@kevincarmody.com>).
The solution was to use the Static variable IsActiveMenu in the function Events() for switching
menu state (which is activated at WM_MENUSELECT event) and block the hotkeys action in the WM_HOTKEY event when the menu is active. Then this flag was reset at the WM_MOUSEMOVE, WM_MOVE, WM_SIZE, WM_COMMAND and WM_CONTEXTMENU events.

But this rough hack creates a problem in the Grid inplace edit window and I've remove this trick from the latest build. :o

For now I support Esgici's conclusion:
problem is ON KEY ESCAPE .. command.
...
if program set a key for other than standard action, system quit this standard action and obey this command.
BTW I think that a hotkeys handling require a small improvement/revising. :idea:

Thanks for your attention!

Re: Deactivation of main or context menu

Posted: Tue Apr 27, 2010 10:23 am
by mol
problem is ON KEY ESCAPE .. command.
...
if program set a key for other than standard action, system quit this standard action and obey this command.
I think, Esgici is not right.
All over the world Escape key is used to deactivate unwanted action.
How to tell user, why ESC does work in some cases and does not in others.

Re: Deactivation of main or context menu

Posted: Tue Apr 27, 2010 8:02 pm
by Roberto Lopez
gfilatov wrote: Yes, we had the similar problem in the minigui ext. :shock:
<...>
Many many thanks for your help!.

You saved me a lot of hours on research and testing!

Thanks again!.

Re: Deactivation of main or context menu

Posted: Thu Apr 29, 2010 1:09 am
by Roberto Lopez
gfilatov wrote:<...>
But this rough hack creates a problem in the Grid inplace edit window and I've remove this trick from the latest build. :o
So, the problem still exists in minigui ext... well... I'll start playing with WM_MENUSELECT...

I'll keep you posted...

Re: Deactivation of main or context menu

Posted: Thu Apr 29, 2010 2:38 am
by Roberto Lopez
Roberto Lopez wrote: I'll keep you posted...
Well... I've found a completely different solution (I'll must test during some days to be sure that it is reasonably correct).

The approach is extremely simple:

The only problem is to force menu close. You can do this, clicking on the menu's parent window. So, I've synthesized a mouse click using mouse_event function.

This procedure is added to the hotkey user action procedure for ON KEY ESCAPE command.

Is extremely simple, and, until now, I've not noticed about adverse effects.

Re: Deactivation of main or context menu

Posted: Thu Apr 29, 2010 4:31 am
by Roberto Lopez
Roberto Lopez wrote: Is extremely simple, and, until now, I've not noticed about adverse effects.
It has adverse effects.

But there is one safer, cleaner and simpler solution: You must to call Windows API 'EndMenu' function prior to execute action procedure associated to a ON KEY ESCAPE command. That's all!

I love simple solutions :)

Re: Deactivation of main or context menu

Posted: Thu Apr 29, 2010 4:54 am
by Rathinagiri
I love simple solutions :)
We too. :)

Re: Deactivation of main or context menu

Posted: Thu Apr 29, 2010 5:20 am
by mol
It seemed so simple when I was starting this theme :D
Great, Roberto.
Sometimes one action (like pressing ESC key :D) takes many days of work.
Sometimes, you can write all application in one day.
Life of programmer is beautiful!

Re: Deactivation of main or context menu

Posted: Thu Apr 29, 2010 11:33 am
by gfilatov
Roberto Lopez wrote:
Roberto Lopez wrote: Is extremely simple, and, until now, I've not noticed about adverse effects.
It has adverse effects.

But there is one safer, cleaner and simpler solution: You must to call Windows API 'EndMenu' function prior to execute action procedure associated to a ON KEY ESCAPE command. That's all!

I love simple solutions :)
Thanks a lot, Roberto :!:

The Marek's sample works fine after these changes:

Code: Select all

...
   On Key ESCAPE OF Second Action ( IIF(Empty(EndMenu()), NIL, Second.Release) )
...
where

Code: Select all

//-----------------------------------------------------------------------------
// WINUSERAPI BOOL WINAPI EndMenu( VOID);

#if (WINVER >=0x0500)
HB_FUNC( ENDMENU )
{
   hb_retl( EndMenu() ) ;
}
#endif
It seems that Windows API EndMenu() function is not available at the Win9x :o