FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour refresh a get with when
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
refresh a get with when
Posted: Tue Sep 22, 2015 09: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 March-April 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
Posts: 346
Joined: Mon Oct 05, 2009 03:35 PM
Re: refresh a get with when
Posted: Tue Sep 22, 2015 11:51 AM
silvio se me ocurre asi:

Code (fw): Select all Collapse
@ 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
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: refresh a get with when
Posted: Tue Sep 22, 2015 03:14 PM
Silvio:

Or this way

Code (fw): Select all Collapse
@ 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
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: refresh a get with when
Posted: Tue Sep 22, 2015 03: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 (fw): Select all Collapse
@ 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 (fw): Select all Collapse
@ 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
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: refresh a get with when
Posted: Tue Sep 22, 2015 05:06 PM
Armando wrote:Silvio:

Or this way

Code (fw): Select all Collapse
@ 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... :-)
Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: refresh a get with when
Posted: Wed Sep 23, 2015 07:13 AM
Dear Friends ,
I tried but here not run ok

i made a tet sample to try
Code (fw): Select all Collapse
#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 March-April 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
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: refresh a get with when
Posted: Wed Sep 23, 2015 11:20 AM
Perfect!

Just add the following line:
Code (fw): Select all Collapse
     @ 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"
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: refresh a get with when
Posted: Wed Sep 23, 2015 05: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 March-April 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
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: refresh a get with when
Posted: Wed Sep 23, 2015 08: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"
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: refresh a get with when
Posted: Thu Sep 24, 2015 08:38 AM
I explain you






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 (fw): Select all Collapse
#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 March-April 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
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: refresh a get with when
Posted: 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 (fw): Select all Collapse
(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"

Continue the discussion