Solved

How to modify the caret width/height in a edit control.

Posted on 1998-02-21
7
375 Views
Last Modified: 2010-04-04
I want to modify the caret width/height in a edit control.

I found "CreateCaret" and "ShowCaret" in the WinAPI.Hlp
I tried to play with these functions but I get the old caret.

- I want to know where and how call the procs.
- How work with a "bitmap " to create the caret ?

Some sample code would be very helpful.
0
Comment
Question by:jpdupont
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 50 total points
ID: 1359650
Place to 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;


0
 

Author Comment

by:jpdupont
ID: 1359651
Sorry, the code don't work ...
I paste your code on my form.

(FBitmap : HBitmap ?)

The bitmap is drawned on the edit. The old caret is also there.
The bitmap disapear when the edit is redrawn (type some text in).

I try without bitmap (with a 10x10 caret).
Same problem.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1359652
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:jpdupont
ID: 1359653
Have you try the code you send ;) ?

Exactly the same effect :
The code don't work.

JP
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1359654
Yes, I tried. Post your EMail and I'll send it to you.
I tested it in Delphi 3, WinNT4.
0
 

Author Comment

by:jpdupont
ID: 1359655
Ronit,

I'm using D3.02, Win95.
jpdupont@skynet.be

Thanks for the help !

0
 

Author Comment

by:jpdupont
ID: 1359656
The sample code work.
But I get some flicker when using the edit with new caret
(I tried no bitmap caret).
Probably there is an other way to do the work.
Thank for help.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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