Problem with Taphold

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Problem with Taphold

Post by Silvio »

I made a small test

Code: Select all


#include "FWCE.ch"

STATIC oBmp


#define SHRG_RETURNCMD     1
#define GN_CONTEXTMENU  1000

#define MF_ENABLED         0
#define TPM_VERTICAL  0x0040

function Main()
   local oWnd

   DEFINE WINDOW oWnd TITLE "Bmp-Res"


   @ 1, 1 BITMAP oBmp NAME "omb1" SIZE 80,20 PIXEL   NOBORDER
                 oBmp:lTransparent := .t.
                 oBmp:bLClicked := {|| CheckTapAndHold( oWnd, nRow, nCol )  }


   ACTIVATE WINDOW oWnd


   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, "Inserisci" )
      AppendMenu( hMenu, MF_ENABLED, 20, "Riserva" )
      AppendMenu( hMenu, MF_ENABLED, 30, "Annulla" )
      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


First problem When I click on bmp it make a n error not found row and col . Why ?
Second problem Where i can insert the ACTION COMMANd on menu popup ?
Best Regards, Saludos

Falconi Silvio
Post Reply