Solved

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

Posted on 1998-02-21
7
378 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
[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
  • 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
Industry Leaders: 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!

 

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

Industry Leaders: 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

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…
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…

756 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