Jump to content
Fivewin Brasil

Say com cliques


mkyx

Recommended Posts

Pessoal o que pode está errado na rotina abaixo, pois eu clico em qualquer um dos nome e só mostra o primeiro nome da lista:

 

#include "fivewin.ch"

function main()
  
  
define dialog rel_11 title "teste"

hist:={"ze","mane","maria","pedro","joao"}

li_1:=15
_pos:=100
for qth=1 to 5
    I0:=STRZERO(QTH,3)
    c_obj:="V_H"+I0
    hh:=HIST[qth]
    @ LI_1,50 SAY &C_OBJ. VAR HIST[qth] PIXEL OF rel_11 SIZE _POS,15
    &C_OBJ.:lWantClick = .t.
    &C_OBJ.:bLClicked  = { || _movim(hh) }
    &C_OBJ.:CTOOLTIP:=ALLTRIM(hh)
    &c_obj.:cvarName:=ALLTRIM(hh)
    li_1:=li_1+15
next       
      
activate dialog rel_11 centered

return .t.


FUNCTION _movim(REL_111)
N_HIST:=""
for ii=1 to len(REL_11:aControls)
    if upper(REL_11:aControls[ii]:className())="TSAY" .AND. REL_11:aControls[ii]:lFocused   // verifica se é um objeto SAY e se foi o que recebeu o click do mouse
        N_HIST:=rel_11:aControls[ii]:cVarName   // aqui pega o nome da variável
        II:=len(rel_11:aControls)+10   // aqui agiliza para sair do loop for-next
    ENDIF
next ii

? "O nome onde o mouse tocou é = ",N_HIST

return .t.      

 

Eu não sei, se essa declaração REL_11:aControls[ii]:lFocused é realmente o comando para saber onde o mouse clicou.

 

Alguém saberia informar?

 

Obrigado

 
      

 

Link to comment
Share on other sites

\samples\TESTSAY2.PRG

// A sample showing to to let a SAY accept Clicks events
	#include "FiveWin.ch"
	#define COLOR_BTNFACE       15
	function Main()
	   local oDlg, oSay, oCursor
	   DEFINE CURSOR oCursor HAND
	   DEFINE DIALOG oDlg
	   @ 2, 2 SAY oSay PROMPT "Test" BORDER   ;
          COLORS CLR_HRED, CLR_WHITE
	   oSay:lWantClick = .t.
   oSay:bLClicked  = { || oSay:SetColor( CLR_WHITE, GetSysColor( COLOR_BTNFACE ) ),;
                          oSay:Refresh(), MsgInfo( "Hello" ) }
   oSay:oCursor    = oCursor
	   ACTIVATE DIALOG oDlg CENTERED
	return nil


Link to comment
Share on other sites

Boa noite, resolvi assim:

#include "fivewin.ch"

function main()
  
  
define dialog rel_11 title "teste"

hist:={"ze","mane","maria","pedro","joao"}

li_1:=15
_pos:=100
for qth=1 to 5
    I0:=STRZERO(QTH,3)
    c_obj:="V_H"+I0
    hh:=HIST[qth]
    @ LI_1,50 SAY &C_OBJ. VAR HIST[qth] PIXEL OF rel_11 SIZE _POS,15
    &C_OBJ.:lWantClick = .t.
    &C_OBJ.:bLClicked  = { || _movim(&c_obj.:cvarName) }
    &C_OBJ.:CTOOLTIP:=ALLTRIM(hh)
    &c_obj.:cvarName:=ALLTRIM(hh)
    li_1:=li_1+15
next       
      
activate dialog rel_11 centered

return .t.


FUNCTION _movim(REL_111)

? rel_111

return .t.

 

Blz.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...