Problem with Valid of tget Resolved!!

Post Reply
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Problem with Valid of tget Resolved!!

Post by Eoeo »

When I select an item from an archive the valid get function must refresh a combobox
the valid function return .t. only if the cvalue is "Adele" and set lok=true
the combobox control must be activate when lok is true

the problem :
the test run ok only when I select an item from xbrowse it not refresh the combobox

only when the final user move the mouse cursor on the second get (oget[2] ) the combobox is refreshed.

if there are many selections (on the app) on a dialog the combobox is never refreshed

this is the test minimal to try

Code: Select all


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

#define LIGHTCYAN        nRGB( 203, 225, 252 )


Function test()
Local oDlg
Local oGet[4]
local cGet1:="Adrian",cGet2 :=SPACE(30)
lOCAL cGet3:=1
LOcal aItems:={"16","21","4.50"}
   Local lOk:=.f.
   Local nBottom   := 20
   Local nRight    := 40
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H

   USE  CUSTOMER ALIAS CU
   INDEX ON CU->FIRST TAG FIRST TO CUSTOMER

DEFINE DIALOG oDlg SIZE nWidth, nHeight;
                    GRADIENT { { 1,CLR_WHITE, LIGHTCYAN } }    ;
                 STYLE DS_MODALFRAME + WS_POPUPWINDOW + WS_VISIBLE + WS_DLGFRAME + 4;
                 TITLE "test" PIXEL
@ 12, 5 SAY "Get 1:" OF oDlg SIZE 35, 8 PIXEL
@ 22, 5  SAY "Get 2" OF oDlg SIZE 35, 8 PIXEL
@ 10, 56  GET    oGet[1] VAR  cGEt1 OF oDlg SIZE 85, 10 PIXEL  VALID Change_Combox(cGEt1,@lok,oGet);
               ACTION    Select_Items(cGEt1,oGet[1],oDlg)
@ 24, 56  GET    oGet[2] VAR  cGEt2 OF oDlg SIZE 85, 10 PIXEL
@ 50 , 5 COMBOBOX oGet[3] VAR cGEt3 ITEMS aItems OF oDlg SIZE 40, 95 PIXEL STYLE CBS_DROPDOWN;
      WHEN lok  UPDATE
ACTIVATe DIALOG oDlg center
RETU NIL


Function Select_Items(cGEt1,oControl,oDlg)
   Local nBottom   := 14.2
   Local nRight    := 55
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H
   local oBrowse ,lsave:=.f.
   local nRecno := CU->( RecNo() )
   local nOrder := CU->( OrdNumber() )
   local nArea  := Select()
   SELECT CU
     CU->( DbSetOrder( 1 ) )
   CU->( DbGoTop( ) )
   DEFINE DIALOG oDlg        ;
   TITLE i18n("Select an item")
@02, 10 XBROWSE   oBrowse OF oDlg ;
      SIZE -10,-10 PIXEL
   oBrowse:cAlias := "CU"
   oCol := oBrowse:AddCol()
   oCol:bStrData := { || CU->FIRST }
   oCol:cHeader  := "NAME"
   oCol:nWidth   := 120
   oCol:bLDClickData  := {|| ( lsave := .t., oDlg:End() )   }
   oBrowse:SetRDD()
   oBrowse:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
   if lsave
     oControl:cText := CU->FIRST
     oControl:refresh()
    endif
   CU->( DbSetOrder( nOrder ) )
   CU->( DbGoTo( nRecno ) )
   Select (nArea)
return nil






Function Change_Combox(cGEt1,lok,oGet)
  Local lreturn :=.f.
 IF    alltrim(cGEt1)="Adele"
                 lreturn:=.t.
        ENDIF
oGet[3]:refresh()
lok:=lreturn
return lReturn


 
Last edited by Eoeo on Mon Sep 17, 2012 2:04 pm, edited 1 time in total.
kok joek hoa
Posts: 117
Joined: Tue Jan 03, 2006 6:18 pm

Re: Problem with Valid of tget

Post by kok joek hoa »

Dear Eoeo

Try this

Code: Select all

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

#define LIGHTCYAN        nRGB( 203, 225, 252 )


Function test()
Local oDlg
Local oGet[4]
local cGet1:="Adrian",cGet2 :=SPACE(30)
lOCAL cGet3:=1
LOcal aItems:={"16","21","4.50"}
   Local lOk:=.f.
   Local nBottom   := 20
   Local nRight    := 40
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H

   USE  CUSTOMER ALIAS CU
   INDEX ON CU->FIRST TAG FIRST TO CUSTOMER

DEFINE DIALOG oDlg SIZE nWidth, nHeight;
                    GRADIENT { { 1,CLR_WHITE, LIGHTCYAN } }    ;
                 STYLE DS_MODALFRAME + WS_POPUPWINDOW + WS_VISIBLE + WS_DLGFRAME + 4;
                 TITLE "test" PIXEL
@ 12, 5 SAY "Get 1:" OF oDlg SIZE 35, 8 PIXEL
@ 22, 5  SAY "Get 2" OF oDlg SIZE 35, 8 PIXEL
@ 10, 56  GET    oGet[1] VAR  cGEt1 OF oDlg SIZE 85, 10 PIXEL  ;
          ACTION     ( Select_Items(cGEt1,oGet[1],oDlg) ,iif(Change_Combox(cGEt1,@lok,oGet),oGet[3]:enable(),oGet[3]:disable()) ) 

          
@ 24, 56  GET    oGet[2] VAR  cGEt2 OF oDlg SIZE 85, 10 PIXEL
@ 50 , 5 COMBOBOX oGet[3] VAR cGEt3 ITEMS aItems OF oDlg SIZE 40, 95 PIXEL STYLE CBS_DROPDOWN;
     // WHEN lok  UPDATE
ACTIVATe DIALOG oDlg center ;
    on init oGet[3]:disable()
RETU NIL


Function Select_Items(cGEt1,oControl,oDlg)
   Local nBottom   := 14.2
   Local nRight    := 55
   Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
   Local nHeight := nBottom * DLG_CHARPIX_H
   local ocol
   local oBrowse ,lsave:=.f.
   local nRecno := CU->( RecNo() )
   local nOrder := CU->( OrdNumber() )
   local nArea  := Select()
   SELECT CU
     CU->( DbSetOrder( 1 ) )
   CU->( DbGoTop( ) )
   DEFINE DIALOG oDlg        ;
   TITLE i18n("Select an item")
@02, 10 XBROWSE   oBrowse OF oDlg ;
      SIZE -10,-10 PIXEL
   oBrowse:cAlias := "CU"
   oCol := oBrowse:AddCol()
   oCol:bStrData := { || CU->FIRST }
   oCol:cHeader  := "NAME"
   oCol:nWidth   := 120
   oCol:bLDClickData  := {|| ( lsave := .t., oDlg:End() )   }
   oBrowse:SetRDD()
   oBrowse:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
   if lsave
     oControl:cText := CU->FIRST
     oControl:refresh()
    endif
   CU->( DbSetOrder( nOrder ) )
   CU->( DbGoTo( nRecno ) )
   Select (nArea)
return nil






Function Change_Combox(cGEt1,lok,oGet)
    Local lreturn :=.f.
    IF   alltrim(cGEt1)="Adele"
        lreturn:=.t.
    ENDIF
    lok:=lreturn        
return lReturn
 


Regards,

Kok
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Problem with Valid of tget

Post by Eoeo »

thanks I resolved !!
Post Reply