MouseDown() on a TImage

I can get a MouseDown response from EditBox1 and RichEdit1 on Form1, but I cannot get a response from other areas on Form1, nor from the area under a TImage object - my main concern.

My app. uses several other Forms which, surprisingly, do not suffer the same problem.

I am using Delphi6, Windows XP.

Suggestions please.
magman5Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Emmanuel PASQUIERFreelance Project ManagerCommented:
what do you mean by you can't get a mouseDown response for the form or TImage ? the events exist for those. Are you saying that when implement the MouseDown event on you form and TImage and you click on those, your event is not triggered ?

can you post the .PAS and .DFM of your form ?
0
magman5Author Commented:
Thankyou for your quick reply

Instructions in the mousedown event are not executed.

Yes I can send .PAS and .DFM files, hopwever this is my first post and
I do not want them in the public domain.

Can I just send them to you only ?
0
systanCommented:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Edit1: TEdit;
    Label1: TLabel;
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Label1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
text:='Timage mouse down response';
end;

procedure TForm1.Edit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
text:='TEdit mouse down response';
end;

procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
text:='TLabel mouse down response';
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.OnMouseDown:=Label1MouseDown;
Image1.OnMouseDown:=Image1MouseDown;
Edit1.OnMouseDown:=Edit1MouseDown;
end;

end.


//systan ideas
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

systanCommented:
and you can add x and y coordinates, like this:
text:='Timage mouse down response at X:' + inttostr(x) + '  at Y:' + inttostr(y);
0
magman5Author Commented:
Thanks Systan,

I have code very similar to this and it should work, but does not.

I have sent full source code to epasquier for comment and will await his/her reply.
0
Geert GOracle dbaCommented:
not really in line with the use of this site...
just post the code here and you will have more than just 1 expert looking at your problem
0
magman5Author Commented:
Thanks for the suggestion Geert. I will wait this time.
0
Geert GOracle dbaCommented:
the clicks wil not go under a TImage
the Timage receives the clicks and ignores them
nothing under a image will receive clicks

you are not letting anyone else look at your problem ?
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
I understand why you did not wanted to post your whole project here, it's huge.
Unfortunately I can't compile as you are using some units I don't have.
One tip though : naming your forms from Form1 to Form65 is NOT a good idea. Relevant names makes good software. Same goes for your components.

Now, I suggest you tell me which form cause your problem, and I will try to extract it in a simple project, clean it from whatever non standard components/unit you might have there, and post it here for everyone to be able to look at it. That is what you are supposed to do here to get help from experts, but I'm willing to show you what we expect, this time.
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
Ok, I re-read your email, so your problem is in Form1. Which is not the smallest :o/
I have a problem with some of your DFM files that are completely f??cked up (they looks like binary files with some text within), so I can't view the forms. I don't see how you could even compile with that.

Here are the ruined files :

XYZ_Edit_Unit1.dfm
Color_Drape_control.dfm
Display_Data_Parameters.dfm
HeadingError.dfm
XYZ_2_ERV.dfm
XYZ_Edit_Tools.dfm

You should try to find some backup of those files (I hope you have some). If you can compile with those, it's not surprising if there are some events that do not work. What's surprising is that you don't have much more problems.
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
@modus operandi

1) true. I only accepted to see if and why it was sensitive for the asker, and to make things faster on his first post here. And because the question sounds not likely to interest others (not a particular technique implementation), but a problem with his environment. I think about corrupted source files now.

2) I suppose it's true most of the time. I'm well aware of the value of posting the answer there, and haven't and (would not have) replied to the question by mail, only here.

I'll wait for the moment
0
magman5Author Commented:
Thanks modus operandi,

I understand your comments and do not wish to cause anyone any grief.
epaxsquier has been most helpful to date, in the spirt of helping others should not be chastised.

There is clearly a shortcoming if people cannot keep some code confidential, especialy code that is not causing any problems and not thus not relevant to a solution.

Regarding potentially corrupted files, the current projest compiles fine. but will not allow me to generate any new forms called Form16 for some reason. Whilst I can work around this, it may be part of the corrupted file problem.

