[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 858
  • Last Modified:

Permanent Scrollbar

I have a string grid that starts blank and is populated when entries are made by the user into a database.  I know for a fact that they will be entering more than enough to require a vertical scrollbar on the grid, so I've left enough room on the right for it.  Now, when there's no scrollbar, there's a gap.  I want the scrollbar permanently visible.

John.
0
Jaymol
Asked:
Jaymol
  • 9
  • 4
  • 4
  • +2
1 Solution
 
rwilson032697Commented:
Try this:

This should work for Win95:

procedure Sound(Freq : Word);
var
    B : Byte;
begin
    if Freq > 18 then
        begin
            Freq := Word(1193181 div LongInt(Freq));
            B := Byte(GetPort($61));

            if (B and 3) = 0 then
               begin
                   SetPort($61, Word(B or 3));
                   SetPort($43, $B6);
               end;

            SetPort($42, Freq);
            SetPort($42, Freq shr 8);
        end;
end;

procedure NoSound;
var
  Value: Word;
begin
    Value := GetPort($61) and $FC;
    SetPort($61, Value);
end;

procedure SetPort(address, Value:Word);
var
  bValue: byte;
begin
  bValue := trunc(Value and 255);
  asm
    mov dx, address
    mov al, bValue
    out dx, al
  end;
end;

function GetPort(address:word):word;
var
  bValue: byte;
begin
  asm
    mov dx, address
    in al, dx
    mov bValue, al
  end;
  GetPort := bValue;
end;

--------------------------------------------------------------------------------
Under WinNT, Beep(Tone, Duration) can be used.

Cheers,

Raymond.
0
 
rwilson032697Commented:
Actually, the help for beep says it will work for Win95 also...

Cheers,

Raymond.
0
 
JaymolAuthor Commented:
Raymond.  Thanks for that, but you've answered the wrong question my friend.

Be quick....someone else WILL steal and use your code if you don't answer the question.  I should know....
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
TheNeilCommented:
John,

Why not simply create a set of blank rows in the string grid and then fill them until you've used them all up. Once you've used them all, THEN start adding extra rows on.

e.g. String grid will display 10 rows so you initially set it to have 10 EMPTY rows. When you add a row, just do the following:

IF StringGrid1.Cells[0, StringGrid1.RowCount - 1] = ''
THEN
BEGIN
  //Insert the data in the first empty row
END
ELSE
BEGIN
  //Add a row
  //Insert the data into the new row
END;

The Neil
0
 
JaymolAuthor Commented:
Thanks Neil, but I think that looks a bit tacky.  I did do that originally, but would prefer the grid to look uniform throughout.

Thanks anyway,

John.
0
 
rwilson032697Commented:
Sorry Jaymol - comes with multiple browsers open :-)
0
 
JaymolAuthor Commented:
No problem Raymond.  Hope you get the points.  Oh yeah, BTW.  I'm on NT and can't use Beep(any variables whatsoever!).  Can only go...

  Beep;

That's all!

John.
0
 
TheNeilCommented:
Ok John. If you had used it then your table would look as though it was more like a notebook. I think this is a hack of the component source code

The Neil
0
 
seredaCommented:
John,

about beeps - you can do windows.beep (tone, duration), i am sure ;)

to your question - you can explicitly tell window to show its scrollbar by
 Windows.ShowScrollBar (MyGrid. Handle, SB_VERT, True);

And you may set scrollinfo for a scrollbar so window will not hide it - instead it will disable it:
 var si: TScrollInfo;
 ...
 si. cbSize := sizeof (si);
 si. fMask := SIF_DISABLENOSCROLL;
 Windows.SetScrollInfo (MyGrid. Handle, SB_VERT, &si, True);

If this won't help, try playing with other scroll info or setting flat scroll bars (they are more volatile).

Igor.
0
 
JaymolAuthor Commented:
Sorry, but it doesn't work.  Anyone else have any ideas?

PS.  You were right about Windows.Beep being different than Beep!
0
 
Michael_Benjamin_PerezCommented:
Hi John,

Maybe a bit dirty again, but what about dropping the stringgrid in a scrollbox.
switch off all scrollbars in the stringgrid, switch off the horizontal scrollbar in the scrollbox. So implicitly the only scrollbar on is the scrollbox's vertical scrollbar.

Now every time you add a row simply increase the height of the Stringgrid equal to the height of one row.

Next thing you do is connect the OnScroll event of the scrollbox to the cursor movement of the Stringgrid.

I worked for me ! Although I must admit it's horrible <grin>

G'Luck, Mick
0
 
rwilson032697Commented:
You could use something like TAdvStringGrid (from DSP) which allows you to say you want the last column to stretch to fit...

Cheers,

Raymond.

Beep :-)
0
 
TheNeilCommented:
Here's a nasty hack that just LOOKS as though you have a scrollbar. Just drop a TScrollbar on top of your TStringGrid. Make sure that it's disabled and then when the StringGrid's own scrollbar actually appears, hide the dummy one. Just a thought

The Neil
0
 
JaymolAuthor Commented:
Now that's not a bad idea Neil.....

I'll be back.
0
 
TheNeilCommented:
I warned you it was nasty...

The Neil
0
 
JaymolAuthor Commented:
AHHH!!!!!

I don't really like that Neil.  I can see too many problems with it.

I have noticed something VERY strange though.....

The earlier suggestion to use ShowScrollBar is not completely useless....just with vertical scroll bars.

  ShowScrollBar(StringGrid1.Handle, SB_BOTH, True);

This shows the horizontal one, but not the vertical.

Any suggestions how to fix this?

John.
0
 
JaymolAuthor Commented:
Sereda's getting the points for this.  I tried the ShowScrollBar command again, but in many, many various places and found that it works in some, but not in other more obvious ones.  I only tried it in one place earlier.  Now, I have it working.

So, Sereda, if you're still reading this.....post something so I can give you the points.

Ta,

John.
0
 
seredaCommented:
Hi John,

here i am :)
We had also a nasty experience with scrollbars (we had listview though, not a grid) - but the task was the same - to show scrollbar always. The solution was much like you did it - not obvious - and with use of flat scrollbars...

I think the formal solution is to have scrollbar as a separate window, but it is much more coding...

Thanks for points,

sereda
0
 
JaymolAuthor Commented:
No problem Sereda.  Thanks for your help.

John.
0
 
JaymolAuthor Commented:
Just in case anyone is wondering, if you put the code (the answer) in the grid's OnDrawCell event, you get a scrollbar that's always there, but only moves when it can!

Mmm, Nice.
0
 
seredaCommented:
Weird :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 9
  • 4
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now