Jump to content
toufik

tedit hint not working

Recommended Posts

Just now, Attila Kovacs said:

texthint is not hint, hint is empty and edit is focused so you can't see anything

i don't want to show a balloon hint i want to show a hint inside an edit once the user selects it , it clear 

Share this post


Link to post
Just now, Attila Kovacs said:

it works the opposite way, it's only shown if the edit is not focused

yes that s what i want if you watched the video, you can see that 

Share this post


Link to post
Just now, Attila Kovacs said:

then why are you writing hint in the topic if you are such an eagle eye?

otherwise no clue. debug the VCL

you were right its a ''focus''  problem now i feel very stupid thank you for all your help 

Share this post


Link to post

Your button texts are colorful, that means you have visual styles turned off, but it's needed to show texthint

Share this post


Link to post
6 hours ago, Attila Kovacs said:

Your button texts are colorful, that means you have visual styles turned off, but it's needed to show texthint

can you explain more how to do that please?

Share this post


Link to post

If you want to see the TextHint even if the TEdit control has the focus, you need to send EM_SETCUEABANNER to the control:

https://learn.microsoft.com/en-us/windows/win32/controls/em-setcuebanner

like this:

uses
  ...
  WinApi.CommCtrl,
  ...

procedure TForm1.FormShow(Sender: TObject);
begin
  SendTextMessage(Edit1.Handle, EM_SETCUEBANNER, WParam(True), 'please type here');
end;

WParam(True): if the cue banner (text hint) should show even when the edit control has focus.

Be aware that VCL controls sometimes gets recreated, resulting in a new handle value and losing previous settings.

A better way would be to inherit from TEdit and overwrite the protected DoSetTextHint() method like this:

Interface

uses
  ...
  WinApi.CommCtrl,
  Vcl.Themes, ...;

type
  TMyEdit = class(TEdit)
  protected
    procedure DoSetTextHint(const Value: string); override;
  end;
  TEdit = class(TMyEdit);
  ...

Implementation

procedure TMyEdit.DoSetTextHint(const Value: string);
begin
  if CheckWin32Version(6, 1) // Windows 7 and up
  and StyleServices(Self).Enabled 
  and HandleAllocated
  then
    SendTextMessage(Handle, EM_SETCUEBANNER, WPARAM(True), Value)
  else
    inherited;
end;

HTH

  • Like 1

Share this post


Link to post
12 minutes ago, Achim Kalwa said:

If you want to see the TextHint even if the TEdit control has the focus, you need to send EM_SETCUEABANNER to the control

Also, "enable runtime themes" must be enabled in the project options (in Delphi 2007, no idea what it's called later), but that's the default.

 

I know that because I usually disable this option so I can set colors as I want rather than having them overridden by Windows, so the cue banner didn't work in this case.

  • Like 1

Share this post


Link to post

 

the problem was fixed by changing the rc file name

 

''resource file''

thank you all for help 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×