BTNBMP AND POPUP

BTNBMP AND POPUP

Postby Silvio.Falconi » Sat Mar 26, 2016 6:24 pm

I have a list of btnbmp and I wish open a popup when the final user click on a btnbmp

the problem is the nitem is the same

Code: Select all  Expand view
RA->(dbgotop())
    Do While ! Ra->(eof())


      @ nrow,ncol BTNBMP oBtn[n] of oGrid:adialogs[1] ;
                  SIZE nsizeW,nsizeh PIXEL TRANSPARENT ;
                  Prompt (alltrim(Ra->Radesc)," ")  ;
                  NOBORDER ;
                  Filename aBmp[RA->RACOLORE]   ;
                  CENTER

               oBtn[n]:bAction := {|| Msginfo("Item "+str(n) ) }
     
       ncol:= ncol+nsizeW+5
       n:=n+1

       k++

       IF k = 11
          nRow += nsizeh+10
          ncol := 10
          k:= 1
       Endif

       RA->(dbSkip())
    Enddo

 



give me allway item 30 and the same caption because there are 30 items

How I cam open a popup and give to popup the number of button and the caption ?
Last edited by Silvio.Falconi on Sun Mar 27, 2016 4:44 pm, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: Matrice of btnbmp

Postby Antonio Linares » Sat Mar 26, 2016 6:26 pm

regards, saludos

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

Re: Matrice of btnbmp

Postby Silvio.Falconi » Sat Mar 26, 2016 8:09 pm

Antonio,
I saw
I tried but not run !!


Test.prg

Code: Select all  Expand view
#include "FiveWin.ch"
#include "constant.ch"


REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO


Function test()
Local oDlgTest,oGrid
 Local  aPrompts:={"faldone 1"}


   Local  nBottom   := 29.2
   Local  nRight    :=  58
   Local  nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local  nHeight   :=  nBottom * DLG_CHARPIX_H

   RddSetDefault( "DBFCDX" )

   SetHandleCount( 100 )



DEFINE DIALOG oDlgTest         ;
         SIZE nWidth, nHeight   PIXEL  ;    //TRUEPIXEL
         TITLE "test"  TRANSPARENT



   oGrid := TFolderex():New( , , , , oDlgTest, , ,, aPrompts)
   oGrid:nTop    := 00
   oGrid:nLeft   := 00
   oGrid:nBottom := 200
   oGrid:nRight  := 300


ACTIVATE DIALOG oDlgTest ;
 ON INIT Show_raccoglitori(oGrid)
return nil

//----------------------------------------------------------------//

 function  Show_raccoglitori(oGrid)

local  oFontsmall:= TFont():New( "Tahoma", 0, -9,,.F. )
Local cCursor:= TCursor():New(,'HAND')

local nRow := 10
local ncol := 10

//per i faldoni
Local nsizeW:= 84
Local nsizeh:= 240


local aBmp:= {".\bitmaps\tipo1.png"       ,;
              ".\bitmaps\tipo2.png"       ,;
              ".\bitmaps\tipo3.png"       ,;
              ".\bitmaps\tipo4.png"       ,;
              ".\bitmaps\tipo5.png"   }


local n:= 1
local oBtn,oBasket2

Create_Faldoni()

USE FALDONI ALIAS RA


nCount:=RA->(OrdKeyCount())
nNumeroPerLinea:= 15+1
oBtn:= array(nCount)
 k:= 1
RA->(dbgotop())
    Do While ! Ra->(eof())



 nCode:= Ra->racodice
                 nCaption:=Ra->Radesc

      @ nrow,ncol BTNBMP oBtn[n] of oGrid:adialogs[1] ;
                  SIZE nsizeW,nsizeh PIXEL TRANSPARENT ;
                  Prompt str2lines(alltrim(Ra->Radesc)," ")  ;
                  NOBORDER ;
                  Filename aBmp[RA->RACOLORE]   ; // ACTION bEjecutaBoton(nrow,ncol,n,alltrim(Ra->Radesc),obtn);
                  CENTER

      * oBtn[n]:lTransparent:=.T.
      oBtn[n]:oCursor:= cCursor
      oBtn[n]:lBorder := .F.
      oBtn[n]:bAction := bEjecutaBoton(nrow,ncol,n,oBtn[n], nCaption)


       ncol:= ncol+nsizeW+5
       n:=n+1

       k++

       IF k = nNumeroPerLinea
          nRow += nsizeh+10
          ncol := 10
          k:= 1
       Endif


       RA->(dbSkip())
    Enddo








   return nil
//----------------------------------------------------------------//


 function bEjecutaBoton(nrow,ncol,n,oControl, nCaption)
        return { |n| Menu_popup(nrow,ncol,n,oControl, nCaption)  }

//----------------------------------------------------------------//

      Function Menu_popup(nrow,ncol,n,oControl, nCaption)
        Local oMenuPop
       MENU oMenuPop POPUP
          MENUITEM "Apri "+ nCaption
          MENUITEM "WWW"
       ENDMENU
        ACTIVATE POPUP oMenuPop OF oControl AT nrow,ncol

     return nil

//----------------------------------------------------------------//


 Function Create_Faldoni()
      Local cDir:=""
    DbCreate(cDir+'RA',      {{ "RACODICE"  , "C",     4, 0 },;
                              { "RADESC  "  , "C", 25,    0 },;
                              { "RACOLORE"  , "N",     1, 0 } } , 'DBFCDX')



      close all
      use &(cDir+'RA') new
      select RA
      if FILE(cDir+'FALDONI.DBF')
         delete file &(cdir+'FALDONI.cdx')
         append from &(cdir+'FALDONI')
         dbcommitall()
         close all
         delete file &(cdir+'FALDONI.dbf')
      endif
      close all
      rename &(cdir+'RA.dbf') to &(cdir+'FALDONI.dbf')
   return nil

//----------------------------------------------------------------//
  FUNCTION Str2Lines( string, parser )
Local cStrLines:= CRLF+"", nLenPar:= Len( parser )
Local commapos := 0

   If parser == NIL .OR. parser == "e"
     parser := " "
   EndIf

   Do While Len( string ) > 0
      commapos := at( parser, string )
      IF commapos > 0
         cStrLines+= Left( string, commapos - 1 ) + CRLF + ""
         string := SubStr( string, commapos + Len( parser ) )
     ELSE
         cStrLines+= string
         string := ''
     ENDIF
  ENDDO

RETURN( cStrLines )
//----------------------------------------------------------------//








 


Image


I saw

if we use @ btnbmp -- action ... it run the function of the baction

if we use oBtn[n]:bAction := bEjecutaBoton(n,nrow,ncol, nCode,nCaption,obtn[n]) the control draw a border arround the control btnbmp and at right draw a triangule and the popupup menu is far from btnbmp

why ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: BTNBMP AND POPUP

Postby ukoenig » Mon Mar 28, 2016 8:15 am

Silvio,

Silvio wrote :
if we use oBtn[n]:bAction := bEjecutaBoton(n,nrow,ncol, nCode,nCaption,obtn[n]) the control draw a border

don't use nrow,ncol !!

oBtn[n]:bAction := bEjecutaBoton(n,0, 0 ,nCode,nCaption,obtn[n])
will display the popup on top / left of the button

oBtn[n]:bAction := bEjecutaBoton(n, 0, oBtn[n]:nRight ,nCode,nCaption,obtn[n])
will display the popup on top / right of the button

best regards
Uwe :D
Last edited by ukoenig on Mon Mar 28, 2016 5:53 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BTNBMP AND POPUP

Postby Willi Quintana » Mon Mar 28, 2016 3:04 pm

Hi,
Code: Select all  Expand view

..
oMesa := ARRAY(40)

FOR nCont := 1 TO 40
          REDEFINE BTNBMP oMesa[nCont] ;
                   ACTION (<Actions>, MenuMesa( oMesa[::nId-100], ::nId) ) ) ;    
                   FONT oFont1 ;
                   ID 100 + nCont OF oDlg

