Solved

Change the blinking cursor of an DBEdit field

Posted on 1998-10-27
3
374 Views
Last Modified: 2010-04-03
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
0
Comment
Question by:l00ny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1344555
Try this (It should work also on TDBEdits):
Place 2 TEdits on a form and write the following:

    procedure TForm1.Edit2Enter(Sender: TObject);
    begin
      FBitmap:=LoadBitmap(0,MAKEINTRESOURCE(OBM_RGARROW ));
      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;

Also add the following to the code:

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

Author Comment

by:l00ny
ID: 1344556
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;

0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1344557
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;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question