Page 4 of 5

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 1:21 am
by James Bott
Rao,

TXBrows():new(oWnd) // not TXBrow()

It is easier to change "TXBrowse(" to "TXBrows(" in one stroke in all sources with a single operation with any program editor. Anyway we are changing to what FWH recommends.

Changing xbrowse.ch does not help. It calls functions. FWH library never internally uses TXBrowse():new() to construct xbrowse. Even internally it calls only TXBrows():New()


Can you tell me where the source code is for the TXBrows class, or is just preprocessed to something else. I cannot find it in my source using a global search utility.

I was unware that TXBrowse():New() was being preprocessed into a function call. This does explain a lot, but does defeat the normal way of subclassing a class.

Regards,
James

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 1:48 am
by James Bott
Rao,

Here is an important point. If one is creating a xbrowse using OOP syntax like this:

oBrw:= TXBrowse():New( oWnd, nRow, nCol, ...)

It cannot be just changed to:

oBrw:= TXBrows():New( oWnd, nRow, nCol, ...)

Since TXBrows():new() only accepts one parameter, oWnd. Converting would requite a lot of hand recoding of every browse.

oBrw:= TXBrows():New( oWnd )
oBrw:nRow:= 10
oBrw:nCol:= 10
...

This prevents someone like UKService from easily converting his code via search and replace. This also explains why you were saying that using OOP syntax would create a larger OBJ.

I am reserving my opinion at this point, but I don't see what the advantage is to preprocessing OOP syntax into calling a function. This seems to create lots of problems.

Regards,
James

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 4:19 am
by nageswaragunupudi
oBrw:= TXBrowse():New( oWnd, nRow, nCol, ...)
This is not correct.
TXBrowse():New( oWnd ) also accepts only one parameter. It does NOT accept any other paramters

TXBrows():New( oWnd ) is equivalent to TXBrowse():new( oWnd ) normally

After executing SetXBrowse( { || MyBrowse() } ,

TXBrows():New( oWnd ) is equivalent to MyBrowse():New( oWnd )

This provides a mechanism to use our subclass with only one stantement at the beginning without changing any other sourcecode.

Please try and see it yourself. It works. I was designed to work.

Extract from whatsnew.txt in July 2009
a) Inherited classes from XBrowse:
It may be necessary to have a modified behaviour of xbrowse for a specific browse or an application.
In such cases it is desirable to create one or mroe child classes derived from TXBrowse and use them.
It is now very easy to implement this globally or for specific browses.

[bPrev := ] SetXBrowse( { || ChildBrowse() } ). After this all xbrowse commands create and use this
child class.
command equivalent is :
SET XBRROWSE TO ChildBrowse() [ SAVE PREVIOUS TO bPrevXbr ]

To use child class for a speicific browse :
@ r, c, XBROWSE oBrw CLASS ChildBrowse() OF ownd .... can be used.
It is possible to use different child classes or standard FWH txbrowse for different browses displayed at
the same time.

If browse is created in Oops syntax, TXBrows():New(oWnd) may be used instead of TXBrowse():New( oWnd ).

Sample:
xbrchild.prg demonstrates use of child browses and switching between child and parent classes as well as provides a template for creation of child xbrowse class.

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 10:00 am
by ukservice
Mr. Rao,

This is the way I define xBrowses:

// Browse---------------------------------------------------------------
oVMenuBrowse := TXBrowse():New( oDlg )

aBrowse := { { { || TYPE->NAME }, "Name", 5200, 0 } }



FOR i := 1 TO Len(aBrowse)
oCol := oVMenuBrowse:AddCol()
oCol:bStrData := aBrowse[ i, 1 ]
oCol:cHeader := aBrowse[ i, 2 ]
oCol:nWidth := aBrowse[ i, 3 ]
NEXT



oVMenuBrowse:nMarqueeStyle := MARQSTYLE_HIGHLROW //
oVMenuBrowse:nColDividerStyle := LINESTYLE_BLACK
oVMenuBrowse:lColDividerComplete := .T.
oVMenuBrowse:nHeaderLines := 1.5


oVMenuBrowse:nTop:=00
oVMenuBrowse:nLeft:=72
oVMenuBrowse:nRight:= (oDlg:nWidth()-10)/2 //nWidth=150
oVMenuBrowse:nBottom:= (oDlg:nHeight()-21)/2 //nHeight=200


oVMenuBrowse:blDblClick := { || (ActionBrowse( "AddType", cSelect, oDlg, oVMenuBrowse ) ) }
oVMenuBrowse:CreateFromCode()
oDlg:oClient := oVMenuBrowse


Is not correct?. Thank you.

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 3:57 pm
by James Bott
Rao,

TXBrowse():New( oWnd ) also accepts only one parameter.


I see. I was assuming it worked like the other browses.

I still have been unable to find the source for TBrows():New(). Do you know where it is?

Regards,
James

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 4:26 pm
by nageswaragunupudi
Mr James,
I still have been unable to find the source for TBrows():New(). Do you know where it is?


There is no TXBrows class as such. TXBrows() is a function which returns the class object TXBrowse() by default. If we set a different browse class with the statement SetXBrowse( { || MyBrowse() } then it returns the class object MyBrowse().

When we write the code:
TXBrowse():New()
Message new is sent to the class object returned by the function TXBrowse(). TXBrowse() always returns the class object defined in the native class TXBowse.

We can also write:
oClass := TXBrowse()
and then
oClass:New( oWnd )
This is the same as TXBrowse():New( oWnd )

When we write TXBrows():New( oWnd ), the message "New" is sent to the class object returned by TXBrows(). By default this is TXBrowse() class object which we can change by the function call SetXBrowse( { || NewClass() } ).

This is how FWH implemented the capability to use any derived class easily in our application without changing any of the library code or the preprocessor commands.

While this is the explanation of how FWH enabled the ease of using derived classes, normal programmer is not concerned with all these intricate logic. One can safely use the derived classes by one single statement. The very idea of xbrowse is to make complex tasks easy.

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 4:48 pm
by nageswaragunupudi
Mr. Ukservice

I can not say the code is "not correct". It "normally" works okay.

#1. If your intention is the change your code only for Win7 bars, my personal advice is to wait for next releases of FWH for their own implementation. You may not have to change any code.

#2. If you are interested in general advice about any better practices of coding for xbrowse, here are a few advices:

a) It is desirable if you change all "TXBrowse():" as "TXBrows(". You can do it with many program editors in all programs at once and then rebuild your application. This change is perfectly safe and does not disturb any of your browses. The advanatage, however, is that you can use any derived classes at fly in future with only one statement. I recommend this change.

b) Important: I did not see that you set the datasource by SetRDD(). I see you are using DBFs. It is always a good practice to set the source alias, by
Code: Select all  Expand view
oBrw:cAlias := "your alias"
oBrw:SetRDD()

IMMEDIATELY after creating the browse object.
it is true that even if you do not do this, the very tolerant xbrowse tries to use the default alias just before displaying the browse.
But this is a dangerous practice with many possible sideeffects and some functionality of xbrowse may even give runtime errors.
You may have seen many example postings like this, but *please*, for the sake of stability of your own software, take my advice seriously.

c) Important: FWH deprecates the use of bStrData. This was the only way available years back. Instead assign the codeblock to bEditValue and provide picture clause, if any, to cEditPicture.

I still keep advising to use of command style. I know for sure it has lots of advantages and will ultimately make your life easier. Fewer bugs, easier maintenance and more power.


Many other improvements are possible, but we keep discussing them in due course.

Re: XBrowse Win7 Bar New Sample

PostPosted: Thu Jan 06, 2011 5:00 pm
by James Bott
Rao,

When we write TXBrows():New( oWnd ), the message "New" is sent to the class object returned by TXBrows().


I should have thought of that. Thanks for the detailed explanation.

Regards,
James

Re: XBrowse Win7 Bar New Sample

PostPosted: Mon Feb 14, 2011 10:30 pm
by Silvio
Mr Rao,
When I use your TXbrWin7


@ 30, 10 XBROWSE oLbx OF oDlg ;
SIZE 120,85 PIXEL CLASS TXbrWin7()

oLbx:SetArray(aArray)
Ut_BrwRowConfig7( oLbx )


FUNCTION Ut_BrwRowConfig7( oBrw )

oBrw:lRecordSelector := .t. // .t.
oBrw:lAllowRowSizing := .t.
oBrw:lColDividerComplete := .t. // .f.
oBrw:lAllowColSwapping := .t.
oBrw:lAllowColHiding := .t.
oBrw:lFastEdit := .f.

oBrw:nRowSel := 1
oBrw:nColSel := 1
oBrw:nColOffset := 1
oBrw:nFreeze := 0
oBrw:nCaptured := 0
oBrw:nLastEditCol := 0

oBrw:nRowDividerStyle := LINESTYLE_NOLINES
oBrw:nColDividerStyle :=LINESTYLE_BLACK // LINESTYLE_NOLINES
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLWIN7 // for Windows 7 style

RETURN nil




I can see the xbrowse white , I cannot see the LINEs VERTICAL (oBrw:nColDividerStyle :=LINESTYLE_BLACK ) it is a bug ?

Re: XBrowse Win7 Bar New Sample

PostPosted: Mon Feb 14, 2011 11:24 pm
by nageswaragunupudi
Mr. Silvio

In the TXbrWin7 class source code, I have purposefully set row divider and column divider styles to 0 in the adjust method. This overrides your settings.
If you want comment out the line in the Adjust method which resets column linestyle to zero. Then your setting will work.

Re: XBrowse Win7 Bar New Sample

PostPosted: Tue Feb 15, 2011 12:29 am
by amnunez
Dear All,

"Error in creating dialog". I tried to use the class using resource and that error appeared. Does anyone has a sample using resource. please post it. BTW, here's my resource declaration:

DLG_MAIN DIALOGEX -2,-16,387,255
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_MODALFRAME
BEGIN
CONTROL "",1001,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_CENTER,3,4,92,18,WS_EX_CLIENTEDGE
CONTROL "Load DBF",1002,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,96,4,50,18
CONTROL "",1003,"TXBROWSE",WS_CHILDWINDOW|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL,7,30,370,194
CONTROL "CLOSE",1004,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,310,233,67,18
CONTROL "EXPORT TO XLS",1005,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,243,233,67,18
END



Please correct or advice me if i missed something... thanks for the help...


regards,
apollo

Re: XBrowse Win7 Bar New Sample

PostPosted: Tue Feb 15, 2011 2:22 am
by James Bott
Apollo,

Make a backup of the resource file. Then use a copy and remove the controls one by one until you find which one is the problem. I suspect it is the first one.

James

Re: XBrowse Win7 Bar New Sample

PostPosted: Tue Feb 15, 2011 2:31 am
by nageswaragunupudi
replace txbrowse with this class name in t nh e resource file

Re: XBrowse Win7 Bar New Sample

PostPosted: Tue Feb 15, 2011 2:57 am
by amnunez
Dear Sir James and Sir RAO,

Sir James, i tried it already and whenever i removed the "CLASS TXbrWin7()" from xbrowse declaration, it works fine...

Sir RAO, what was the name of classname again that i should replace "TXBROWSE"?

thank you both for the help...


regards,
apollo

Re: XBrowse Win7 Bar New Sample

PostPosted: Tue Feb 15, 2011 5:49 am
by nageswaragunupudi
if you are hi using txbrwwin7 class in the program you should write "TXBrwWin7" in the resource file also instead of"TXBrowse".