FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Detecting the button-pos on action from a btn-list (array)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Detecting the button-pos on action from a btn-list (array)
Posted: Tue Apr 02, 2013 11:18 PM
Hello,

I created a Buttonlist inside a DO WHILE from a DBF.
The buttons are painted with defined size and prompts without any problem.
Now I need the button-number/position of a selected button-action from the buttonlist ( array ).

Code (fw): Select all Collapse
nAreas := 0
DO WHILE (1)->IMAGE = cWImage .and. !EOF()
   nAreas++
   AAdd( oHArea, nAreas )
   AAdd( aPrompts, ALLTRIM(STR( (1)->HOTSPOT )) )
   @ (1)->TOP, (1)->LEFT BTNBMP oHArea[nAreas] OF oHDialog ;
   PIXEL SIZE (1)->WIDTH, (1)->HEIGHT ;
   PROMPT ALLTRIM(STR(nAreas)) ;
   ACTION  MsgAlert( ???? )  ;  // BUTTONPOSITION needed ????
   FONT oFont2 ;
   ROUND CENTER DESIGN
   oHArea[nAreas]:lTransparent := .t.   
   oHArea[nAreas]:cTooltip :=  ALLTRIM(STR(nAreas)) // displayed Number OK !!!
   oHArea[nAreas]:SetColor( nHSpotCol, )
   DBSKIP(+1)
ENDDO




Best Regards
Uwe :-)
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.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to get the Btn-pos from a Btn-list-array on action ?
Posted: Wed Apr 03, 2013 01:59 PM
I got it working, but looks a bit complicated ( maybe there is still another possible solution ? )
I can have many buttons, but I create only 1.
At the end of the button-define and after the DO WHILE I added :

ENDDO
AEval( oHDialog:aControls, {|o| TEST_POS( o ) } )
RETURN NIL

Because I know the button-width and height, I can define the related action

FUNCTION TEST_POS( o )

o:bAction := {|| ;
IIF( o:nWidth = 96 .and. o:nHeight = 96, MsgAlert( 1 ), NIL ), ;
IIF( o:nWidth = 72 .and. o:nHeight = 56, MsgAlert( 2 ), NIL ), ;
IIF( o:nWidth = 80 .and. o:nHeight = 72, MsgAlert( 3 ), NIL ) }

RETURN NIL


or using the defined TOOLTIPS

FUNCTION TEST_POS( o )

o:bAction := {|| ;
IIF( o:cToolTip = "1", MsgAlert( 1 ), NIL ), ;
IIF( o:cToolTip = "2", MsgAlert( 2 ), NIL ), ;
IIF( o:cToolTip = "3", MsgAlert( 3 ), NIL ) }

RETURN NIL


Best Regards
Uwe :-)
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.

Continue the discussion