?
Solved

Change the blinking cursor of an DBEdit field

Posted on 1998-10-27
3
Medium Priority
?
378 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 300 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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