Solved

Permanent Scrollbar

Posted on 2000-02-15
21
806 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
Comment Utility
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
Comment Utility
Actually, the help for beep says it will work for Win95 also...

Cheers,

Raymond.
0
 
LVL 6

Author Comment

by:Jaymol
Comment Utility
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
 
LVL 5

Expert Comment

by:TheNeil
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry Jaymol - comes with multiple browsers open :-)
0
 
LVL 6

Author Comment

by:Jaymol
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry, but it doesn't work.  Anyone else have any ideas?

PS.  You were right about Windows.Beep being different than Beep!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Expert Comment

by:Michael_Benjamin_Perez
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Now that's not a bad idea Neil.....

I'll be back.
0
 
LVL 5

Expert Comment

by:TheNeil
Comment Utility
I warned you it was nasty...

The Neil
0
 
LVL 6

Author Comment

by:Jaymol
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
No problem Sereda.  Thanks for your help.

John.
0
 
LVL 6

Author Comment

by:Jaymol
Comment Utility
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
Comment Utility
Weird :)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now