PopUp Menu Item Selected

PopUp Menu Item Selected

Postby PeterBaga » Thu Mar 25, 2010 4:46 pm

ola a todos.

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

Obrigado por qq dicca...


Code: Select all  Expand view  RUN

// 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    
 
Pedro Alexandre C. Bagarrão
User avatar
PeterBaga
 
Posts: 52
Joined: Sun Jan 24, 2010 3:39 pm

Re: PopUp Menu Item Selected

Postby Antonio Linares » Thu Mar 25, 2010 7:54 pm

Pedro,

Aqui tienes un ejemplo completo:
Code: Select all  Expand view  RUN

// 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
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: PopUp Menu Item Selected

Postby PeterBaga » Sat Mar 27, 2010 10:30 am

Ok Antonio....

Muito Obrigado..
Pedro Alexandre C. Bagarrão
User avatar
PeterBaga
 
Posts: 52
Joined: Sun Jan 24, 2010 3:39 pm


Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 5 guests