Scrolling in a Browse window

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Scrolling in a Browse window

Post by CalScot »

Hi.

I have a Browse window that shows about 35 rows of records, indexed on dDate.

When first loaded, the highlighted pointer row is the top row of the window. When I do a seek or a softseek, the pointer moves to the correct record (and the window refreshes), but then the pointer is always at a row further down the window, and records with earlier dates can be seen above it.

Is there a way to get the found() record to always display at the top row of the window? I have tried all sorts of things, including various combinations of things using Scroll() and Row(), but I haven't been able to find something that works.

Does anyone have any suggestions of things to try, or an example of how they've made this work, or...?

Thanks.
CalScot


Hola.

Tengo una ventana Examinar que muestra unas 35 filas de discos, indizadas en ddate.

Cuando se carga por primera vez, la fila resaltada es puntero de la fila superior de la ventana. Cuando hago una búsqueda o una SoftSeek, el puntero se mueve al registro correcto (y se actualiza la ventana), pero entonces el puntero se encuentra siempre en una fila al final de la ventana, y los registros con fechas anteriores se puede ver por encima de ella.

¿Hay una manera de obtener el registro encontrado () para que se muestre siempre en la fila superior de la ventana? He intentado todo tipo de cosas, incluyendo varias combinaciones de cosas usando Scroll () y ROW (), pero no he sido capaz de encontrar algo que funcione.

¿Alguien tiene alguna sugerencia de cosas para probar, o un ejemplo de cómo se han hecho de este trabajo, o ...?

Gracias.
CalScot
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: Scrolling in a Browse window

Post by dhaine_adp »

Code: Select all


SET BROWSE SYNCH ON
DEFINE WINDOW MainForm;
   .
   .
   .
   @ Row, Col BROWSE myBrowse .......  // @ syntax
END WINDOW

function YourSearchUDF()
.
. Your other codes here
.
    MainForm.myBrowse.Value := YOURALIAS->( RECNO() )
    MainForm.myBrowse.Refresh
    MainForm.myBrowse.Setfocus
    RETURN NIL
Regards,

Danny
Manila, Philippines
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Scrolling in a Browse window

Post by CalScot »

Thanks, Danny.

That's the code that I have in place (in several places). It works fine in most cases (as in after setting a filter or after a Set Filter To, etc., elsewhere in the code), but my problem is with my opening screen - which I'd like to look as clean as possible.

It's strange, but it's the same lines of code (not just other versions of the same code, but a call to the same routine!) that do work after filters that don't seem to work at startup!!

I've made sure that there's no subsequent "Go Top" or anything like that, and I've tried putting it (the .Value := RecNo(), .Refresh and .SetFocus "block") between declare and load (which really doesn't make any sense, but I'll try anything!), between load and activate, after activate, in all three places(!?), in Main itself, in a called function (as a function on its own or at the end of another piece of code), all in the hope that something, somewhere, would work!

Everything I've tried that puts the pointer at the correct record also shows the first records in the file (that is, records that I want hidden "above" the first displayed record).

When I re-read your reply, I thought it might be that I was using the wrong syntax for "Set BrowseSync On", so I tried "SET BROWSE SYNCH ON" (and some other things) but only the syntax I have compiles.

