Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ugh... Getting the Cursor position -

78 views
Skip to first unread message

Christopher Pall

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to
Well - what worked for TEdit doesnt' work with TStringGrid. Here's
what I got that doesn't work:

What does?

procedure TEditorDlg.UpdateStatusPanel;
var
CaretPos : DWord;
Hand : THandle;
begin
if KeyStatus.NumLock = ksOn
THEN StatusBar.Panels[3].Text := 'NUM'
ELSE StatusBar.Panels[3].Text := '';
if KeyStatus.CapsLock = ksOn
THEN StatusBar.Panels[4].Text := 'CAP'
ELSE StatusBar.Panels[4].Text := '';
SendMessage(EditGrid.Handle, EM_GETSEL, 0, CaretPos);
StatusBar.Panels[0].Text := IntToStr(CaretPos);
StatusBar.Panels[1].Text := IntToStr(EditGrid.Selection.Top-1);
end;

Peter Below

unread,
Sep 10, 1998, 3:00:00 AM9/10/98
to
In article <35F737B8...@spambegonewmich.edu>, Christopher Pall wrote:
> SendMessage(EditGrid.Handle, EM_GETSEL, 0, CaretPos);
>

Christopher,

if EditGrid is a TStringgrid then the message is send to the wrong window.
In edit mode the grid uses a special edit control that moves from cell to
cell as the user moves the focus. That control needs to be the target of
the message if you want its caret position. TStringgrid inherits a
protected property

property InplaceEditor: TInplaceEdit read FInplaceEdit;

from TCustomGrid. You can get its handle via

Type
TGridCracker = Class( TStringGrid );

SendMessage(TGridCracker(EditGrid).InplaceEditor.Handle, EM_GETSEL, 0,
CaretPos);

Wouldn't it make more sense to display the current Row/Col in the grid
instead of the caret position in the editor control?
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitely requested!


Christopher Pall

unread,
Sep 10, 1998, 3:00:00 AM9/10/98
to

Thank you very much for the answer - I was befuddled by this one...

As for your second point - actually no, I am making a COBOL editing program and as you may know - columns are pretty
important in COBOL - I am using the TStringGrid as the editor because COBOL starts code out at column 7 and I just
wanted to show the line numbers at the left...

Ordinarily I think it most certainly would make more sense.

0 new messages