Problem with xBrowse in MDI-Childs

Problem with xBrowse in MDI-Childs

Postby ukoenig » Tue Jan 29, 2008 8:20 pm

I wanted to change a Browse from Dialog to a MDI-Child
Following happens :

//------------ Quick- Browse Outlook2003 ---------------------------

FUNCTION PROG_4(oWnd,oDlg,aCtrl,nPage,oOutL2003)
local oDlg3, oFile1, cFile1 := "", oBtn1, oBtn2, obtn3, oBtn4, oBrw5, DBFTYP := ""
local oFilter, cFilter := SPACE( 70 ), cFELD := "", l_INDEX := .F.
local oSUCH, cSUCH := "", aSCOPE, nSCOPE := 1
local oEXPORT, cEXPORT := "EXPORT.DBF ", oINDKEY, cINDKEY := ""
local oOemAnsi, cOemAnsi := ""

DEFINE DIALOG aCtrl[nPage] RESOURCE "BROWSER" OF oDlg PIXEL

cFile1 := GET_DBF2() // the selected Database
DBFTYP := CabDbf (cFile1) // DBF-Header-Info CDX or NTX
IF lOemAnsi = .T. // wants to open a Oem or Ansi - Database
cOemAnsi := "ANSI"
ELSE
cOemAnsi := "OEM"
ENDIF

IF DBFTYP = "CDX"
RDDSETDEFAULT( "DBFCDX" )
ELSE
RDDSETDEFAULT( "DBFNTX" )
ENDIF

// -------- Open the Database ---------------------------------

DBSELECTAREA(1)
USE &cFile1
DBGOTOP()

BROWSE() // Database is open and shows the Data

// ------------------------------------------

// Dosn't work in a MDI-Child
// as a ARRAY and in a Dialog it is OK

//-------------------------------------------

oBrw5 := TXBrowse():New( aCtrl[nPage] )
// => aCtrl[nPage] is a MDI-Child of Outlook2003

oBrw5:nMarqueeStyle := MARQSTYLE_HIGHLCELL
oBrw5:nColDividerStyle := LINESTYLE_BLACK
oBrw5:nRowDividerStyle := LINESTYLE_BLACK
oBrw5:lColDividerComplete := .t.
oBrw5:nHeaderLines := 1
oBrw5:nDataLines := 1
oBrw5:lAllowColSwapping := .t.
oBrw5:lOemToAnsi := lOemAnsi // New OemToAnsi
oBrw5:SetRDD()

lClrFlag:=.f.
for nFor := 1 to len( oBrw5:aCols )

// Error-Message
// NO WORKAREA in USE !!!!
// as a ARRAYS it is OK
// ------------------------------------

oCol := oBrw5:aCols[ nFor ]
oBrw5:bSkip:={| nRecs | ( if(nRecs == nil, nRecs := 1,),nRecs:= ;
(1)->(dbskipper( nRecs )), ;
lClrFlag:= if( nRecs % 2 = 0, lClrFlag,!lClrFlag), nRecs) }
// Define alternating row colors
oBrw5:bClrStd:= {|| if(lClrFlag,{ CLR_BLACK, COLOR_LIGHT }, ;
{ CLR_BLACK, COLOR_DARK }) }
oCol:nEditType := 1
oCol:bOnPostEdit := {|o, v, n| IIF( n != VK_ESCAPE, ;
( IIF( Net_Lock(), ;
IIF( lOemAnsi = .T., ;
FieldPut( o:nCreationOrder, AnsiToOem(v) ), ;
FieldPut( o:nCreationOrder, v ) ), Net_ULock () ), NIL ), ) }
next

oBrw5:CreateFromResource( 110 )
aCtrl[nPage]:oClient := oBrw5

ACTIVATE DIALOG aCtrl[nPage] NOWAIT ;
ON INIT ( aCtrl[nPage]:Move( aCORS [1] + 10, aCORS [2] + 230, ;
aCtrl[nPage]:nWidth, aCtrl[nPage]:nHeight, .f. ) )

CLOSE DATABASE

RETURN( NIL )

regards
U. König :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby James Bott » Tue Jan 29, 2008 8:51 pm

A dialog is modal and a MDI window is non-modal. The consequence is that when in a non-modal window you can jump out and do something else which might include changing the current workarea.

When setting up a browse or with any code referencing a database you need to always use alias referencing. In your code you have not told the browse what the alias is, like this:

oBrw:cAlias := cAlias

Or, in your case:

oBrw5:cAlias := "1"

The alias referencing issue is a big reason to use database objects since they have that built-in. You still need to tell the browse the alias, but all navigation commands are automatically alias referenced.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby RenOmaS » Tue Jan 29, 2008 9:12 pm

Code: Select all  Expand view
....
...
If !OpenDataBase() ????  //not open database
    DBSELECTAREA(1)
    USE &cFile1
Endif
   Select( 1 )
EndIf

.......
....
ACTIVATE DIALOG aCtrl[nPage] NOWAIT ;
ON INIT ( aCtrl[nPage]:Move( aCORS [1] + 10, aCORS [2] + 230, ;
aCtrl[nPage]:nWidth, aCtrl[nPage]:nHeight, .f. ) ) ;
VALID ( CloseDatabase(), .T. )


Static Function CloseDataBase()

CLOSE DATABASE

Return Nil


;)
User avatar
RenOmaS
 
Posts: 205
Joined: Fri Oct 07, 2005 5:07 pm

Postby James Bott » Wed Jan 30, 2008 9:42 pm

Code: Select all  Expand view
Static Function CloseDataBase()

CLOSE DATABASE

Return Nil


Better would be:

Code: Select all  Expand view
Static Function CloseDataBase()
   local nArea:= select(1)
   CLOSE DATABASE
   select( nArea )
Return nil


If you were using a database object you could simply do:

...VALID (oCust:end(), .t.)

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 53 guests

cron