Solved

Change the blinking cursor of an DBEdit field

Posted on 1998-10-27
3
371 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
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now