Deactivation of main or context menu

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Deactivation of main or context menu

Post 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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
gfilatov
Posts: 1057
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Deactivation of main or context menu

Post 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!
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Deactivation of main or context menu

Post 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.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Deactivation of main or context menu

Post 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!.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Deactivation of main or context menu

Post 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...
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Deactivation of main or context menu

Post 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.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Deactivation of main or context menu

Post 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 :)
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Deactivation of main or context menu

Post by Rathinagiri »

I love simple solutions :)
We too. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Deactivation of main or context menu

Post 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!
User avatar
gfilatov
Posts: 1057
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Deactivation of main or context menu

Post 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
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
Post Reply