Solved

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

Posted on 1998-02-21
7
372 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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