In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Menu Popup explanation

Xailer professional forum in English
Responder
Giuseppe Bogetti
Mensajes: 281
Registrado: Vie Ago 04, 2006 4:58 pm

Menu Popup explanation

Mensaje por Giuseppe Bogetti »

Hi,
In the statusbar of my app I've added a panel to switch language of
application as you see in attached image.
In the OnInitialize event I use this code
// Status bar
WITH OBJECT ::oBackStatus
:oImageList:Add( "BMP_LANGUAGE" )
:oImageList:Add( "BMP_CHG_OFF" )
:oImageList:Add( "BMP_CHG_ON" )
:aItems[ tSTATUS_LANG ]:nImage := 1
:aItems[ tSTATUS_LANG ]:OnClick := { |oSender, x, y| ::FormLanguageSelect( oSender, x, y ) }
END WITH
This is the methods used to activate popup menu
METHOD FormLanguageSelect( oSender, x, y ) CLASS TBackup
LOCAL oMenu AS OBJECT
oMenu := GetLanguagePopupMenu( Self )
IF !( oMenu == NIL )
ACTIVATE POPUP oMenu OF Self AT y, x
ENDIF
RETURN Nil
These are the two functions that actually build the popup menu
//---------------------------------------------------------- --------------------
// Return language popup menu
//
FUNCTION GetLanguagePopupMenu( oDlg )
LOCAL aLang AS ARRAY
LOCAL oRetval AS OBJECT
LOCAL nI, nLen AS NUMERIC
aLang := GetLanguages()
nLen := Len( aLang )
IF ( nLen > 0 )
oRetval := TMenu():Create( oDlg, TRUE )
FOR nI := 1 TO nLen
WITH OBJECT TMenuItem():New( oRetval )
:cText := aLang[ nI, 2 ]
:OnClick := GetLanguagePopupMenuAction( oDlg, aLang[ nI, 2 ] )
:Create()
END WITH
NEXT
ENDIF
RETURN oRetval
//---------------------------------------------------------- --------------------
// Return language popup action for single language
//
FUNCTION GetLanguagePopupMenuAction( oDlg, nID )
RETURN {|| oDlg:BackLanguage( nID, FALSE ) }
If I trace through the debugger the popup menu is built correctly but the
call to ACTIVATE POPUP doesn't show anything and returns immediatly.
Any hints ? What am I doing wrong ?
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy
--
Giuseppe Bogetti
Mensajes: 281
Registrado: Vie Ago 04, 2006 4:58 pm

Menu Popup explanation

Mensaje por Giuseppe Bogetti »

In data Thu, 17 Mar 2005 11:15:58 +0100, Giuseppe Bogetti ha scritto:
Hi,
I've found the error. There was an error in the function that build the
popup.
Now the popup is built but shown using coord of panel. But now I face a
couple of problems.
1) I need to convert panel coords to screen coords.
Can I use winApi ClientToScreen to do this convertion ? How ?
2) Using activate popup the associated action is not executed.
I've seen that the command is translated to a TrackPopupMenu() call with
TPM_RETURNCMD as flag and WIN32SDK API Docs says that using this style the
menu ID of the item selected is returned.
Is it right ?
How can I set the menu ID of each item ?
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy
Giuseppe Bogetti
Mensajes: 281
Registrado: Vie Ago 04, 2006 4:58 pm

Menu Popup explanation

Mensaje por Giuseppe Bogetti »

In data Thu, 17 Mar 2005 11:15:58 +0100, Giuseppe Bogetti ha scritto:
Hi,
I've found the error. There was an error in the function that build the
popup.
Now the popup is built but shown using coord of panel. But now I face a
couple of problems.
1) I need to convert panel coords to screen coords.
Can I use winApi ClientToScreen to do this convertion ? How ?
2) Using activate popup the associated action is not executed.
I've seen that the command is translated to a TrackPopupMenu() call with
TPM_RETURNCMD as flag and WIN32SDK API Docs says that using this style the
menu ID of the item selected is returned.
Is it right ?
How can I set the menu ID of each item ?
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9252
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Menu Popup explanation

Mensaje por ignacio »

Giusseppe,
> 1) I need to convert panel coords to screen coords.
> Can I use winApi ClientToScreen to do this convertion ? How ?
METHOD ClientToScreen( @x, @y ) descedendt from TControl
OR
FUNCTION ClientToScreen( hWnd, @aPoint | @nX, @nY )
> 2) Using activate popup the associated action is not executed.
> I've seen that the command is translated to a TrackPopupMenu() call with
> TPM_RETURNCMD as flag and WIN32SDK API Docs says that using this style the
> menu ID of the item selected is returned.
Try to do it more simple, for example:
METHOD StatusBar1ContextMenu( oSender, nPosX, nPosY ) CLASS TForm1
local oPopup
MENU oPopup POPUP
MENUITEM "One" ACTION ...
MENUITEM "Two" ACTION ...
ENDMENU
oSender:ShowPopupMenu( oPopup, nPosX, nPosY )
RETURN Nil
Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
InvalidAccount
Mensajes: 53
Registrado: Vie Mar 04, 2005 9:58 am

Menu Popup explanation

Mensaje por InvalidAccount »

Giusseppe,
> 1) I need to convert panel coords to screen coords.
> Can I use winApi ClientToScreen to do this convertion ? How ?
METHOD ClientToScreen( @x, @y ) descedendt from TControl
OR
FUNCTION ClientToScreen( hWnd, @aPoint | @nX, @nY )
> 2) Using activate popup the associated action is not executed.
> I've seen that the command is translated to a TrackPopupMenu() call with
> TPM_RETURNCMD as flag and WIN32SDK API Docs says that using this style the
> menu ID of the item selected is returned.
Try to do it more simple, for example:
METHOD StatusBar1ContextMenu( oSender, nPosX, nPosY ) CLASS TForm1
local oPopup
MENU oPopup POPUP
MENUITEM "One" ACTION ...
MENUITEM "Two" ACTION ...
ENDMENU
oSender:ShowPopupMenu( oPopup, nPosX, nPosY )
RETURN Nil
Regards,
Giuseppe Bogetti
Mensajes: 281
Registrado: Vie Ago 04, 2006 4:58 pm

Menu Popup explanation

Mensaje por Giuseppe Bogetti »

In data Thu, 17 Mar 2005 12:39:53 +0100, Ignacio Ortiz de Zúñiga ha
scritto:
Ignacio,
Thanks
> Try to do it more simple, for example:
It seems that I have the "gift" to always keep the longer road :-(
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy
Giuseppe Bogetti
Mensajes: 281
Registrado: Vie Ago 04, 2006 4:58 pm

Menu Popup explanation

Mensaje por Giuseppe Bogetti »

In data Thu, 17 Mar 2005 12:39:53 +0100, Ignacio Ortiz de Zúñiga ha
scritto:
Ignacio,
Thanks
> Try to do it more simple, for example:
It seems that I have the "gift" to always keep the longer road :-(
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy
Responder