Page 1 of 1

PopUp Menu Item Selected

Posted: Thu Mar 25, 2010 4:46 pm
by PeterBaga
ola a todos.

Como podemos obter o item seleccionado para executarmos uma Action??

Obrigado por qq dicca...

Code: Select all

// Detecting the tap-and-hold event

#include "FWCE.ch"

#define SHRG_RETURNCMD     1
#define GN_CONTEXTMENU  1000

#define MF_ENABLED         0
#define TPM_VERTICAL  0x0040

function Main()

   local oWnd
   
   DEFINE WINDOW oWnd TITLE "Tap & Hold"
   
   ACTIVATE WINDOW oWnd ;
      ON CLICK CheckTapAndHold( oWnd, nRow, nCol )
      
return nil

function CheckTapAndHold( oWnd, nRow, nCol )

   local hMenu

   if SHRecognizeGesture( oWnd:hWnd, nCol, nRow, SHRG_RETURNCMD ) == GN_CONTEXTMENU
      // MsgInfo( "Tap & Hold" )
      hMenu = CreatePopupMenu()
      AppendMenu( hMenu, MF_ENABLED, 10, "One" )
      AppendMenu( hMenu, MF_ENABLED, 20, "Two" )
      AppendMenu( hMenu, MF_ENABLED, 30, "Three" )
      TrackPopupMenuEx( hMenu, TPM_VERTICAL, nRow, nCol, oWnd:hWnd )
   endif
   
return nil    
 

Re: PopUp Menu Item Selected

Posted: Thu Mar 25, 2010 7:54 pm
by Antonio Linares
Pedro,

Aqui tienes un ejemplo completo:

Code: Select all

// Detecting the tap-and-hold event

#include "FWCE.ch"

#define SHRG_RETURNCMD     1
#define GN_CONTEXTMENU  1000

#define MF_ENABLED         0
#define TPM_VERTICAL  0x0040

function Main()

   local oWnd := TMyWindow():New()
   
   oWnd:SetText( "Tap & Hold" )
   
   ACTIVATE WINDOW oWnd ;
      ON CLICK CheckTapAndHold( oWnd, nRow, nCol )
      
return nil

CLASS TMyWindow FROM TWindow

   METHOD Command( nWParam, nLParam )

ENDCLASS

METHOD Command( nWParam, nLParam ) CLASS TMyWindow

   local nId

   if nHiWord( nWParam ) == 0 // MenuItem

      nId = nLoWord( nWParam )

      do case
         case nId == 10
              MsgInfo( "One" )
              
         case nId == 20
              MsgInfo( "Two" )
              
         case nId == 30
              MsgInfo( "Three" )
      endcase                
   endif   

return Super:Command( nWParam, nLParam )

function CheckTapAndHold( oWnd, nRow, nCol )

   local hMenu

   if SHRecognizeGesture( oWnd:hWnd, nCol, nRow, SHRG_RETURNCMD ) == GN_CONTEXTMENU
      // MsgInfo( "Tap & Hold" )
      hMenu = CreatePopupMenu()
      AppendMenu( hMenu, MF_ENABLED, 10, "One" )
      AppendMenu( hMenu, MF_ENABLED, 20, "Two" )
      AppendMenu( hMenu, MF_ENABLED, 30, "Three" )
      TrackPopupMenuEx( hMenu, TPM_VERTICAL, nRow, nCol, oWnd:hWnd )
   endif
   
return nil            

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

LPWSTR AnsiToWide( LPSTR );

#define IF(x,y,z) ((x)?(y):(z)) 

HB_FUNC( CREATEPOPUPMENU )
{
   hb_retnl( ( LONG ) CreatePopupMenu() );
}   

HB_FUNC( APPENDMENU )
{
   LPWSTR pW = AnsiToWide( hb_parc( 4 ) );
   
   hb_retl( AppendMenu( ( HMENU ) hb_parnl( 1 ), ( UINT ) hb_parnl( 2 ), hb_parnl( 3 ),
                        IF( ISCHAR( 4 ), pW, ( LPWSTR ) hb_parnl( 4 ) ) ) );
   hb_xfree( pW );                     
}

HB_FUNC( TRACKPOPUPMENUEX )
{
  hb_retl( TrackPopupMenuEx( ( HMENU ) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 4 ),
           hb_parni( 3 ), ( HWND ) hb_parni( 5 ), NULL ) );
}  

#pragma ENDDUMP 
 

Re: PopUp Menu Item Selected

Posted: Sat Mar 27, 2010 10:30 am
by PeterBaga
Ok Antonio....

Muito Obrigado..