NEXT nCont
..
..
//---------------------------------------------------------------------------------------------------------------------
Function MenuMesa(oObj, nId)
local nOption, nTopR, nLeftR, oMenu

nOption := 0
nTopR   := oObj:nBottom         //nTop           // posicion del control que hizo la llamada
nLeftR  := oObj:nRight         //nLeft

MENU oMenu POPUP 2007
  MENUITEM "Opcion 1" ;
     RESOURCE "CALENDARIO1" ACTION nOption := 1
  MENUITEM "Opcion 2" ;
     RESOURCE "CALENDARIO1" ACTION nOption := 2
  MENUITEM "Opcion 3" ;
     RESOURCE "CALENDARIO1" ACTION nOption := 3
  MENUITEM "Opcion 4" ;
     RESOURCE "CALENDARIO1" ACTION nOption := 4
ENDMENU
ACTIVATE POPUP oMenu AT nTopR , nLeftR + 10 OF oObj

? nOption, nId

Return(Nil)

 
User avatar
Willi Quintana
 
Posts: 1019
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: BTNBMP AND POPUP

Postby Silvio.Falconi » Mon Mar 28, 2016 6:51 pm

please I tried your help but none run ok .....
can U publish a test sample ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: BTNBMP AND POPUP

Postby ukoenig » Tue Mar 29, 2016 10:59 am

Silvio Your running sample

I used Your sample but shortend the code for my test
without Your DBF, to show the main-logic
You only want to show the popup on button-action ?
It is possible to use a combination of < Action > and < oBtn[n]:bRclicked >

Image

Code: Select all  Expand view

#include "FiveWin.ch"
#include "constant.ch"

FUNCTION TEST()
Local oDlgTest,oGrid
Local  aPrompts:={"faldone 1"}

Local  nBottom   := 29.2
Local  nRight    :=  58
Local  nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
Local  nHeight   :=  nBottom * DLG_CHARPIX_H

DEFINE DIALOG oDlgTest         ;
SIZE nWidth, nHeight   PIXEL  ;    //TRUEPIXEL
TITLE "Test"  TRANSPARENT

oGrid := TFolderex():New( , , , , oDlgTest, , ,, aPrompts)
oGrid:nTop    := 00
oGrid:nLeft   := 00
oGrid:nBottom := 200
oGrid:nRight  := 300

ACTIVATE DIALOG oDlgTest ;
ON INIT SHOW_RACCOGLITORI(oGrid)

RETURN NIL

//----------------------------------

FUNCTION  SHOW_RACCOGLITORI(oGrid)

Local  oFontsmall:= TFont():New( "Tahoma", 0, -9,,.F. )
Local cCursor:= TCursor():New(,'HAND')

Local nRow := 10
Local ncol := 10

Local nsizeW:= 84
Local nsizeh:= 240

Local n:= 1
Local oBtn[4],oBasket2

nNumeroPerLinea:= 15+1
k:= 1
i := 1
nCaption := 1

FOR I := 1 TO 4
    cPrompt := ALLTRIM( STR( I ) )
    @ nrow, ncol BTNBMP oBtn[n] of oGrid:adialogs[1] ;
                  SIZE nsizeW, nsizeh PIXEL 2007 ;
                  Prompt cPrompt  ; // optional use ACTION ..... and oBtn[n]:bRclicked
                  NOBORDER ;
                  CENTER

    oBtn[n]:oCursor:= cCursor
    oBtn[n]:lBorder := .F.  // display Top / Right
    oBtn[n]:bAction := bEjecutaBoton(   0, oBtn[n]:nWidth,  n,oBtn[n], nCaption)
    // Action works using
    // oBtn[n]:bRclicked := bEjecutaBoton(   0, oBtn[n]:nWidth,  n,oBtn[n], nCaption)
    // use a Tooltip to tell the user about this option

    ncol:= ncol+nsizeW+5
    n:=n+1

    k++

    IF k = nNumeroPerLinea
        nRow += nsizeh+10
        ncol := 10
        k:= 1
    Endif

