Link to home
Start Free TrialLog in
Avatar of l00ny
l00ny

asked on

Change the blinking cursor of an DBEdit field

Hi,

does anyone know how to change the blinking cursor in a DBEdit field (within source code) ?
(I want to make the cursor larger).

Regards
l00ny
ASKER CERTIFIED SOLUTION
Avatar of ronit051397
ronit051397

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of l00ny
l00ny

ASKER

ronit,

thanks for your answer.
I had to change some of your source code so I could implement a resource file.
But there is still one problem: When I click into Edit2 the old (default) cursor plus the new cursor is there. When I change the Edit2 field everything works fine.

Here is my source:

[...]

{$R CURSOR.RES}

procedure TForm1.Edit2Enter(Sender: TObject);
begin
  FBitmap := LoadBitmap(Hinstance,'CURSOR');
  CreateCaret(Edit2.Handle, FBitmap,
    GetSystemMetrics(SM_CXBORDER),GetSystemMetrics(SM_CYBORDER));
  ShowCaret(Edit2.handle);
end;

procedure TForm1.Edit2Exit(Sender: TObject);
begin
  DestroyCaret;
  DeleteObject(FBitmap);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DestroyCaret;
  DeleteObject(FBitmap);
end;

procedure TForm1.Edit2Change(Sender: TObject);
begin
  FBitmap := LoadBitmap(hinstance,'CURSOR');
  CreateCaret(Edit2.Handle, FBitmap,
    GetSystemMetrics(SM_CXBORDER),GetSystemMetrics(SM_CYBORDER));
  ShowCaret(Edit2.handle);
end;

This is a shorter code. When you click on Edit2 then it works OK, but when you enter Edit2 by TAB key, it doesn't work ok. Sorry, I couldn't solve it:

  var
    FBitmap: HBitmap;
.

procedure TForm1.FormCreate(Sender: TObject);
begin
  FBitmap:=LoadBitmap(0,MAKEINTRESOURCE(OBM_RGARROW));
  Edit2.OnEnter:=Edit2.OnChange;
  Edit2.OnClick:=Edit2.OnChange;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DestroyCaret;
  DeleteObject(FBitmap);
end;

procedure TForm1.Edit2Change(Sender: TObject);
begin
  CreateCaret(Edit2.Handle, FBitmap,     GetSystemMetrics(SM_CXBORDER),GetSystemMetrics(SM_CYBORDER));
  ShowCaret(Edit2.handle);
  Edit2.Invalidate;
end;