kretzschmar
asked on
How to get Clicks on a form?
hi experts,
make a form, place a panel and a button on it
make a second form, place some edits on it
in the button onclick-event place following code:
with tform2.create(self) do
begin
borderstyle := bsnone;
align := alclient;
parent := panel1;
show;
end;
you will see, that the form is embedded into the panel,
and works properly
but, if i change the code as following
with tform2.create(self) do
begin
borderstyle := bssingle; <--change here
align := alclient;
parent := panel1;
show;
end;
then i am unable to click into an edit
so the question is, how to get a form with a border,
which has a panel as parent, to accept mouseclicks,
like a borderless form
meikl ;-)
make a form, place a panel and a button on it
make a second form, place some edits on it
in the button onclick-event place following code:
with tform2.create(self) do
begin
borderstyle := bsnone;
align := alclient;
parent := panel1;
show;
end;
you will see, that the form is embedded into the panel,
and works properly
but, if i change the code as following
with tform2.create(self) do
begin
borderstyle := bssingle; <--change here
align := alclient;
parent := panel1;
show;
end;
then i am unable to click into an edit
so the question is, how to get a form with a border,
which has a panel as parent, to accept mouseclicks,
like a borderless form
meikl ;-)
ASKER
>Have you considered drawing the border yourself?
hehe, no, madshi
i guess there must be another solution,
one would be to assign an onclick-event on each edit
to gain the focus to it, but also this is not for what i am after, should be more generic/general
meikl ;-)
hehe, no, madshi
i guess there must be another solution,
one would be to assign an onclick-event on each edit
to gain the focus to it, but also this is not for what i am after, should be more generic/general
meikl ;-)
ASKER
raising points a bit
Hi meikl,
This is not exactly what you are fooking for but try it and see if it's applicable for your needs.
Panel1.BorderStyle := bsSingle;
with TForm2.Create(self) do begin
borderstyle := bssizeable; //<--change here
Show;
ManualDock(Form1.Panel1);
end;
Regards, Geo
This is not exactly what you are fooking for but try it and see if it's applicable for your needs.
Panel1.BorderStyle := bsSingle;
with TForm2.Create(self) do begin
borderstyle := bssizeable; //<--change here
Show;
ManualDock(Form1.Panel1);
end;
Regards, Geo
Forgot:
Panel1.DockSite := true;
in the beginning.
Panel1.DockSite := true;
in the beginning.
ASKER
well, geo, i will try this evening,
but what the hell is fooking :-))
but what the hell is fooking :-))
Hi,
Docking mechanism is seem cool. But maybe here is some other opinion. You could use MDI mechanism.
Set TForm1.FormStyle property to fsMDIForm.
Set TForm2.FormStyle property to fsMDIChild.
And for the ButtonClick handler in TForm1 is:
With TForm2.Create (Self) do
begin
BorderStyle := bsSizeAble;
end;
Regards, Dewo
Docking mechanism is seem cool. But maybe here is some other opinion. You could use MDI mechanism.
Set TForm1.FormStyle property to fsMDIForm.
Set TForm2.FormStyle property to fsMDIChild.
And for the ButtonClick handler in TForm1 is:
With TForm2.Create (Self) do
begin
BorderStyle := bsSizeAble;
end;
Regards, Dewo
ASKER
thanks dewo, for your suggestion,
but i will avoid the mdi-mechanism,
as it may have some unwished side-effects
any other ideas?
but i will avoid the mdi-mechanism,
as it may have some unwished side-effects
any other ideas?
Hehe. Sorry, meikl. fooking = looking :-) (F isn't even close to L on my keyboard...)
Hi Meikl.
Thats wors but has a collateral effect.
Try and.....
procedure TForm1.Button1Click(Sender : TObject);
begin
with tform2.create(self) do
begin
borderstyle := bsSingle;
// borderstyle := bsnone;
align := alclient;
parent := panel1;
show;
end;
form2.Edit1.parent:=panel1 ;
ShowMessage(form2.Edit1.Te xt);
end;
Best Regards
Marcos.
Thats wors but has a collateral effect.
Try and.....
procedure TForm1.Button1Click(Sender
begin
with tform2.create(self) do
begin
borderstyle := bsSingle;
// borderstyle := bsnone;
align := alclient;
parent := panel1;
show;
end;
form2.Edit1.parent:=panel1
ShowMessage(form2.Edit1.Te
end;
Best Regards
Marcos.
ASKER
geo, maybe, if there is no better choice
not what i want, Marcos ;-)
any further suggestions?
not what i want, Marcos ;-)
any further suggestions?
Hi,
There is another way but it has disadvantages also:
- tab is limited inside the Form2
- Form2 can be moved within Panel1.
Perhaps these effects could be removed using some code in Form2 (the second one for sure, I think).
with TForm2.Create(self) do
begin
BorderStyle := bsSingle;
Left := 0;
Top := 0;
Height := Panel1.ClientHeight;
Width := Panel1.ClientWidth;
Windows.SetParent(Handle, Panel1.Handle);
Show;
end;
Regards, Geo
There is another way but it has disadvantages also:
- tab is limited inside the Form2
- Form2 can be moved within Panel1.
Perhaps these effects could be removed using some code in Form2 (the second one for sure, I think).
with TForm2.Create(self) do
begin
BorderStyle := bsSingle;
Left := 0;
Top := 0;
Height := Panel1.ClientHeight;
Width := Panel1.ClientWidth;
Windows.SetParent(Handle, Panel1.Handle);
Show;
end;
Regards, Geo
It's because there's no WM_SetFocus message generated and sent to the editbox - the mouse messages are getting through. I can't find out where a normal WM_SetFocus comes from (anyone know?). Is it handled by the standard Windows editbox message handler?
There's a similar-ish problem with ActiveX controls written in Delphi - when you embed them within Delphi or other applications. It think the TAB stops working properly then, but suspect it's related.
Not in the office for a couple of days, so won't be able to continue investigating.
Will watch with interest, in case someone else works out what's going on (or not!)
There's a similar-ish problem with ActiveX controls written in Delphi - when you embed them within Delphi or other applications. It think the TAB stops working properly then, but suspect it's related.
Not in the office for a couple of days, so won't be able to continue investigating.
Will watch with interest, in case someone else works out what's going on (or not!)
I'm just forced to ask why you want to do this without MDI.. MDI is the normal way to go about having multiple forms inside a single parent form.
Is there any particular reason you want the child form to have a border?
If you just want the close functionality (minimize and maximize are pointless since the form alignment is alClient) you could just put a toolbar on the top of the form with a button to the far right resembling a close button, and release the form when the button is clicked.
If you want just the border effect, you could get that with the panel or another panel on the child form beneath all the controls there.
If you don't want to use MDI, I would suggest you take one of two other approaches :
1) Create the controls at runtime.
Instead of creating the form at runtime, just create all the components that are on the form like editboxes, etc., and insert them onto the panel. If you want multiples of these "forms" you can use a tab control or something similar.
2) Create a new VCL control.
Create a TPanel decendant that has all of the controls you want on it, install it into your component palette and drop them onto your form as needed in place of the panels.
Is there any particular reason you want the child form to have a border?
If you just want the close functionality (minimize and maximize are pointless since the form alignment is alClient) you could just put a toolbar on the top of the form with a button to the far right resembling a close button, and release the form when the button is clicked.
If you want just the border effect, you could get that with the panel or another panel on the child form beneath all the controls there.
If you don't want to use MDI, I would suggest you take one of two other approaches :
1) Create the controls at runtime.
Instead of creating the form at runtime, just create all the components that are on the form like editboxes, etc., and insert them onto the panel. If you want multiples of these "forms" you can use a tab control or something similar.
2) Create a new VCL control.
Create a TPanel decendant that has all of the controls you want on it, install it into your component palette and drop them onto your form as needed in place of the panels.
ASKER
to geo,
yes thats really near what i want,
there are only resizing and and moving issues,
but this i could solve myself
to andrewjb,
i thought also that it must be something with the messages,
and a solution could be somekind of
message-catching and forwarding
i guess the window is like disbled and the messages are rejected because of this.
and yes, tabkey works
to asymmetric
>Is there any particular reason you want the
>child form to have a border?
just for interest, maybe useable for
some kind of app-design
>minimize and maximize are pointless since the form
>alignment is alClient
correct
>If you just want the close functionality (minimize and
>maximize are pointless since the form alignment is
>alClient) you could just put a toolbar on the top of the
>form with a button to the far right resembling a close
>button, and release the form when the button is clicked.
this won't be rendered with the current system-settings
>1) Create the controls at runtime.
then i don't need the ide, and have much to code
>2) Create a new VCL control.
should be a window (no panel, no frame)
well, further suggestions?
yes thats really near what i want,
there are only resizing and and moving issues,
but this i could solve myself
to andrewjb,
i thought also that it must be something with the messages,
and a solution could be somekind of
message-catching and forwarding
i guess the window is like disbled and the messages are rejected because of this.
and yes, tabkey works
to asymmetric
>Is there any particular reason you want the
>child form to have a border?
just for interest, maybe useable for
some kind of app-design
>minimize and maximize are pointless since the form
>alignment is alClient
correct
>If you just want the close functionality (minimize and
>maximize are pointless since the form alignment is
>alClient) you could just put a toolbar on the top of the
>form with a button to the far right resembling a close
>button, and release the form when the button is clicked.
this won't be rendered with the current system-settings
>1) Create the controls at runtime.
then i don't need the ide, and have much to code
>2) Create a new VCL control.
should be a window (no panel, no frame)
well, further suggestions?
You say the toolbar won't be rendered with current system settings.. could you explain this a bit further?
Also, could you please provide more information on why you don't want to use MDI?
I'm full out of suggestions outside of perhaps overriding a lot of the default handling of the properties of the TForm decendant (TForm1 in this case) so that changing the borderstyle won't change it's ability to receive mouseclicks, and I'm not even sure that will work.
Peter Below (TeamB, very prolific on usenet) doesn't know why this behavior happens either.. it just does.. and it's been this way for a couple of years at least.
Also, could you please provide more information on why you don't want to use MDI?
I'm full out of suggestions outside of perhaps overriding a lot of the default handling of the properties of the TForm decendant (TForm1 in this case) so that changing the borderstyle won't change it's ability to receive mouseclicks, and I'm not even sure that will work.
Peter Below (TeamB, very prolific on usenet) doesn't know why this behavior happens either.. it just does.. and it's been this way for a couple of years at least.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you are trying to simulate MDI windows, download this file http://www.torry.net/samples/samples/other/mddi.zip and check out the Topic of simulating MDIs.
ASKER
to asymmetric,
>You say the toolbar won't be rendered with current system >settings.. could you explain this a bit further?
well, the problem may xp, with its new style of the window-border and gadgets. to emulate this by code is too much work, since windows does this for you, also should be the look and feel also for other windows-os. thwerefore i will not determine which os is running and then decide how to paint somewhat. as stated, windows does this for you.
to lee,
simple and effective,
you are the new number one for this q
to dragonslayer,
interesting article, points also to lee's solution
and a bit more
any further suggestions?
>You say the toolbar won't be rendered with current system >settings.. could you explain this a bit further?
well, the problem may xp, with its new style of the window-border and gadgets. to emulate this by code is too much work, since windows does this for you, also should be the look and feel also for other windows-os. thwerefore i will not determine which os is running and then decide how to paint somewhat. as stated, windows does this for you.
to lee,
simple and effective,
you are the new number one for this q
to dragonslayer,
interesting article, points also to lee's solution
and a bit more
any further suggestions?
oh .. dunno how to do this on Linux, but I guess it has something similar (as they try to copy windows :)
ASKER
going to grade tomorrow
lee gets the points
additional i offer 150 points for geobul in a separate q
i'm open for further suggestions
(i've enough points, which i could share,
with someone for a working alternative)
meikl ;-)
lee gets the points
additional i offer 150 points for geobul in a separate q
i'm open for further suggestions
(i've enough points, which i could share,
with someone for a working alternative)
meikl ;-)
ASKER
thanks lee
geo watch out for your points
others may suggest further
meikl ;-)
geo watch out for your points
others may suggest further
meikl ;-)
Hi Meikl,
I'm sorry but I was on a business trip last two days. Lee's solution is great and I've already recorded it ;-) Thank you very much for the points you gave me.
Regards, Geo
I'm sorry but I was on a business trip last two days. Lee's solution is great and I've already recorded it ;-) Thank you very much for the points you gave me.
Regards, Geo
Sorry to say, but I'm currently not the time to check the problem out in depth. So just a dumb question from me: Have you considered drawing the border yourself? :-)
Regards, Madshi.