Hi,

here I am with a slightly different version of the BruceR's function to avoid 
the undesired zooming when scrolling left at the left edge and to let to show 
the blank bars on left edge in the main window:

thanks BruceR

Bisto

function ZoomSync( force )
{
    //  All variables are made local to guarantee naming collisions or side 
effects
    local bv, dr, Curstdt, Curenddt, prevstdt, prevenddt, Curststr, Curendstr;
    local OAB, OAD, dcount, i, OADoc, OAW, OADocWin, res;
    //  Get a count of the number of documents
    OAB = CreateObject( "Broker.Application" );
    OAD = OAB.Documents;
    dcount = OAD.Count;
    //  Process multiple windows (documents)
    res = False;

    if ( dcount > 1 )
    {
        //  Get current and last start and end DateTimes's
        LastBarIndex = Status( "LastVisibleBarIndex" );
        FirstBarIndex = Status( "FirstVisibleBarIndex" );
        Nblankbar = Status( "LastVisibleBarIndex" ) - BarCount;
        prevLastBarIndex = Nz( StaticVarGet( "_prevLastVisibleBarIndex" ) );
        prevFirstBarIndex = Nz( StaticVarGet( "_prevFirstVisibleBarIndex" ) );
        //  Check for a new date/time range

        if ( ( LastBarIndex != prevLastBarIndex OR FirstBarIndex != 
prevFirstBarIndex ) OR force )
        {
            //  Set the new last values
            StaticVarSet( "_prevLastVisibleBarIndex", Status( 
"LastVisibleBarIndex" ) );
            StaticVarSet( "_prevFirstVisibleBarIndex", Status( 
"FirstVisibleBarIndex" ) );
            DT = DateTime();
            BI = BarIndex();
            LastDateTime =  LastValue( ValueWhen( LastBarIndex  == BI, DT ) );
            FirstDateTime = LastValue( ValueWhen( FirstBarIndex == BI, DT ) );
            LastDateTimestr = DateTimeToStr( LastDateTime );
            FirstDateTimestr = DateTimeToStr( FirstDateTime );
            //  Loop through the document collection

            for ( i = 0; i < dcount; i++ )
            {
                //  If it is not the active document -
                OADoc = OAD.Item( i );
                //  NOTE - it doesn't hurt to sync the current window and it 
makes all
                //         windows have no blank bars on the right so they look 
the same
                //if ( OADoc != OAB.ActiveDocument )
                {
                    //  Get the document window and zoom to range
                    //_TRACE( "  Zoom to range document - " + i + " , " +   
Curststr + " - " + Curendstr );
                    OADW = OADoc.Windows;
                    //  Document window count assumed to be 1
                    OADocWin = OADW.Item( 0 );
                    OADocWin.ZoomToRange( FirstDateTimestr, LastDateTimestr  );
                }
            }

            res = True;
        }
    }

    return res;
}


UseZoomer = ParamToggle("Use Zoomer?", "No|Yes", 0);

if (UseZoomer)
    ZoomSync( False );


Reply via email to