Form doesn't react to events. Posibly related to how the form is created

hi there:

I have a form that doesnt react to events such as click, double click, etc the same applies if you add any other object to the form.

I have tryed all the obvious things, but i believe the problem could be linked to the way the form is created
But i m not sure, the following code shows how this form is created.


procedure showformwithprobs....
var
  f: Tform;
begin
    f := Tform.CreateParented(GetDesktopWindow);
    try
      f.ShowModal;
.....

thanks in advance for your help
JodiePAsked:
Who is Participating?
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.

kretzschmarCommented:
>    f := Tform.CreateParented(GetDesktopWindow);
why this way?

why not simple
f := Tform.Create(Application);


meikl ;-)

0
saravananvgCommented:
Hello sir,

  The code should have been

  f := TForm.Create(Self);
  f.ShowModal;
  f.free;

with regards,
padmaja.
0
JodiePAuthor Commented:
I can t:
If i use create(GetDesktopWindow) I get the error incompatible types Tcomponent and HWND and If i try create() I get the error not enoough actual paramenters

0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

JodiePAuthor Commented:
i also tryed with

f := TForm.Create(Self);
  f.ShowModal;
  f.free;

and it gives me the error undeclared identifier Self ( I m calling this form from a unit)

and also tryed:
f := TForm.Create(nil);
  f.ShowModal;
  f.free;

and it all works the same way that at the begining
Thanks


Jodie
0
JodiePAuthor Commented:
besides, there was areason for using createparented, when is it
necesary to use this?


THanks for your imput

Jo
0
Slick812Commented:
hello JodieP ??, Not sure what you are trying to do when you want to create a Form, , You do not say if your program has the TApplication as an intialized "Application" variable, , in other words, have you got a "Main Form" already created in your program when you are trying to create the new form? If you do, then I would use the same code that the delphi .DPR file uses to create a form -

Application.CreateForm(TForm1, Form1);

a button click below to show you -

procedure TForm1.but_ShowToolClick(Sender: TObject);
begin
if not assigned(Form2) then
  Application.CreateForm(TForm2, Form2);
Form2.Show;
end;


 = = = = = = = = = = = = =
you ask -->  "  there was areason for using createparented, when is it necesary to use this? "

The Delphi help for -
constructor CreateParented(ParentWindow: HWnd);
 says  -->  Creates and initializes a control as the child of a specified NON-VCL window.
In my way of thinking, you only use this to put a control ( probally not a form) on a "Window" client area, that is not in the TApplication (VCL) message path, a window created with something like "CreateWindow( )", or a system dialog box. The function "GetDesktopWindow" is leftover from way way back when the desktop was a window, it is no longer a window, and GetDesktopWindow returns a "Virtual" (not real) handle.
Can you give more information about  what you are trying to do, the properties of the new form, if they are different?
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
JodiePAuthor Commented:
Where to start?

The code you provided works, i m using the name of the created form  as a handle, (which doesnt really make any sense to me but works, so happy days)

"In my way of thinking, you only use this to put a control ( probally not a form) on a "Window" client area, that is not in the TApplication (VCL) message path, a window created with something like "CreateWindow( )", or a system dialog box. The function "GetDesktopWindow" is leftover from way way back when the desktop was a window, it is no longer a window, and GetDesktopWindow returns a "Virtual" (not real) handle.
Can you give more information about  what you are trying to do, the properties of the new form, if they are different?"
This makes sense in my app


Thanks for your help
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.