• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

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
0
JodieP
Asked:
JodieP
1 Solution
 
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now