How to programmatically call the context menu?
Moderator: Rathinagiri
How to programmatically call the context menu?
How to programmatically call the context menu?
I want to call context menu for browse, after searching record.
1. I don't want to define new window with buttons, because I placed all needed functions in context menu.
How to do it?
2. When I press context menu button on the kayboard, context menu appears in the right down corner of the sceen.
It doesn't look fine - detached from the component (especially in the browse - from current row).
Is it possible to control position of context menu on the screen?
Best regards, MAREK
I want to call context menu for browse, after searching record.
1. I don't want to define new window with buttons, because I placed all needed functions in context menu.
How to do it?
2. When I press context menu button on the kayboard, context menu appears in the right down corner of the sceen.
It doesn't look fine - detached from the component (especially in the browse - from current row).
Is it possible to control position of context menu on the screen?
Best regards, MAREK
- Roberto Lopez
- HMG Founder
- Posts: 4023
- Joined: Wed Jul 30, 2008 6:43 pm
Re: How to programmatically call the context menu?
Is not clear to me the first part of your post.mol wrote:How to programmatically call the context menu?
I want to call context menu for browse, after searching record.
1. I don't want to define new window with buttons, because I placed all needed functions in context menu.
How to do it?
2. When I press context menu button on the kayboard, context menu appears in the right down corner of the sceen.
It doesn't look fine - detached from the component (especially in the browse - from current row).
Is it possible to control position of context menu on the screen?
Best regards, MAREK
Anyway, there is no high level implementation for this yet.
The function to call a context menu is:
Code: Select all
TrackPopupMenu ( MenuHandle , x , y , ParentWIndowHandle )You should first to get the form index in data array.
i := GetFormIndex ( cFormName )
ContextMenuHandle is in: _HMG_SYSDATA [ 74 ]
It should give you control about context menu.
Regards,
Roberto.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: How to programmatically call the context menu?
Normally, you can call context menu using right mouse button or special key on the keyboard.
But I wanna call this menu after searching record automatically.
I've tried:
where:
OknoZlecenia - is the name of window
but... nothing happens.
What's wrong?
But I wanna call this menu after searching record automatically.
I've tried:
Code: Select all
i := GetFormIndex ( "OknoZlecenia" )
ContextMenuHandle := _HMG_SYSDATA [ 74 ] [i]
TrackPopupMenu ( ContextMenuHandle , 50 , 50 , "OknoZlecenia" )
OknoZlecenia - is the name of window
but... nothing happens.
What's wrong?
- Roberto Lopez
- HMG Founder
- Posts: 4023
- Joined: Wed Jul 30, 2008 6:43 pm
Re: How to programmatically call the context menu?
No.mol wrote:Normally, you can call context menu using right mouse button or special key on the keyboard.
But I wanna call this menu after searching record automatically.
I've tried:where:Code: Select all
i := GetFormIndex ( "OknoZlecenia" ) ContextMenuHandle := _HMG_SYSDATA [ 74 ] [i] TrackPopupMenu ( ContextMenuHandle , 50 , 50 , "OknoZlecenia" )
OknoZlecenia - is the name of window
but... nothing happens.
What's wrong?
The last parameter should be GetFormHandle('OknoZlecenia')
Regards,
Roberto.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: How to programmatically call the context menu?
Hi Marek,mol wrote:Normally, you can call context menu using right mouse button or special key on the keyboard.
But I wanna call this menu after searching record automatically.
I've tried:where:Code: Select all
i := GetFormIndex ( "OknoZlecenia" ) ContextMenuHandle := _HMG_SYSDATA [ 74 ] [i] TrackPopupMenu ( ContextMenuHandle , 50 , 50 , "OknoZlecenia" )
OknoZlecenia - is the name of window
but... nothing happens.
What's wrong?
Please be so kind to try the following working sample:
Code: Select all
#include "minigui.ch"
Function main()
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 200 ;
TITLE 'Menu Test' ;
MAIN
DEFINE MAIN MENU
POPUP 'File'
ITEM 'Test' ACTION showcontext()
END POPUP
POPUP 'Help'
ITEM 'About' ACTION MsgInfo ('Help:ABout')
END POPUP
END MENU
DEFINE CONTEXT MENU
ITEM 'Item 1' ACTION MsgInfo ('Item 1')
ITEM 'Item 2' ACTION MsgInfo ('Item 2')
SEPARATOR
ITEM 'Item 3' ACTION MsgInfo ('Item 3')
END MENU
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil
Function showcontext()
Local i, ContextMenuHandle, FormHandle
i := GetFormIndex ( "Form_1" )
ContextMenuHandle := _HMG_SYSDATA [ 74 ] [i]
FormHandle := _HMG_SYSDATA [ 67 ] [i]
TrackPopupMenu ( ContextMenuHandle , Form_1.Col + 50 , Form_1.Row + 50 , FormHandle )
Return NilKind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
- Roberto Lopez
- HMG Founder
- Posts: 4023
- Joined: Wed Jul 30, 2008 6:43 pm
Re: How to programmatically call the context menu?
gfilatov wrote: Please be so kind to try the following working sample:Code: Select all
#include "minigui.ch" [/quote] Thanks for the sample. Regards, Roberto.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: How to programmatically call the context menu?
Following this, I wanna ask, if it is possible to determine screen position of selected row in the browse.
It will be superfine, when context menu will appear exactly under seected row...
It will be superfine, when context menu will appear exactly under seected row...
Re: How to programmatically call the context menu?
I've reached satisfactory result.
Below modified code of Grigori sample:
PS. If somebody want to test it, remember to define Browse_1
Below modified code of Grigori sample:
PS. If somebody want to test it, remember to define Browse_1
Code: Select all
Function showcontext()
Local i, ContextMenuHandle, FormHandle, nScreenRow, posx, posy
i := GetControlIndex ( "Browse_1", "Form_1" )
nScreenRow := LISTVIEW_GETFIRSTITEM ( _HMG_SYSDATA [3] [i] )
posx := Form_1Row + Form_1.Browse_1.Row + (nScreenRow+3) * (Form_1.Browse_1.FontSize + 1)
posy := Form_1.Col + Form_1.Browse_1.Col + Form_1.Browse_1.Width/2
i := GetFormIndex ( "Form_1" )
ContextMenuHandle := _HMG_SYSDATA [ 74 ] [i]
FormHandle := _HMG_SYSDATA [ 67 ] [i]
TrackPopupMenu ( ContextMenuHandle ,posy , posx, FormHandle )
Return Nil
Re: How to programmatically call the context menu?
Working with context menu, I think, it will be fine to define context menu for exact component, not for whole window.
maybe it's future?
maybe it's future?