trichview.com

trichview.support




Re: CAPSLOCK & Insert


Return to index


Author

Message

Sergey Tkachenko

Posted: 09/03/2004 21:20:00


1) Caps Lock state is global for all application and can be toggled when

user presses this key in any application.

Its state can be tested:

IsCapsLockActive := GetKeyState(VK_CAPITAL) and 1)=1;

If you want to display Caps Lock indicator, the simplest way is to use timer

to update it


2) Insert state is local for the application and can be toggled only when

editor has input focus.

TRichViewEdit does not support override mode directly, but you can implement

it yourself using this code:


var IgnoreNextChar: Boolean = False;


procedure TForm1.RichViewEdit1KeyDown(Sender: TObject; var Key: Word;

  Shift: TShiftState);

begin

  IgnoreNextChar := RichViewEdit1.SelectionExists;

end;


procedure TForm1.RichViewEdit1KeyPress(Sender: TObject; var Key: Char);

var rve: TCustomRichViewEdit;

    ItemNo, Offs: Integer;

begin

  if IgnoreNextChar then begin

    IgnoreNextChar := False;

    exit;

  end;

  IgnoreNextChar := False;

  if not ((Key=#9) or (Key>=' ')) then

    exit;

  rve := RichViewEdit1;

  while rve.InplaceEditor<>nil do

    rve := TCustomRichViewEdit(rve.InplaceEditor);

  if rve.SelectionExists then

    exit;

  ItemNo := rve.CurItemNo;

  Offs  := rve.OffsetInCurItem;

  if (Offs>=rve.GetOffsAfterItem(ItemNo)) then begin

    if (ItemNo+1<rve.ItemCount) and

       not rve.IsFromNewLine(ItemNo+1) then begin

      inc(ItemNo);

      Offs := rve.GetOffsBeforeItem(ItemNo);

      end

    else

      exit;

  end;

  rve.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs+1);

  rve.Invalidate;

end;


You can test if Insert is pressed in OnKeyDown, Key = VK_INSERT




>

> I�m trying TRichView v1.9 and I�d like to know when CAPSLOCK is activated

> and when Insert is activated.

>

> Thanks

>

> Pieter E.

>





Powered by ABC Amber Outlook Express Converter