refresh a get with when

refresh a get with when

Postby Silvio.Falconi » Tue Sep 22, 2015 9:44 am

I have a combobox and I wish refresh some gets
I wish enable the aget[10] and aget[11] only if the aTipoOp=1


local lTutteOp := .t.
local aTipoOp := {"Entrate","Uscite"}
local cTipoOp := aTipoOp[1]

Local lTClienti := .t.
Local cClienti := ''"
Local aClienti := {"Cliente1","Cliente2","Cliente3}

DEFINE DIALOG...


@ 58, 56 CHECKBOX aGet[8] VAR lTutteOp PROMPT "Tutte" SIZE 25,8 PIXEL OF oDlg
@ 58, 145 COMBOBOX aGet[9] VAR cTipoOp ITEMS aTipoOp SIZE 75,12 PIXEL OF oDlg WHEN ! lTutteOp ;
ON CHANGE ( aGet[10]:refresh(),aGet[11] :refresh() )

@ 72, 56 CHECKBOX aGet[10] VAR lTClienti PROMPT "Tutti" SIZE 25,8 PIXEL OF oDlg WHEN cTipoOp==aTipoOp[1]
@ 72, 145 COMBOBOX aGet[11] VAR cClienti ITEMS aClienti SIZE 75,12 PIXEL OF oDlg WHEN ! lTClienti

ACTIVATE DIALOG oDlg

Why the when clausole is not processed ?
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: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: refresh a get with when

Postby armando.lagunas » Tue Sep 22, 2015 11:51 am

silvio se me ocurre asi:

Code: Select all  Expand view  RUN


@ 58, 56 CHECKBOX aGet[8] VAR lTutteOp PROMPT "Tutte" SIZE 25,8 PIXEL OF oDlg

@ 58, 145 COMBOBOX aGet[9] VAR cTipoOp ITEMS aTipoOp SIZE 75,12 PIXEL OF oDlg WHEN {|| ! lTutteOp }
          aGet[9]:bChange  := {||  aGet[10]:refresh(), aGet[11]:refresh() }

@ 72, 56 CHECKBOX aGet[10] VAR lTClienti PROMPT "Tutti" SIZE 25,8 PIXEL OF oDlg WHEN {|| cTipoOp==aTipoOp[1] }

@ 72, 145 COMBOBOX aGet[11] VAR cClienti ITEMS aClienti SIZE 75,12 PIXEL OF oDlg WHEN {|| ! lTClienti }

 


Saludos!
SkyPe: armando.lagunas@hotmail.com
Mail: armando.lagunas@gmail.com
User avatar
armando.lagunas
 
Posts: 346
Joined: Mon Oct 05, 2009 3:35 pm
Location: Curico-Chile

Re: refresh a get with when

Postby Armando » Tue Sep 22, 2015 3:14 pm

Silvio:

Or this way

Code: Select all  Expand view  RUN

@ 58, 56 CHECKBOX aGet[8] VAR lTutteOp PROMPT "Tutte" SIZE 25,8 PIXEL OF oDlg;
              ON CHANGE oDlg:AEvalWhen()
 


Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3242
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: refresh a get with when

Postby Carlos Mora » Tue Sep 22, 2015 3:52 pm

Hi Silvio,

Combobox's bChange is evaluated when the control changes, but that doen't means that the new value is assigned to the var.
In you example you can check what I mean, adding a MsgInfo() or another way to inspect the cTipoOp value:

Code: Select all  Expand view  RUN

@ 58, 145 COMBOBOX aGet[9] VAR cTipoOp ITEMS aTipoOp SIZE 75,12 PIXEL OF oDlg WHEN {|| ! lTutteOp }
          aGet[9]:bChange  := {|| MsgInfo(cTipoOp), aGet[10]:refresh(), aGet[11]:refresh() }
 


It's not a good idea to use bChange because it is fired on window's internal value change, not var change.
May be a little trick can help, but, if you can, use VALID clause

Try this:
Code: Select all  Expand view  RUN

@ 58, 145 COMBOBOX aGet[9] VAR cTipoOp ITEMS aTipoOp SIZE 75,12 PIXEL OF oDlg WHEN {|| ! lTutteOp }
          aGet[9]:bChange  := {|| aGet[9]:Assign(), aGet[10]:refresh(), aGet[11]:refresh() }
 


Regards
Last edited by Carlos Mora on Wed Sep 23, 2015 6:55 am, edited 1 time in total.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: refresh a get with when

Postby joseluisysturiz » Tue Sep 22, 2015 5:06 pm

Armando wrote:Silvio:

Or this way

Code: Select all  Expand view  RUN

@ 58, 56 CHECKBOX aGet[8] VAR lTutteOp PROMPT "Tutte" SIZE 25,8 PIXEL OF oDlg;
              ON CHANGE oDlg:AEvalWhen()
 


Regards


Realizo algo parecido a lo tuyo y utilizo asi como dice Armando y funciona bien, me refresca todos los oBjetos, si quieres alguno u otrac accion, simplemente llama a una funcion y pasale los GET para que hagas lo que necesites, saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: refresh a get with when

Postby Silvio.Falconi » Wed Sep 23, 2015 7:13 am

Dear Friends ,
I tried but here not run ok

i made a tet sample to try
Code: Select all  Expand view  RUN
#include "FiveWin.ch"
#include "constant.ch"



Function Test()
local oDlg, aGet[40]


local lTutteOp   := .t.
local aTipoOp := {"Entrate","Uscite"}
local cTipoOp := aTipoOp[1]

Local lTClienti  := .t.
Local cClienti   := ''
Local aClienti   := {}

Local lTFornitori  := .t.
Local cFornitori   := ''
Local aFornitori   := {}


// per la dialog 1...
   Local nBottom   := 25
   Local nRight    := 57
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H


aClienti := {"Cliente1","Cliente2","Cliente3"}
aFornitori:= {"Provveder1","Provveder2","Provveder3"}


 DEFINE DIALOG oDlg        ;
   TITLE "Assistente alla ricerca movimenti"    ;
   SIZE nWidth, nHeight  PIXEL  


 @ 60, 10 SAY "Operation type" OF oDlg SIZE 55, 8 PIXEL
 @ 58, 56  CHECKBOX aGet[8] VAR lTutteOp PROMPT "All" SIZE 25,8  PIXEL OF oDlg
 @ 60, 100 SAY "Select :" OF oDlg SIZE 55, 8 PIXEL
 @ 58, 145 COMBOBOX aGet[9] VAR cTipoOp ITEMS aTipoOp SIZE 75,12 PIXEL  OF oDlg   WHEN  !lTutteOp


  @ 74, 10 SAY "clients " OF oDlg SIZE 55, 8 PIXEL
  @ 72, 56  CHECKBOX aGet[10] VAR lTClienti PROMPT "All" SIZE 25,8  PIXEL OF oDlg  WHEN  cTipoOp==aTipoOp[1]
  @ 74, 100 SAY "Select:" OF oDlg SIZE 55, 8 PIXEL
  @ 72, 145 COMBOBOX aGet[11] VAR cClienti ITEMS aClienti SIZE 75,12 PIXEL  OF oDlg  WHEN  !lTClienti   .AND.   cTipoOp==aTipoOp[1]


  @ 88, 10 SAY "Proveders " OF oDlg SIZE 55, 8 PIXEL
  @ 86, 56  CHECKBOX aGet[12] VAR lTFornitori PROMPT "All" SIZE 25,8  PIXEL OF oDlg   WHEN  cTipoOp==aTipoOp[2]
  @ 88, 100 SAY "Select:" OF oDlg SIZE 55, 8 PIXEL
  @ 86, 145 COMBOBOX aGet[13] VAR cfornitori ITEMS aFornitori SIZE 75,12 PIXEL  OF oDlg  WHEN  !lTFornitori   .AND.   cTipoOp==aTipoOp[2]


  activate dialog oDlg

RETU NIL
 




the problem and what I wish

At init all combobox are disable
If the user click on all ( checkbox) it make enable the combobox
If the user select the first option of the first combobox "Entrate" must be activate only the 2th combobox ( and the second checkbox)
If the user select the second option of the first combobox "Uscite" must be activate only the 3th combobox ( and the third checkbox)

I hope help me
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: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: refresh a get with when

Postby Carlos Mora » Wed Sep 23, 2015 11:20 am

Perfect!

Just add the following line:
Code: Select all  Expand view  RUN

     @ 58, 145 COMBOBOX aGet[9] VAR cTipoOp ITEMS aTipoOp SIZE 75,12 PIXEL  OF oDlg   WHEN  !lTutteOp
        aGet[9]:bChange  := {|| aGet[9]:oGet:Assign(), oDlg:AEvalWhen() } // <--- Add this

 


Tested and i think it works as you spected. The point is that bChange is fired when control's internal buffer changes, but that change is not taken into the VAR's value until the COMBOBOX looses focus.
Just test it in the original form, navigating using <Tab>. Assign() does the trick: copies the controls value into the var.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: refresh a get with when

Postby Silvio.Falconi » Wed Sep 23, 2015 5:48 pm

it seem to run
but if you select before the second element of the first combo and the press the checkbox of the third line and then reselect the first element the first combo the checkbox the third line is allway .f.
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: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: refresh a get with when

Postby Carlos Mora » Wed Sep 23, 2015 8:19 pm

Silvio,
Don't get you. Do you mean that, when you return the focus to the first combo and select the first one the third control set is .f. ?
May be there is a problem in your logic: If the first combo has the value "clients", ANY VALUE for the third set of vars have NO MEANING. As a rule of thumb, if a control has it's when in .f. there is nothing to do with it's value.
Probably you should put more code in the Combo OnChange to set things as you want.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: refresh a get with when

Postby Silvio.Falconi » Thu Sep 24, 2015 8:38 am

I explain you

Image




I put also word on espana language to understood the problem

On My archive I have a filed called MvTipo the value can be E or U ( Ingreso or Gastos)

If is E the user can insert Customers and category of Ingreso
If is U the user can insert Provveders and category of Gastos

in that dialog ( with combos) I wish create a research on this archive and I ask to final user

1. if he want search all moviments ( apuntes) or can select only "Entrata" (ingreso) or only "Uscita" (gastos)

the procedure must refresh the combos

"Clienti" ( clientes) if the type of moviments( apuntes) is E (ingreso)

"Fornitori" (provveders) if the type of moviments (apuntes) is U (gastos)

and it make right ..refresh the combobox

If the final user before to press the button "confirm" wish change the first combobox ( Ingreso or Gastos) then the other comboboxes are not refresh()

I add also two combobox one for clientes and one for provveders

it run but after many times the comboboxes are not refresh or there is something of error
or I'm afraid that in the end does not work, or the final user can not figure out how to do the research

new code to try

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



Function Test()
local oDlg, aGet[40]


local lTutteOp   := .t.
local aTipoOp := {"Entrate","Uscite"}
local cTipoOp := aTipoOp[1]

Local lTClienti  := .t.
Local cClienti   := ''
Local aClienti   := {}

Local lTFornitori  := .t.
Local cFornitori   := ''
Local aFornitori   := {}

Local lTEntrate  := .t.
Local cEntrate   := ''
Local aEntrate   := {}

Local lTUscite  := .t.
Local cUscite   := ''
Local aUscite   := {}

// per la dialog 1...
   Local nBottom   := 35
   Local nRight    := 57
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H
    Local  oBtnOK,oBtnCan

aClienti := {"Cliente1","Cliente2","Cliente3"}
aEntrate  := {"Entrate1","Entrate2","Entrate3"}

aFornitori:= {"Provveder1","Provveder2","Provveder3"}
aUscite   := {"Uscite1","Uscite2","Uscite3"}


 DEFINE DIALOG oDlg        ;
   TITLE "Assistente alla ricerca movimenti"    ;
   SIZE nWidth, nHeight  PIXEL


 @ 60, 10 SAY "Tipo movimento" OF oDlg SIZE 55, 8 PIXEL
 @ 58, 56  CHECKBOX aGet[8] VAR lTutteOp PROMPT "Tutti" SIZE 25,8  PIXEL OF oDlg
 @ 60, 100 SAY "Selezionare :" OF oDlg SIZE 55, 8 PIXEL
 @ 58, 145 COMBOBOX aGet[9] VAR cTipoOp ITEMS aTipoOp SIZE 75,12 PIXEL  OF oDlg   WHEN  !lTutteOp

 aGet[9]:bChange  := {|| aGet[9]:oGet:Assign(), oDlg:AEvalWhen() } // <--- Add this



  @ 74, 10 SAY "Pagatori" OF oDlg SIZE 55, 8 PIXEL
  @ 72, 56  CHECKBOX aGet[10] VAR lTClienti PROMPT "Tutti" SIZE 25,8  PIXEL OF oDlg  WHEN {|| cTipoOp==aTipoOp[1] .and.  !lTutteOp}
  @ 74, 100 SAY "Selezionare :" OF oDlg SIZE 55, 8 PIXEL
  @ 72, 145 COMBOBOX aGet[11] VAR cClienti ITEMS aClienti SIZE 75,12 PIXEL  OF oDlg  WHEN {|| ! lTClienti .and. cTipoOp==aTipoOp[1] }


  @ 88, 10 SAY "Causali Entrate " OF oDlg SIZE 55, 8 PIXEL
  @ 86, 56  CHECKBOX aGet[12] VAR lTEntrate PROMPT "Tutti" SIZE 25,8  PIXEL OF oDlg   WHEN  cTipoOp==aTipoOp[1] .and.  !lTutteOp
  @ 88, 100 SAY "Selezionare:" OF oDlg SIZE 55, 8 PIXEL
  @ 86, 145 COMBOBOX aGet[13] VAR cEntrate ITEMS aEntrate SIZE 75,12 PIXEL  OF oDlg  WHEN  !lTEntrate   .AND.   cTipoOp==aTipoOp[1]



  @ 102, 10 SAY "Fornitori " OF oDlg SIZE 55, 8 PIXEL
  @ 100, 56  CHECKBOX aGet[14] VAR lTFornitori PROMPT "Tutti" SIZE 25,8  PIXEL OF oDlg   WHEN  cTipoOp==aTipoOp[2]  .and.  !lTutteOp
  @ 102, 100 SAY "Selezionare:" OF oDlg SIZE 55, 8 PIXEL
  @ 100, 145 COMBOBOX aGet[15] VAR cfornitori ITEMS aFornitori SIZE 75,12 PIXEL  OF oDlg  WHEN  !lTFornitori   .AND.   cTipoOp==aTipoOp[2]

  @ 116, 10 SAY "Causali Uscite " OF oDlg SIZE 55, 8 PIXEL
  @ 114, 56  CHECKBOX aGet[16] VAR lTUscite PROMPT "Tutti" SIZE 25,8  PIXEL OF oDlg   WHEN  cTipoOp==aTipoOp[2]   .and.  !lTutteOp
  @ 116, 100 SAY "Selezionare:" OF oDlg SIZE 55, 8 PIXEL
  @ 114, 145 COMBOBOX aGet[17] VAR cUscite ITEMS aUscite SIZE 75,12 PIXEL  OF oDlg  WHEN  !lTuscite   .AND.   cTipoOp==aTipoOp[2]











    @ 250, 121 BUTTON oBtnOK PROMPT "&Conferma" SIZE 42, 12 PIXEL ACTION ( oDlg:end( IDOK ) )
          oBtnOK:cTooltip := i18n("Conferma")

   @ 250, 172 BUTTON oBtnCan PROMPT "&Annulla"  SIZE 42, 12 PIXEL ACTION  ( oDlg:end( IDCANCEL ) )
          oBtnCan:cTooltip := i18n("Annulla la ricerca")

  activate dialog oDlg

 
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: 7090
Joined: Thu Oct 18, 2012 7:17 pm

Re: refresh a get with when

Postby Carlos Mora » Thu Sep 24, 2015 11:50 am

Silvio,

I don't speak italian, but for an spanish speaker italian is more or less 'understable'. I can run your code and it runs fine, activating and deactivating the controls as spected, that's why i told you i don't understand.
If the dialog is not easy to understand FOR THE USER, it's a different issue.

May I sugest a change? Instead of using a combo for {"Entrate","Uscite"}, use a RADIOGROUP. Then, avoid 'Tutti' checkboxes and add a '<<TUTTI>>' option to the Clienti, Fornitori, Entrate, Uscite COMBOBOXES

Code: Select all  Expand view  RUN

(0) Tutti
( ) Entrate       Pagatori [ <<TUTTI>> v ]
                           [ Cliente1    ]
                           [ Cliente2    ]
                           [ Cliente3    ]
                           
           Causali Entrate [ <<TUTTI>> v ]
                           [ Entrate1    ]
                           [ Entrate2    ]
                           [ Entrate3    ]
   
( ) Uscite      Fornitori  [ <<TUTTI>> v ]
                           [ Fornitori1  ]
                           [ Fornitori2  ]
                           [ Fornitori3  ]
                           
           Causali Uscite  [ <<TUTTI>> v ]
                           [ Uscite1     ]
                           [ Uscite2     ]
                           [ Uscite3     ]
 


Sorry for the AsciiArt, but it's faster than drawing :)
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests