FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Resize xbrowse
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Resize xbrowse
Posted: Wed Jan 21, 2009 08:34 AM

How can I bind the width of a xBrowse to the windows width that the xBrowse gets automatically resized if I resize the window.
Thanks in advance
Otto

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Resize xbrowse
Posted: Wed Jan 21, 2009 08:49 AM

Otto,

did you try oChildWnd:SetControl(oBrw) for MDI or oWnd:oClient := oBrw for normal windows ?

kind regards

Stefan
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Resize xbrowse
Posted: Wed Jan 21, 2009 09:34 AM

Thank you Stefan. I tried your suggestion. But this resizes also the height.
I need a fixed height and only the width resised.
Best regards,
Otto

Posts: 284
Joined: Mon Oct 24, 2005 08:04 PM
Re: Resize xbrowse
Posted: Wed Jan 21, 2009 02:33 PM
Otto,

You could try something like this:

oDlg:bResized := {|| oBrw:move( oBrw:nTop, oBrw:nLeft, oDlg:nWidth-oBrw:nLeft-10, oDlg:nHeight-80)

Randal


Otto wrote:How can I bind the width of a xBrowse to the windows width that the xBrowse gets automatically resized if I resize the window.
Thanks in advance
Otto
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Resize xbrowse
Posted: Wed Jan 21, 2009 02:41 PM
otto please check this sample

#include "FiveWin.ch"
#include "xbrowse.ch"

#define SM_CYVSCROLL      20
#define SM_CXHSCROLL      21
#define SM_CXSCREEN      	0
#define SM_CYSCREEN      	1
#define SM_CYCAPTION      4 

function main()

local oWnd, oBrw
local aArray := {}
local aColWidth := array( 13 ) // 13 columns
local nI, nWd, nHt, nFactor

for nI = 1 to 20
aadd( aArray, { StrZero(nI,2),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ),;
								SPACE( 5 ) } )
next

nWd      := GetSysMetrics(SM_CXSCREEN) * .5
nHt      := GetSysMetrics(SM_CYSCREEN) * .3	

		
DEFINE WINDOW oWnd Title "Test Resized xBrowse " from 50,0 to nHt, nWd PIXEL


oBrw:= txbrowse():new( oWnd )
oBrw:nRowHeight := 25
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLCELL 
oBrw:SetArray( aArray )
oBrw:CreateFromCode()
oBrw:lRecordSelector := .t.
oBrw:lVScroll := .t.
oBrw:nWidth := oWnd:nWidth - if( oBrw:lVScroll, GetSysMetrics(SM_CYVSCROLL), 0 )
oBrw:nHeight := oWnd:nHeight - GetSysMetrics(SM_CYCAPTION) - if( oBrw:lVScroll, GetSysMetrics( SM_CYVSCROLL ),0)

nFactor := ( ( if( oBrw:lRecordSelector,55,30) + ;
               if( oBrw:lVScroll, GetSysMetrics( SM_CYVSCROLL ),15) ) / oWnd:nWidth ) / len( aColWidth )


aColWidth[ 1 ]:= 0.1 
oBrw:aCols[ 1 ]:nWidth := oBrw:nWidth  * ( aColWidth[ 1 ] - nFactor )

for nI = 2 to len( oBrw:aCols )
	aColWidth[ nI ] := 0.9 / ( len( aColWidth ) - 1 )
	oBrw:aCols[ nI ]:nWidth := oBrw:nWidth * ( aColWidth[ nI ] - nFactor )
next


oWnd:bResized := {||  nFactor := ( ( if( oBrw:lRecordSelector,55,30) + ;
               				if( oBrw:lVScroll, GetSysMetrics( SM_CYVSCROLL ),15) ) / oWnd:nWidth ) / len( aColWidth ) ,;
										  oBrw:nWidth := oWnd:nWidth - if( oBrw:lVScroll, GetSysMetrics(SM_CYVSCROLL), 0 ) ,;
   										aeval( oBrw:aCols, {| o,nI | o:nWidth := oBrw:nWidth * ( aColWidth[ nI ] - nFactor ) } ),;
   										oBrw:Refresh() }	

ACTIVATE WINDOW oWnd 

return nil
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
Re: Resize xbrowse
Posted: Wed Jan 21, 2009 03:07 PM

Super, how resize xbrowse in Vertical

best regards

kajot
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Resize xbrowse
Posted: Wed Jan 21, 2009 03:40 PM
hello Kajot

only include into codeblock Resized
oBrw:nHeight := oWnd:nHeight - GetSysMetrics(SM_CYCAPTION) - if( oBrw:lVScroll, GetSysMetrics( SM_CYVSCROLL ),0)

like that...
oWnd:bResized := {||  nFactor := ( ( if( oBrw:lRecordSelector,55,30) + ;
if( oBrw:lVScroll, GetSysMetrics( SM_CYVSCROLL ),15) ) / oWnd:nWidth ) / len( aColWidth ) ,;
oBrw:nWidth := oWnd:nWidth - if( oBrw:lVScroll, GetSysMetrics(SM_CYVSCROLL), 0 ) ,;
oBrw:nHeight := oWnd:nHeight - GetSysMetrics(SM_CYCAPTION) - if( oBrw:lVScroll, GetSysMetrics( SM_CYVSCROLL ),0),;
aeval( oBrw:aCols, {| o,nI | o:nWidth := oBrw:nWidth * ( aColWidth[ nI ] - nFactor ) } ),;
oBrw:Refresh() }
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Resize xbrowse
Posted: Wed Jan 21, 2009 04:09 PM

Hello Randal,
for the case I asked your solution works perfectly. Thank you.

Hello Daniel,
For my future xBrowse implementations I will use your code as a standard feature. Thanks very much for this sample.

Best regards,
Otto

Continue the discussion