Solved

Change the blinking cursor of an DBEdit field

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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