I haven't blogged much recently, primarily because there hasn't been much to
blog about, but also because quite often I get struck by a mysterious malaise
that hits at around 2 pm and only dissapates in the evening. I had a
gastroscopy test at the beginning of the week whose conclusions were unclear;
I don't have anything seriously wrong, but still. On the topic of health, I
can report that since starting the new
prophylactic medicine1 for migraines, I have been mercifully free of headaches, but there
have been other side effects, such as adding 3 kg to my weight! And now for
today's topic: horizontal scrolling.
In the OP's management program, there is a very simple form that has exactly
one visible component, a TDBGrid. The grid's datasource is a query that has
three fields: a date, a subject and a hidden id field. The subject can be very
long and so it can be wider than the width of the form. Both the form and the
grid have their bidimode set to biRightToLeft, as it should be for a Hebrew
form. When one double clicks on the grid in order to open a form that is
dependent on the hidden id field, the grid scrolls horizontally all the way to
the left, thus effectively hiding the date field. A user complained
that she had to scroll all the way to the right in order to overcome this.
I admit that I've seen this problem before but haven't cared enough to fix it. I
also didn't know how to repair it. I assume that the solution would be some message
that is sent to the grid to make it scroll back to the right. According to
CoPilot, When a TDBGrid is in Right‑To‑Left mode: The visual left edge is
actually the logical right edge. The scrollbar is reversed. When the grid
receives focus again (after your double‑click opens the EditTask form),
Windows sends a WM_HSCROLL message. The default handler scrolls the grid to
the logical left, which in RTL mode is the visual right. But Delphi’s RTL
support is partial, and the grid ends up scrolling to the visual left instead
— exactly the opposite of what you want. So after returning from the EditTask
form, the grid scrolls to the wrong side.
The fix seems to be to send the WM_HSROLL message to the grid (as I assumed):
DBGrid1.Perform (WM_HSCROLL, SB_RIGHT, 0). But this code actually sends the
cursor to the left of the grid (as I see it), whereas I want it to go to the
right. So the real fix is DBGrid1.Perform (WM_HSCROLL, SB_LEFT, 0). And this
does work.
Internal links
[1] 2095
This day in blog history:
| Blog # | Date |
Title | Tags |
| 72 | 08/05/2007 | (Welcome to the) Hotel California | Van der Graaf Generator, Randy Newman, Jackson Browne, CSN, Barney Hoskyns |
| 130 | 08/05/2008 | Amsterdam diary | Programming, Holiday, Amsterdam |
| 357 | 08/05/2011 | More facts your mother never told you about Word automation | Programming, Office automation |
| 581 | 08/05/2013 | Analysing my sleep | CPAP, Gadgets |
| 704 | 08/05/2014 | Doctoring, researching, sampling | DBA, Kindle |
| 1500 | 08/05/2022 | 1500 blogs | Meta-blogging |
| 1757 | 08/05/2024 | Milano: the final day | Computers, Holiday, Italy, Milan |