Solved

Overriding onclick event for all components on form

Posted on 1997-11-16
7
365 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
[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 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
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!

 

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

Technology Partners: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

705 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