Page 1 of 1
"DynamicBackColor" within a BROWSE
Posted: Tue Jul 07, 2020 1:12 pm
by Red2
Hi All,
I have one problem using "DynamicBackColor". In a (modal) form I have a BROWSE control to display a .DBF table. Column #1's value is binary, either "Yes" or " " (empty). If "Yes" then the row's DynamicBackColor displays it as green. This works in most cases. My codeblock array is:
Code: Select all
bkState := { || iif( empty( By_State->MergeState ), {255,255,255}, {190,255,170} ) }
This browse has a
ControlContextMenu. Its Right-Click
MENUITEMs let the user toggle this row's cell #1 .DBF value. I then programmatically update the cell's screen display. So far so good.
The problem: This row's
DynamicBackColor does
not then dynamically update. It does NOT change until I exit and re-load the form.
QUESTIONS:
1) Is there an issue with my codeblock?
(Coming from Visual FoxPro codeblocks are brand new to me).
2) Is there some creative programmatic way to
force the row's DynamicBackColor?
3) Could there be a "bug" in DynamicBackColor for a BROWSE control that is not documented in
"C:\HMG.3.4.4\DOC\Data\Browse.htm"?
I am out of ideas. I would really appreciate any suggestions and guidance.
Thank you,
Red2
Re: "DynamicBackColor" within a BROWSE
Posted: Tue Jul 07, 2020 1:46 pm
by Red2
One important point. To prevent annoying BROWSE
"flickering" I update the ROW's changed CELL value with the following.
Code: Select all
procedure RefreshBrowseLine( cForm, cBrowse, p_cUpDtCol )
local i
local nRow
local xValue
local aStruct // array of FIELD names
p_cUpDtCol := iif( p_cUpDtCol == NIL, NIL, upper( p_cUpDtCol ) )
h := GetControlHandle ( cBrowse, cForm )
nRow := ListView_GetFirstItem ( h ) // Returns the BROWSE's current row number
aStruct := DBStruct()
for i := 1 to len( aStruct ) // The number of fields in this record
if ( p_cUpDtCol != Nil ) .AND. ( ! ( p_cUpDtCol == aStruct[ i,1 ] ) )
loop // If not NIL then only field p_cUpDtCol
endif
xValue := &( aStruct[ i,1 ] )
if ( valtype( xValue ) == "N" )
xValue := hb_ntos( xValue )
endif
SetProperty( cForm, cBrowse, "CELL", nRow, i, xValue )
NEXT i
RETURN
The following code, instead, will update the row's DynamicBackColor but it causes the "flickering".
Code: Select all
DoMethod( "DataBrowse", "BrowseStates", "Refresh" ) // Filckers
Neither is optimal. Is there a any solution to both issues?
Thanks,
Red2
Re: "DynamicBackColor" within a BROWSE
Posted: Tue Jul 07, 2020 7:03 pm
by dragancesu
Can you send program and demo data? or a glass ball?
Re: "DynamicBackColor" within a BROWSE
Posted: Wed Jul 08, 2020 12:58 am
by salamandra
Re: "DynamicBackColor" within a BROWSE
Posted: Wed Jul 08, 2020 1:55 am
by salamandra
Hi @Red2,
Red2 wrote: ↑Tue Jul 07, 2020 1:46 pm
One important point. To prevent annoying BROWSE
"flickering" I update the ROW's changed CELL value with the following.
Code: Select all
procedure RefreshBrowseLine( cForm, cBrowse, p_cUpDtCol )
local i
local nRow
local xValue
local aStruct // array of FIELD names
p_cUpDtCol := iif( p_cUpDtCol == NIL, NIL, upper( p_cUpDtCol ) )
h := GetControlHandle ( cBrowse, cForm )
nRow := ListView_GetFirstItem ( h ) // Returns the BROWSE's current row number
aStruct := DBStruct()
for i := 1 to len( aStruct ) // The number of fields in this record
if ( p_cUpDtCol != Nil ) .AND. ( ! ( p_cUpDtCol == aStruct[ i,1 ] ) )
loop // If not NIL then only field p_cUpDtCol
endif
xValue := &( aStruct[ i,1 ] )
if ( valtype( xValue ) == "N" )
xValue := hb_ntos( xValue )
endif
SetProperty( cForm, cBrowse, "CELL", nRow, i, xValue )
NEXT i
RETURN
The following code, instead, will update the row's DynamicBackColor but it causes the "flickering".
Code: Select all
DoMethod( "DataBrowse", "BrowseStates", "Refresh" ) // Filckers
Neither is optimal. Is there a any solution to both issues?
Thanks,
Red2
DynamicBackColor & DynamicForeColor properties are just updated when browse control "changes", this means that you need apply a "Refresh" to the Browse control.
I´ve made a small modification to the MouseRightClick sample. Please take a look. Hope it helps you.
Best regards,
Salamandra, Brazil
Re: "DynamicBackColor" within a BROWSE
Posted: Wed Jul 08, 2020 5:40 am
by AUGE_OHR
hi,
salamandra wrote: ↑Wed Jul 08, 2020 1:55 am
DynamicBackColor & DynamicForeColor properties are just updated when browse control "changes"
i wonder if we can "simulate ON CHANGE" ...
Code: Select all
_HMG_SYSDATA [ 12 ] [k] := change
we have a Codeblock so this might work
Re: "DynamicBackColor" within a BROWSE
Posted: Wed Jul 08, 2020 7:16 am
by edk
AUGE_OHR wrote: ↑Wed Jul 08, 2020 5:40 am
hi,
salamandra wrote: ↑Wed Jul 08, 2020 1:55 am
DynamicBackColor & DynamicForeColor properties are just updated when browse control "changes"
i wonder if we can "simulate ON CHANGE" ...
Code: Select all
_HMG_SYSDATA [ 12 ] [k] := change
we have a Codeblock so this might work
At one time I needed to set control events in runtime and be able to trigger an event. I don't remember exactly where I found the tips in the forum, but my function is given below. It does not support all types of controls and events, I did for the specific needs of my project, but maybe for someone will be useful. I don't know if it will work with Browse, but from what I saw in the sources for the "OnChange" event it should be OK.
Code: Select all
//to set event in runtime
SetAndDoEvent( "WinDeklaracja", "P_59", "OnChange", { || Spr_dekl(59)} )
//to run event in runtime
SetAndDoEvent( "WinDeklaracja", "P_59", "OnChange", , .T. )
//to set and run event in runtime
SetAndDoEvent( "WinDeklaracja", "P_59", "OnChange", { || Spr_dekl(59)}, .T. )
********************************************************************************************
Function SetAndDoEvent( cWindow, cControl, cEventName, bNewProc, lDoEvent )
LOCAL nIndex:=GetControlIndex( cControl, cWindow )
LOCAL nEvent:= 0
Default lDoEvent := .F.
IF !hb_IsLogical ( lDoEvent )
lDoEvent := .F.
ENDIF
IF nIndex =0
RETURN Nil
ENDIF
DO CASE
CASE Upper(cEventName) = "ONCHANGE"
nEvent := 12
CASE Upper(cEventName) = "ONLOSTFOCUS"
nEvent := 10
CASE Upper(cEventName) = "ONGOTFOCUS"
nEvent := 11
CASE Upper(cEventName) = "ONENTER" .AND. ( _HMG_SYSDATA [ 1 ][ nIndex ] == "NUMTEXT" .OR. _HMG_SYSDATA [ 1 ][ nIndex ] == "TEXT") //textbox
nEvent := 16
CASE Upper(cEventName) = "ONENTER" .OR. Upper(cEventName) = "ACTION" .OR. Upper(cEventName) = "ONDISPLAYCHANGE" //other controls
nEvent := 6
ENDCASE
IF nEvent > 0
IF bNewProc <> Nil .AND. hb_IsBlock ( bNewProc )
_HMG_SYSDATA [ nEvent ][nIndex] := bNewProc //set new event procedure
ENDIF
IF lDoEvent
_DoControlEventProcedure( _HMG_SYSDATA [ nEvent ][nIndex], nIndex ) //do event procedure
ENDIF
ENDIF
Return Nil
Re: "DynamicBackColor" within a BROWSE
Posted: Wed Jul 08, 2020 6:32 pm
by Red2
Hello Again,
Salamandra, thank you for your
Tue Jul 07, 2020 9:55 pm reply.
DynamicBackColor & DynamicForeColor properties are just updated when browse control "changes", this means that you need apply a "Refresh" to the Browse control.
You are accurate. In the BROWSE when my RightClick (via my CONTROL CONTEXT MENU action)
both:
1) Changes the record value of
By_States->MergeState (the BROWSR's current ROW's cell field)
and also
2) Updates the on screen BROWSE ROW's CELL's display value
Nevertheless, HMG's BROWSE is simply
not detecting the change.
You also mentioned a modification that I do not find but would like to see.
I´ve made a small modification to the MouseRightClick sample. Please take a look. Hope it helps you.
Jimmy and edk,
Thank you. It will take me time to dig into your code and see if I can simulate a "change" to the BROWSE's ROW.
dragancesu,
Thank you. I am still trying to make a simple demonstration.
More suggestions are always welcome!
Thanks again to everyone!
Red2