NEXT

return nil

//---------------------

FUNCTION BEJECUTABOTON( nrow, ncol, n, oControl )
       
RETURN { |n| Menu_popup( nrow, ncol, n, oControl )  }

//--------------------

FUNCTION MENU_POPUP( nrow, ncol, n, oControl )
Local oMenuPop

MENU oMenuPop POPUP
          MENUITEM "Apri "
          MENUITEM "WWW"
ENDMENU

// optional
// oMenuPop:Activate( nrow, ncol, oControl, .T.)

ACTIVATE POPUP oMenuPop OF oControl AT nrow, ncol

RETURN NIL
 


best regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BTNBMP AND POPUP

Postby Silvio.Falconi » Tue Mar 29, 2016 12:15 pm

is there no possibility to not show the arrow and show only the popmenu near the button when the user press on it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: BTNBMP AND POPUP

Postby Marcelo Via Giglio » Tue Mar 29, 2016 1:51 pm

Try with this

Code: Select all  Expand view

......
        REDEFINE BTNBMP PROMPT "Nuevo"  NOBORDER OF oDlg ID 112 ;
                 TOOLTIP "Nueva solicitud <Ins>" ;
                  ACTION MenuPop ( Self  )

......

//------------------------------------------------------------------------------
Static Function MenuPop( oBtn )
//------------------------------------------------------------------------------

   Local oMenu, aRect

   aRect := GetClientRect( oBtn:hWnd )

   MENU oMenu POPUP
      MENUITEM "Caja Chica"                    ACTION   solicitud ( "new", "caja" )        RESOURCE "cbx_cajachica"
      MENUITEM "Cargo a Rendición "            ACTION   solicitud ( "new", "cargo" )       RESOURCE "cbx_rendicion"
      MENUITEM "Viáticos y Estipendios"        ACTION   solicitud ( "new", "viaticos" )    RESOURCE "cbx_viaticos"
      MENUITEM "Pago a proveedores y terceros" ACTION   solicitud ( "new", "proveedores" ) RESOURCE "cbx_proveedores"
   ENDMENU

   ACTIVATE POPUP oMenu AT aRect[ 3 ] + 1, aRect[ 2 ] OF oBtn

Return Nil
 
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: BTNBMP AND POPUP

Postby Silvio.Falconi » Tue Mar 29, 2016 5:00 pm

IT IS THE SAME!!!!!!
I see also the border and the arrow
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: BTNBMP AND POPUP

Postby Marcelo Via Giglio » Tue Mar 29, 2016 6:51 pm

Yes, this is strange because we don't define menu option in btnbmp, then try with this change

Code: Select all  Expand view


ACTIVATE POPUP oMenu AT aRect[ 3 ] + 1, aRect[ 2 ] OF oBtn:oWnd

 


you will need to calculate new values for offset

saludos

Marcelo
Marcelo Via Giglio
 
Posts: 1064
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: BTNBMP AND POPUP

Postby ukoenig » Tue Mar 29, 2016 7:06 pm

Just add a button-refresh
The arrow is only visible during executing the popup


STATIC FUNCTION MENUPOP( oBtn )
Local oMenu, aRect

aRect := GetClientRect( oBtn:hWnd )

MENU oMenu POPUP 2010
MENUITEM "Caja Chica" ACTION MsgAlert( "1" )
MENUITEM "Cargo a Rendición " ACTION MsgAlert( "2" ) BOLD
MENUITEM "Viáticos y Estipendios" ACTION MsgAlert( "3" )
MENUITEM "Pago a proveedores y terceros" ACTION MsgAlert( "4" )
ENDMENU

ACTIVATE POPUP oMenu AT aRect[ 3 ] + 1, aRect[ 2 ] OF oBtn
oBtn:Refresh()

RETURN NIL

best regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BTNBMP AND POPUP

Postby Silvio.Falconi » Tue Mar 29, 2016 7:40 pm

thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests