Solved

Overriding onclick event for all components on form

Posted on 1997-11-16
7
359 Views
Last Modified: 2010-04-04
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!!
0
Comment
Question by:doogie
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:itamar
ID: 1350638
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 ?
0
 

Author Comment

by:doogie
ID: 1350639
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!
0
 
LVL 4

Expert Comment

by:itamar
ID: 1350640
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!
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:doogie
ID: 1350641
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 !!!
0
 
LVL 4

Accepted Solution

by:
itamar earned 100 total points
ID: 1350642
Hey ! I hope you're using Delphi 2 !
It's not a third-party VCL, it's just in the Form !!!

Ok, no more mistery...

You must make your app help exactly the same way to use the F1 context help.
In the form you want to use the left mouse button you must set the following properties as this:

+BorderIcons
  biMinimize = False
  biMaximize = True
  biHelp = True

And that's all...
Observe that this kind of help (pop-up windows) doesn't work with Minimizeable and/or maximizeable forms. It's not a limitation of Delphi. It's a Windows standard (believe me !).

By the way, take a look at the OnHelp event of TApplication, perhaps it can be usefull on HTML helps.

I hope this helps,

Itamar
0
 

Author Comment

by:doogie
ID: 1350643
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.
>

0
 
LVL 4

Expert Comment

by:itamar
ID: 1350644
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.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 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