Change color of a DCTABPAGE that has focus
Posted: Fri Aug 04, 2017 2:23 pm
What is the best way to change the color of the DCTABPAGE that has focus?
Donnay Software Web Forums
http://donnay-software.com/DONNAY/
Code: Select all
#INCLUDE "dcdialog.CH"
FUNCTION Main()
LOCAL GetList[0], oTab1, oTab2, oTab3, oBrowse1, oBrowse2, oBrowse3, ;
aDir := Directory(), i, oDlg
@ 0,0 DCTABPAGE oTab1 CAPTION 'Tab 1' SIZE 100, 20 ;
GOTFOCUS {|a,b,o|TabPageFocus(o,oDlg)}
@ 2,2 DCBROWSE oBrowse1 DATA aDir SIZE 96,17 PARENT oTab1
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) PARENT oBrowse1
NEXT
@ 0,0 DCTABPAGE oTab2 RELATIVE oTab1 CAPTION 'Tab 2' ;
GOTFOCUS {|a,b,o|TabPageFocus(o,oDlg)}
@ 2,2 DCBROWSE oBrowse2 DATA aDir SIZE 96,17 PARENT oTab2
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) PARENT oBrowse2
NEXT
@ 0,0 DCTABPAGE oTab3 RELATIVE oTab2 CAPTION 'Tab 3' ;
GOTFOCUS {|a,b,o|TabPageFocus(o,oDlg)}
@ 2,2 DCBROWSE oBrowse3 DATA aDir SIZE 96,17 PARENT oTab3
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) PARENT oBrowse3
NEXT
DCREAD GUI FIT TITLE 'Tab Colors' ;
EVAL {|o|oDlg := o, TabPageFocus(oTab1,o)}
RETURN nil
* ----------
PROC appsys ; RETURN
* ----------
STATIC FUNCTION TabPageFocus(oTabPage,oDlg)
LOCAL i, aChildList
aChildList := oDlg:drawingArea:childList()
FOR i := 1 TO Len(aChildList)
IF aChildList[i]:isDerivedFrom('DC_XbpTabPage')
IF aChildList[i] == oTabPage
oTabPage:setColorBG(GRA_CLR_CYAN)
ELSE
aChildList[i]:setColorBG(GRA_CLR_PALEGRAY)
ENDIF
ENDIF
NEXT
RETURN nil
That's probably a good idea.Perhaps a DCTABPAGE FOCUSCOLOR in the future?
Code: Select all
FUNCTION Main()
LOCAL GetList[0], oTab1, oTab2, oTab3, oBrowse1, oBrowse2, oBrowse3, ;
aDir := Directory(), i, oDlg, aTabOptions
aTabOptions := { ;
GRA_CLR_DARKRED, ;
GraMakeRGBColor({200,200,150}), ;
GRA_CLR_BLACK, ;
GraMakeRGBColor({200,150,200}), ;
'11.Arial Bold', ;
'10.Arial' }
DC_TabPageOptions(aTabOptions)
@ 0,0 DCTABPAGE oTab1 CAPTION 'Tab 1' SIZE 100, 20 ;
@ 2,2 DCBROWSE oBrowse1 DATA aDir SIZE 96,17 PARENT oTab1 USEVISUALSTYLE ;
CURSORMODE XBPBRW_CURSOR_ROW ;
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER 'Column ' + Alltrim(Str(i)) PARENT oBrowse1 ;
HFONT '10.Lucida Console Bold' WIDTH 10
NEXT
@ 0,0 DCTABPAGE oTab2 RELATIVE oTab1 CAPTION 'Tab 2' ;
@ 2,2 DCBROWSE oBrowse2 DATA aDir SIZE 96,17 PARENT oTab2 USEVISUALSTYLE
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) PARENT oBrowse2
NEXT
@ 0,0 DCTABPAGE oTab3 RELATIVE oTab2 CAPTION 'Tab 3' ;
@ 2,2 DCBROWSE oBrowse3 DATA aDir SIZE 96,17 PARENT oTab3 USEVISUALSTYLE
FOR i := 1 TO 10
DCBROWSECOL ELEMENT i HEADER Alltrim(Str(i)) PARENT oBrowse3
NEXT
DCREAD GUI FIT TITLE 'Tab Option Test' ;
EVAL {|o|DC_TabActivate(oTab1)}
RETURN nil
* ----------
PROC appsys ; RETURN