Solved

Permanent Scrollbar

Posted on 2000-02-15
21
832 Views
Last Modified: 2010-04-04
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
Comment
Question by:Jaymol
  • 9
  • 4
  • 4
  • +2
21 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2522232
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2522236
Actually, the help for beep says it will work for Win95 also...

Cheers,

Raymond.
0
 
LVL 6

Author Comment

by:Jaymol
ID: 2522272
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:TheNeil
ID: 2522275
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
 
LVL 6

Author Comment

by:Jaymol
ID: 2522280
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2522281
Sorry Jaymol - comes with multiple browsers open :-)
0
 
LVL 6

Author Comment

by:Jaymol
ID: 2522290
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
 
LVL 5

Expert Comment

by:TheNeil
ID: 2522337
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
 
LVL 1

Expert Comment

by:sereda
ID: 2522429
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
 
LVL 6

Author Comment

by:Jaymol
ID: 2522858
Sorry, but it doesn't work.  Anyone else have any ideas?

PS.  You were right about Windows.Beep being different than Beep!
0
 

Expert Comment

by:Michael_Benjamin_Perez
ID: 2524418
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2524726
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
 
LVL 5

Expert Comment

by:TheNeil
ID: 2526185
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
 
LVL 6

Author Comment

by:Jaymol
ID: 2526231
Now that's not a bad idea Neil.....

I'll be back.
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2526260
I warned you it was nasty...

The Neil
0
 
LVL 6

Author Comment

by:Jaymol
ID: 2526375
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
 
LVL 6

Author Comment

by:Jaymol
ID: 2526394
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
 
LVL 1

Accepted Solution

by:
sereda earned 20 total points
ID: 2526593
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
 
LVL 6

Author Comment

by:Jaymol
ID: 2527100
No problem Sereda.  Thanks for your help.

John.
0
 
LVL 6

Author Comment

by:Jaymol
ID: 2527820
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
 
LVL 1

Expert Comment

by:sereda
ID: 2528008
Weird :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question