In short, I'm still stumped! But on re-reading this, I've thought to try initializing the browse by setting up a dummy filter that will always work, then a Set Filter To, to see if that solves it.
(And I'll post something here if that works.)

I suspect that the solution will be something simple - I just have to find it!

Thanks again.
CalScot
Leopoldo Blancas
Posts: 388
Joined: Wed Nov 21, 2012 7:14 pm
Location: México

Re: Scrolling in a Browse window

Post by Leopoldo Blancas »

Suerte...
*--------
Luck ...
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: Scrolling in a Browse window

Post by dhaine_adp »

Hi CalScot,

Sorry about my post. Here is my actual code from my app:

Code: Select all

   ANNOUNCE RDDSYS
   SET FIXED ON
   SET DECIMALS TO 2
   SET MULTIPLE OFF WARNING
   SET DATE AMERICAN
   SET CENTURY ON
   SET EPOCH TO 1950
   SET WRAP ON
   SET SCOREBOARD OFF
   SET DELETED ON
   SET CONFIRM ON
   SET BELL ON
   SET FONT TO "Verdana" , 9
   SET NAVIGATION EXTENDED
   SET BROWSESYNC ON   // ----> this is the correct syntax, sorry!
   SET TOOLTIPSTYLE BALLOON
   SET TOOLTIPBACKCOLOR { 255 , 255 , 255 }
   SET TOOLTIPFORECOLOR { 0 , 0 , 0 }
   RDDSETDEFAULT("DBFCDX")
Regarding browse positioning problem, date should be sorted by DTOS( dDate ) unless you really needed DTOC(). Other source of problem is workarea. If you are sure that you are in in correct workarea and that the record pointer is really sitting on the right record then most probably its from the filter itself. Instead SET FILTER try ORDSCOPE(). Like this:

Code: Select all

**************************************
function myFilter( dTop, dBot, cWorkArea, cIndex )

    PRIVATE cTop, cBot

    cTop := DTOS( dTop )
    cBot := DTOS( dBot )
    DBSELECTAREA( ( cWorkArea ) )                 // set your work area
    ORDSETFOCUS( ( cIndex ), ( cOrderBag ) )   // replace this with your appropriate index
                                                                // COMMAND using NTX
    ORDSCOPE( 0, "&cTop" )    // set the top bound
    ORDSCOPE( 1, "&cBot" )    //  set the lower or bottom range
    DBGOTOP()
    YourMainForm.Browse.Value := &( cWorkArea )->( RECNO() )  // YOURALIAS->( RECNO() )
    YourMainForm.Browse.Refresh
    YourMainForm.Browse.Setfocus
    RETURN NIL
Your date index should be made by DTOS() or "INDEX ON DTOS( DATE ) TO MYDATE"
To clear the filter do:
ORDSCOPE( 0, NIL )
ORDSCOPE( 1, NIL )
DBGOTOP()
or simply set it up again into another value. If I am not mistaken Harbour ORDSCOPE() supports NTX index format as well.

-Danny
Regards,

Danny
Manila, Philippines
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: Scrolling in a Browse window

Post by dhaine_adp »

Hi CalScot,

Another thing regarding browse is how is the browse is setup? Is there any events or actions attached on it? Try to disable those browse events like, ON CHANGE, ON GOTFOCUS, ON LOSTFOCUS, ON DBCLICK and make them NIL. E.g. ON CHANGE NIL ON GOTFOCUS NIL ON DBLCLICK NIL. Then one by one add and test them to see if the problem came back.

Once the browse value was changed it will trigger the ON CHANGE event and execute the action you have just defined. Apart from that I can't tell whats wrong. That problem is hard to find if it is related to windows event loop (not the do while loop).

And the last thing that you may look at is your index and database record. Compare them to your filter, maybe your code is correct but the record is not and basically the problem is table and not the code. Sometimes the programs tells the reality and we keep on insisting that it is wrong.

Regards,

Danny
Regards,

Danny
Manila, Philippines
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Scrolling in a Browse window

Post by CalScot »

Thanks, Danny.
(And also Polo for wishing me luck!)

DTOS() and OrdScope() are new to me.

DTOS() certainly beats

Code: Select all

Function UDate()      && Changes Date() format to '20130315' format
Parameters DtParm
Return Str(Year(DtParm),4,0)+Substr(DTOC(DtParm),1,2)+Substr(DTOC(DtParm),4,2)
which I port to everything I write and use in my index files and seeks, so I'll use DTOS() from now on - thank you!

(And, yes, I admit that I did that partly to check out the "Code" option on here that I became aware of yesterday! And, as I've also never used the "Smiley' option before, here goes: :lol: )

OrdScope() sounds interesting, so I will definitely play around with it - but I do want to be able to scroll above the starting record at the non-filtered startup, so having a filter in place then wouldn't work.

Update to my earlier post: Setting a filter on and off before the initial browse screen didn't change anything. Neither did eliminating Softseek -- I use Set SoftSeek On, Seek DateParameter (and get the record's Value := RecNo()), then Set SoftSeek Off to establish the starting date record; I just wanted to rule out SoftSeek as being the reason it wasn't doing what I want. I'll keep trying things...

Thanks, yet again!
CalScot
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Scrolling in a Browse window

Post by CalScot »

Hi, Danny.

I originally had some of the process triggered by the ON INIT event of the Browse, but that caused some other issues, so now the only event triggered within the browse is OnDblClick, which displays a popup window with the full record detail (and works perfectly). Everything else is triggered outside of the browse. (But I will try putting the date-seek routine only back in there in in the ON INIT!)

When the user triggers a change to the browse (whether by button, radio group or check box), that all works just fine. It's just at the startup.
And the Index and Data integrity seem good in all other cases, so I don't think that either of those is causing the problem.
But you *are* forcing me to consider everything, so I really appreciate it!!

I've just had a thought: Maybe I'll try making the Browse window the last thing to be defined in the window definition? Could there be a subsequent definition getting in the way? I doubt it, but it's worth a try... Any success will be posted here!

Thanks again.
L.
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Scrolling in a Browse window

Post by CalScot »

AyAyAy!!!

Making Browse_1 the last item in the window definition for UCMain didn't change anything.

Neither did the following:

In UCMain, ON INIT = GetStartDate()

Code: Select all

Function GetStartDate()
GoToNow()
UCMain.Browse_1.Value := RecNo()
UCMain.Browse_1.Refresh
UCMain.Browse_1.SetFocus
Return Nil
which calls

Code: Select all

Function GoToNow()
NowDtHr := UDate( Date() ) +Substr( Time(), 1, 2)
Set SoftSeek On
DBSeek ( NowDtHr )
Set SoftSeek Off
Return Nil
And STILL it comes up with prior date records in the first few rows and my pointer on the correct date/time but several rows down in the browse. Is there a Smiley for "Scream"?

I'm moving on to something else now. Maybe the answer will come when I'm not thinking about it?

Thanks again, Danny, for all your help.
CalScot
User avatar
CalScot
Posts: 303
Joined: Thu Mar 21, 2013 12:22 am
Location: California

Re: Scrolling in a Browse window

Post by CalScot »

Eureka! I found it!!

The following code works perfectly:

Code: Select all

Function GetStartDate()
GoToNow()
// UCMain.Browse_1.Value := RecNo()
UCMain.Browse_1.Refresh
UCMain.Browse_1.SetFocus
Return Nil
In short, by removing the line "UCMain.Browse_1.Value := RecNo()", the "Go To" record shows in the top row of the browse panel every time.
I don't know why this should make a difference (and I don't think it's supposed to make a difference; maybe it's just in 3.1.1? ) - I'm just happy that it works!!

CalScot
Post Reply