The project is indeed large and Form1 where the are problems, calls dozens of other forms - not easily isolated.

As I am not prepared to post the whole project to others, either

1. You let epasquier help me and a summarised solution gets posted ( the "normal solution" has indeed  
     already been posted)
2. EE consider setting up a confidential area in a manner that will add to the sites usefuness
    (I must not be the only person with confidentialty concerns)
3.  I withdraw the question

Either way, I think it only fair to reward epasquier and Gert with some points.

0
Emmanuel PASQUIERFreelance Project ManagerCommented:
magman, don't bang your head for such a small issue. It's true that a confidential area would be a convenient feature, but I think that if it exist, too much people will use it, more than really necessary, and the exchange spirit of the site would slowly disappear. Also, as it is, it forces the asker to try to isolate only the part of their code that is causing problem. That's better for them in the long run, and better for the experts that don't have to crawl in tons of new code each time.

as for your question, please open the DFM files I stated with a text editor. If they are corrupted as well on your side, you HAVE TO fix that. The fact that you don't have more problems is the only quizzical thing.
If they looks fine, please post them (and don't be afraid too much about the confidentiality of DFM files)
0
magman5Author Commented:
thanks epasquier

I have decided to build a new project from scratch;  cut and past all elements of the old project.


0
Emmanuel PASQUIERFreelance Project ManagerCommented:
yes, if you don't have backup, that's the best thing to do.

For  backup, I use Cobian Backup v8 (it's free), that's perfect for saving directories incrementally, so excellent for source code. And a little lighter than using CVS or SVN.
0
magman5Author Commented:
To anybody that would like to help.

I have created a new application to (hopefully) get around the currupted DFM files.
I have cut and pasted from the old Form1 into a new Form1 in a different project and directory.

The same problems persist :

TForm1.Canvas1.MouseDown()  never executes
TForm1.MouseDown()  never executes

The new project is attached.

 I have commented out all references to other forms using //mmm
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
Where is the project ? if you have difficulties to attach files (some extensions are not allowed), post the PAS & DFM in code section of a message
0
magman5Author Commented:
I just read the fine print after the ADD FILE button.
Looks like this site does not support WINRAR (which is the file type I sent).
The site is not smart enough to simply send a message warning me. Sorry.

I just went to the trouble of creating a ZIp file and the www warned me that it will nto accept a .CFG file.

This site must belong to the government - it is such a hassle to use.
(or all the programmers do not use Delphi ?)

Not sure how to get aroud this apparently fundamental shortcoming ??
Should I rename it .txt then ask a helper to rename it ?
Suggestions anyone ?

Not sure why .RAR is not supported  - it is inexpensive, been around for a long time and I find it works better than WInZIP.

Suggestion ot the sit administrator : please support the.RAR data format. You ay even see fit to offer a convesion tool via the www ?

Try this ZIP archive.
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
cfg file is not necessary. just send dpr, pas and dfm
0
magman5Author Commented:
try this ZIP
XYZ-Edit2-Project.zip
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
you have this special windows message handler that is completely disrupting the normal behaviour of mouse events in your form window
If you comment it your problem will disappear
procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
begin
  inherited;                    // call the inherited message handler 
{  if M.Result = htClient then   // is the click in the client area?
     M.Result := htCaption;     // if so, make Windows think it's
                                // on the caption bar.
}
end ; // WMNCHitTest

Open in new window

0
Emmanuel PASQUIERFreelance Project ManagerCommented:
with this enabled, all your window surface is considered as the caption. including all non-windowed components (such as TImage) , and excluding the windowed components that receive their own mouse events (like the TEdit and TMemo)
0
magman5Author Commented:
epasquier - many thanks and take all the points.

I had included this code snippet a very long tme ago and never noticed its detrimental effect.

A dumb question. If I press Accept As Solution button above, do I get to include a comment like this ?
or do I need to Submit this comment first ?
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
when accepting the solution, you have the opportunity to add a comment, that only the selected expert will see. if You want to add a comment for everybody, you can post one even after the subject is closed
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.