Forcing a non blocking temporary hint window in Delphi
Asked Answered
M

2

7

I've been searching, but cannot find a solution so I figured perhaps I should simply post it.

Here's what I'd like to do, in Delphi (2009):

At a certain moment in my application, I'd like to show a message to the user.

This should be the normal hint window, which automatically disappears after the normal application defined hint pause, with a custom message (and have it automatically sized etc etc).

This should be non blocking, like a normal hint, not dependent on the current control or whatever.

"Just show the damn message", in the Application hint window and carry on.

Any clues?

Mandel answered 4/4, 2014 at 18:31 Comment(2)
If you have the DevEx controls you might have a look at the alert manager.Bantamweight
Try using tHintWindow:Crete
O
12

You can use a CustomHint:

with TCustomHint.Create(Self) do begin
  Title := 'temporary message';
  Delay := 0;
  HideAfter := 2000;
  ShowHint(Point(X, Y));
end;

However it is not destroyed at the time it's hidden, but when its owner (Self) is destroyed. But you can of course re-use the same hint instance.

Outworn answered 4/4, 2014 at 20:15 Comment(1)
Just experimented with it, this works nearly exactly as I want! Thank you, didn't know about that class yet. Excellent, thanks!Mandel
B
1

You can use THintWindow for this. Create an instance of THintWindow and when you want to show the window call ActivateHint. When you are ready to close the window call ReleaseHandle. If you want to have the hint window close after a period of time, you'll want to run a timer to allow you the opportunity to ReleaseHandle when time is up.

Breana answered 4/4, 2014 at 19:36 Comment(14)
well, that's the point -- I don't want to keep track of created hint windows and release them myself, I want the Application to do that, as it has all things functionality.Mandel
Who is going to keep track of the hint window if you won't?Breana
That was part of the question: show it in the Application hint window, do not have to create my own hint window, including color etc and keep track with hint timers, avoiding double hints from controls etc etc. I would basically be replacting what TApplication already does!Mandel
The application won't do that. You will have to.Breana
It's a damn pity you have to duplicate that code. Especially since your new hint window would need to disappear when the applications hint window pops up. :(Mandel
I don't think that there's any easy way to piggy back on the application's hint mechanismBreana
See the answer by Sertac, although it doesn't hide the window when the application itself shows a window, the created window is automatically hidden. Works like charm. Thank you for your time.Mandel
It looks crappy though. It's not the same as the normal hint window. Which is what you asked for. And which is why I don't use it and why I did not suggest it. Never mind.Breana
@David - It looks like a standard hint window here with my XE2 test. Anyway, I guess setting Style := bhsStandard should make it look like more standard with your test.Outworn
@Sertac Different shades of yellow for me. The standard hint window is THintWindow though, isn't it?Breana
@David - Yes. This one rather looks like for built-in support for balloon hints.Outworn
@Martin you realise that all you need is one timer and you can match the behaviour of TCustomHint and get the visual appearance that you desire. Is it really that hard to use a timer?Breana
@David: as I said, I wanted to have the hint to disappear when another normal hint is shown, and although with the custom hint, this doesn't happen automatically, the custom hint helps a lot with implementing such a thing.Mandel
You also said that you wanted the normal hint.Breana

© 2022 - 2024 — McMap. All rights reserved.