How to fire the TStringGrid SelectCell event programmatically - c++builder

I have tried some tips on how to do it, even a Team B code I've found using Grid->Row and Grid->Col, these properties are set, the SelectCell event is not fired though. It only works when I click on a cell with the mouse. Can someone help me on this task?
Thank you very much.

Related

Why OnHScrollChange is not fired in stringgrid in Firemonkey?

Why OnHScrollChange is not fired in stringgrid in Firemonkey? How should i catch the scrolling event in Stringgrid?
OnHScrollChange is fired when you scroll with the scrollbar thumbgrip or its buttons. It is however not fired by changing the selection with the left and right arrow keys, even if that would result in the thumbgrip of the scrollbar being moved.
If your question is about the latter situation, I kind of agree with you that it should trigger the OnHScrollChange, but then again, I have no idea of any design decisions. You may want to enter a report at Embarcadero's Quality Portal and see how they respond.
Another possibility is to use the OnViewportPositionChange event instead which fires however the viewport position changes. The caveat is that it fires also on vertical scrolling. If this is ok for you then that is your solution.

What does a StringGrid's OnSetEditText event do?

I thought OnSetEditText was fired whenever text in a cell changed. After setting a breakpoint and experimenting, I know that's wrong :-) So, first, when is this event fired?
Second, if I would like to have the text inside a grid cell continuously autosized, which event should I be coding to make this happen (note: I am using TMS's string grid derivative which includes a method for autosizing rows; I just have to figure out when to call it)?
The OnSetEditText event is fired every time the user changes the contents of the in-place editor control, assuming, of course, the control is editable (goEditing in Options). This is confirmed by the documentation, the VCL source code, and black-box verification.

Virtual TreeView update hint within cell on mouse move

I'm using a TVirtualStringTree as a grid which is working pretty well.
I'm using the treeviews hint functionality to show a hint when the user positions the mouse over a cell. I've had to change HintMode to hmHint as I want my hints to appear regardless of the cell text length.
What I'm trying to do now is to display a different hint depending on whereabouts the mouse is within the cell.
I can do this no problem before the hint is displayed by using the OnGetHint event. My problem is this event is only raised a next time when the user moves the mouse to another cell.
I can't see to find a way to update the hint while its displayed and the mouse is moved within the same cell
I've looked at suggestions for other controls, using the Application's OnShowHint event but they just seem to make the hint disappear and not show again.
Anyone got any ideas?
Thanks
Update
After some investigation here is what I have found in case it helps someone come up with a solution:
The CMHintShow method sets the CursoRect field of the HintInfo record to the bounds of the cell. This seems to stop the VCl from triggering the hint code again until the mouse moves out of this rect (TApplication.HintMouseMessage).
If i set the CursorRect to something smaller than the cell bounds the hint will update. I use VTs in a few places for different purposes, so I can't make these changes directly. Would be good to get a solution that doesn't require this change.
In TBaseVirtualTree.CMHintShow right near the top, the code reads:
if PtInRect(FLastHintRect, HintInfo.CursorPos) then
Exit;
If you comment this out then the behaviour is closer to what you are looking for. The hint window won't show again if you move the mouse within the same cell, but if you click then it will.
I can't seem to find any way to make the hint window show in the same cell without that mouse click though!

Cause 'hint' to refire on listview as I move over items

Sure I've seen this done before but off-hand I can't find any examples.
I've got a TListView, set in 'report' viewstyle. It has about half a dozen subitems, and one thing we'd like to do is have the 'hint' (tooltip) on the listview dynamically show another field of data. That is, each time you move the mouse over any given row, the 'hint' would show some text relevant to that particular row.
I'm partway there - I can do this using the OnInfoTip method, but unfortunately once a tip has appeared, Windows seems to decide that I don't need to see a hint for the listview again until I move the mouse away from the listview and then back 'over' it again. Simply moving the mouse down to the next row, all-the-time keeping the mouse over the control, doesn't persuade the program to display the new hint.
Just to be clear - I've got OnInfoTip working so that the program does display the right hint relevant to the item I first moved the mouse over. Changing the hint text isn't the issue. The problem is that moving the mouse to another item in the listview doesn't cause the software to show a new hint. (Hope that makes sense).
Is there some proper way of getting this behaviour to work, or am I going to end up doing something icky with mouseovers and then manually drawing a hintbox (etc)?
check the following link:
Display Custom Hints for TListView Sub Items
Edit:
I just checked it now on delphi7 it's showing the hint for every row dynamically after moving the mouse on the listview.
Offtopic: This is simple in Virtual Treeview component, it is build-in feature.
i was using the OnInfoTip event (i didn't need hints for the subitems). the hint was "flashing" (show/hide/show/hide/show/hide/show/hide). found the listview's ShowHint was false. set it to True and it worked as it should.

How to Detect that the Mouse is unmoved and button still pressed?

In Delphi, I've added a Scrollbar component (oriented vertical) to the right side of my form.
I've added a Scrollbar OnChange event so I can change the view of the form and the position of the scrollbar thumb when the user clicks on the UpArrow or DownArrow button with his mouse, and this works fine.
But the OnChange event only seems to get triggered when the mouse button is initially pressed on the arrow.
I notice all scrollbar controls repeat the command and continue scrolling while the mouse remains pressed on the arrow, and I'd like to implement this behavior.
So how can I easily detect if the user has not moved the mouse and continues to press the mouse button while the mouse remains over the arrow?
Conclusion. Somehow something in the scrollbar in my project got corrupted. After I deleted the ScrollBar, and added it again, the problem vanished.
This is one of those tricky ones that took me a lot of time to solve. Thanks for your help. I'm closing this question.
Use the OnScroll event.
The following code adds 'xxx' to a memo as long as the mouse is held down on the scrollbar arrow button. Tested with Delphi 6.
procedure TForm1.ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
var ScrollPos: Integer);
begin
Memo1.Lines.Add( 'xxx' );
end;
The usual way to handle auto-repeating is to enable a TTimer and check in the OnTimer() event handler whether the action needs to be performed again, and to deactivate the timer if not. If you need sample code, I seem to remember that the SynEdit control used a similar technique for autoscrolling in drag and drop operations.
If a component does not encapsulate the behaviour you are looking for and you can't easily simulate the behaviour with the methods available you should really subclass the closest component that does most of what you need and add the behaviours that are missing.
I know that some extra work is involved but it really is the better way to go. Now with Delphi, I seem to recall that subclassed components needed a bit of extra work as well to be able to be used from the IDE for form design, maybe this has changed since version 7.

Resources