Hi,
for me the TAB key is ok, but as Antonio already stated...
Here is a sample:
- Code: Select all Expand view
#include "FiveWin.ch"
FUNCTION Main()
LOCAL oWnd
USE Customer
DEFINE WINDOW oWnd TITLE "Test" MDI
ACTIVATE WINDOW oWnd ON INIT BuildChild()
RETURN nil
FUNCTION BuildChild()
LOCAL oChild
DEFINE WINDOW oChild TITLE "A Child Window" MDICHILD COLOR 0
ACTIVATE WINDOW oChild ON INIT BuildDialog( oChild ) VALID ( .T. )
RETURN nil
FUNCTION BuildDialog( oChild )
LOCAL oDlg
LOCAL oGroup
LOCAL oBrw
LOCAL oGet
LOCAL oGet2
LOCAL nID
LOCAL cNotes
LOCAL oText
LOCAL oBtn
LOCAL lExit := .F.
LOCAL cAlias := "CUSTOMER"
SetDlgGradient( { { 1, RGB( 199, 150, 237 ), RGB( 237, 242, 248 ) } } )
DEFINE DIALOG oDlg FROM 50, 50 TO 600, 1400 TITLE "A Dialog Box" PIXEL
//@ 1, 5 GROUP oGroup TO 250, 250 PROMPT "This is a GROUP for some dialog elements:" OF oDlg PIXEL TRANSPARENT
@ 1, 2 CHECKBOX lExit PROMPT "This is a first CHECKBOX with a long text description" OF oDlg COLOR CLR_BLUE, CLR_BLACK
@ 2, 2 CHECKBOX lExit PROMPT "This is a second CHECKBOX with a long text description" OF oDlg
@ 4, 2 SAY "First:" OF oDlg
@ 4, 10 GET oGet VAR ( cAlias )->FIRST OF oDlg
@ 5, 2 SAY "Last:" OF oDlg
@ 5, 10 GET oGet VAR ( cAlias )->LAST OF oDlg
@ 7, 2 SAY oText PROMPT "Street: " + ( cAlias )->STREET OF oDlg COLOR CLR_BLACK, CLR_WHITE
oText:bGet := { || "Street: " + ( cAlias )->STREET }
@ 8, 2 SAY oText PROMPT "City: " + ( cAlias )->CITY OF oDlg COLOR CLR_BLACK, CLR_WHITE
oText:bGet := { || "City: " + ( cAlias )->CITY }
// GET field with memory variable
@ 10, 2 SAY "Notes:" OF oDlg
cNotes := ( cAlias )->NOTES
@ 13, 0 GET oGet2 VAR cNotes OF oDlg
//oGet2:bSetGet := { || ( cAlias )->NOTES }
nID := oGet2:nID
oBrw := TXBrowse():New( oDlg )
oBrw:CreateFromCode()
oBrw:nTop := 3
oBrw:nLeft := 255
oBrw:nBottom := 250
oBrw:nRight := 600
oBrw:cAlias := cAlias
oBrw:bChange := { || Refresh_Dialog( oChild, nID ) }
oBrw:SetRDD()
@ 12, 2 BUTTON "&Ok" OF oDlg SIZE 40, 12 ACTION( Save_Changes( oChild ) ) DEFAULT
@ 12, 10 BUTTON oBtn PROMPT "&Cancel" OF oDlg SIZE 40, 12 ACTION( oChild:End() )
@ 12, 18 BUTTON "&Back" OF oDlg SIZE 40, 12 ACTION( ( cAlias )->( DbSkip( - 1 ) ), Refresh_Dialog( oChild, nID ) )
@ 12, 26 BUTTON "&Next" OF oDlg SIZE 40, 12 ACTION( ( cAlias )->( DbSkip( 1 ) ), Refresh_Dialog( oChild, nID ) )
ACTIVATE DIALOG oDlg NOWAIT ON INIT ChangeParent( oDlg, oChild )
//ACTIVATE DIALOG oDlg
oDlg:End()
RETURN NIL
FUNCTION ChangeParent( oDlg, oChild )
LOCAL i
FOR i := 1 TO Len( oDlg:aControls )
SetParent( oDlg:aControls[ n ] :hWnd, oChild:hWnd )
AAdd( oChild:aControls, oDlg:aControls[ n ] )
oDlg:aControls[ n ] :oWnd := oChild
NEXT
RETURN NIL
FUNCTION Refresh_Dialog( oChild, nID )
LOCAL i
LOCAL nLength
nLength := Len( oChild:aControls )
FOR i := 1 TO nLength
oChild:aControls[ i ] :Refresh()
IF oChild:aControls[ i ] :nID == nID
oChild:aControls[ i ] :cCaption := CUSTOMER->NOTES
ENDIF
NEXT
RETURN NIL
FUNCTION Save_Changes( oChild )
// Save
MsgInfo( "Here is the 'Ok'-Button'" )
RETURN NIL
And here are the notes/differences I've found:
- The SetDlgGradient() call is ignored
- The check boxes overwrites the browse
- RETURN key doesn't executes the DEFAULT button
- (Solved???, see:
viewtopic.php?f=3&t=22940) Tranparences are not functional, e. g. see the effect of
- Code: Select all Expand view
@ 1, 5 GROUP oGroup TO 250, 250 PROMPT "This is a GROUP for some dialog elements:" OF oDlg PIXEL TRANSPARENT
BTW: I want to update/save some fields, if the user click the 'Ok'-button, so I can't refer directly to the table fields like STREET and CITY! Therefor, I have defined a temporary variable <cNotes> for the NOTES field, but I don't know how to refresh this element. My first try with <nID> and setting <cCaption> isn't functional
What's wrong resp. best practice to do this job?