Link to home
Start Free TrialLog in
Avatar of doogie
doogie

asked on

Overriding onclick event for all components on form

How do I override the onclick event for all the components on a form, without having to hardcode each event?
I can override the onclick for the form, but not inherited by all the components on the form. I want to implement a help cursor, Word style, that when clicked changes the cursor to crHelp, and then while the cursor is in this state, I want it to give the component focus when clicked, and then execute an F1 keypress, but not execute the standard onclick event for that component.

Ive tried the following for Form1
type
THelpForm = class(TForm)
procedure Click; override;
end;

type Form1 = class(THelpForm)....
end;

procedure THelpForm.Click;
begin
  if Screen.Cursor = crHelp then
     Form1.Edit1.text := 'HELP'
  else
  inherited Click;      { perform standard handling, including calling handler }
end;

Well this works just fine for the form itself, but not for the buttons on the form etc... and I don't want to have to hardcode every button on the forms onclick event... Is it possible for the m to inherit this click override!!
Avatar of itamar
itamar

Delphi already has this kind of help implementation.
Do you know this and don't want to use, or would you like some information about that ?
Avatar of doogie

ASKER

I know Delphi has context sensitive help on the F1 key, but not on the left mouse button as far as I know, and not with the cursor crHelp.
I also need to use HTML help and not the standard help API that Delphi understands

So my question still stands as is!
Just for your information:
Delphi also has context sensitive help on the left mouse button including the activation by the interrogation mark button on top of the form, changing the cursor (crHelp) automatically and opening a help window based on the help context of every object in the form (just like Word does).
But... it doesn't understand the very new HTML help. Perhaps when it becomes standard in Win98, who knows...
So my comment still stands as is!
Avatar of doogie

ASKER

Well well, never too old to learn. Thanks for that.
Let me in on how the context help is activated using the left mouse button, and please tell me about the 'interrogation button' and all the points are yours!!...seeing as that is exactly what I require... I know how to get the HTML help to work.
Code eg will be appreciated. I'll also revisit the documentation... If you are using a thirdparty VCL please let me know
Thanks !!!
ASKER CERTIFIED SOLUTION
Avatar of itamar
itamar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doogie

ASKER

Itamar....
Well now I have the real answer, not the answer to the question that arose from the question. You got the 100 points for answering the second question, but here is the real answer from Peter Below (Team B) Borland.public.delphi.winapi newsgroup.


>SendMessage(Form1.handle,WM_SYSCOMMAND,SC_CONTEXTHELP,0);
>
>PS Peter this works just fine.. will look into the help for speed
>buttons as you recommended!
>And yes it does change the cursor to crHelp.
>The BorderIcons property allows one to set biHelp, but then the form
>defaults to a dialog form...this way the form is still resizeable, and
>also works with HTML help using  components from Hyperact.
>

It's a good answer indeed, but the original question was:

"How do I override the onclick event for all the components on a form, without having to hardcode each event?" (Remember that ?)

Does Peter's code do that ??

Let me refresh Peter's answer:

"Adrian,

you are going at this problem from the wrong angle, i think. If you go into help context mode ..."

What Peter's code does is exactly the same of biHelp with the clear advantage of a minimizeable form, but it is not Windows 95 standard (Who cares ?)

I think it's important to make things clear. That's why i put this comment.