Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-02-21
7
Medium Priority
?
387 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 150 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Independent Software Vendors: 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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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