Recent

Author Topic: Multiple buttons in TStringrid was not easy  (Read 4508 times)

Fantablup

  • Full Member
  • ***
  • Posts: 139
Multiple buttons in TStringrid was not easy
« on: June 20, 2021, 06:30:01 pm »
Maybe this can be at help for someone.

I wanted to add multiple buttons in a cell in TStringGrid, But Objects could just hold one.
So, i started to search.
After hours i found out that with Objects it is impossible.

So, i tried with TBitBitn, and added three buttons with rect position for the sell.
It worked, but after a while i saw that when scrolling, and the mouse became over a button, the scrolling went mad.
I used days of trying to fix it, but i couldn't solve it.

So, i tried to create buttons as TImage instead.
This works good. The scrolling problem disappeared.

TImage is not a TWinControl. But TBitBitn is.

So, TWinControl was the thing that was the problem.

I used three whole days trying to fix it, but only using none TWinControl fixed it.

I don't know why. Maybe anyone knows the fix.

« Last Edit: June 20, 2021, 06:49:58 pm by Fantablup »

jamie

  • Hero Member
  • *****
  • Posts: 4747
Re: Multiple buttons in TStringrid was not easy
« Reply #1 on: June 20, 2021, 11:42:03 pm »
Good Job..

 The StringGrid/DrawGrid does not have  a ScrollingWindow that is connected to the scrollbars. Instead its has two scrollbar controls that is used to generate the offset cell numbers and are used during cell plot calculations etc.

 What this means is by dropping a TWinControl onto the surface and having the grid parent it, it will sit there because the client area isn't scrolling in reality.

 Also if you are handling the OnDrawCell event you may also notice the gdPushed does not work unless you are using the Columns property instead of raw metal. But you can achieve the same effects using the provided mouse services.


Keep it up.
The only true wisdom is knowing you know nothing

Fantablup

  • Full Member
  • ***
  • Posts: 139
Re: Multiple buttons in TStringrid was not easy
« Reply #2 on: June 20, 2021, 11:51:00 pm »
Thanks for explanation Jamie :)

The strange thing is that when scrolling to the bottom, and the buttons are there, and the mose comes over it, the grid goes to top and scrolls down again and again, and again.


jamie

  • Hero Member
  • *****
  • Posts: 4747
Re: Multiple buttons in TStringrid was not easy
« Reply #3 on: June 21, 2021, 01:59:58 am »
Thanks for explanation Jamie :)

The strange thing is that when scrolling to the bottom, and the buttons are there, and the mose comes over it, the grid goes to top and scrolls down again and again, and again.

I haven't seen that before but it could be something to do with what you could be doing within your mouse events.

The DrawGrid does not have an Event to report scroll bar movement, if it did you could then update the boundsRect for the TWinControls.

Processing the OnDrawCell, the canvas.Frame3d can be used to simulate a button either pushed or not.

there are one Frame3D overload that seems to get its color from some source I Have not identified in the LCL, it seems to stich with the grey button scene..

I spend a lot of time in Delphi too and run into issues where one works here but won't work there and vis versa ….

Oh well... Have fun.
The only true wisdom is knowing you know nothing

egsuh

  • Hero Member
  • *****
  • Posts: 785
Re: Multiple buttons in TStringrid was not easy
« Reply #4 on: June 21, 2021, 07:41:54 am »
How can you do this pretty design?  :o

Fantablup

  • Full Member
  • ***
  • Posts: 139
Re: Multiple buttons in TStringrid was not easy
« Reply #5 on: June 21, 2021, 01:46:12 pm »
I dont use any mouse events. So, that can not be it.

Nice design? I think so too ;D
It's about thinking and trying, and failing until you get it right. It is allot of work to get any design to look good.

I see that allot of Delphi and Lazarus put components on forms and make it work. But it often look like no design at all. But it works.

I think design is half of the application, when thinking of users that will use it.

I have worked many years with web design, and guess i work on design a little more in Lazarus because of this.

Only one design in this type of application is any good. FlameRobin for Firebird. He has done it right. FlameRobin also had several people working on it.

 

TinyPortal © 2005-2018