dr_gonzo
asked on
MDI-parent caption
How do I get caption on and MDI-child's parent window?
I've tried
TForm(myForm.Parent).Capti on
but TForm(myForm.Parent) returns nil. Why?
SHouldn't a MDI-childs parent be set to the hWnd of it's MDI-parent???
I've tried
TForm(myForm.Parent).Capti
but TForm(myForm.Parent) returns nil. Why?
SHouldn't a MDI-childs parent be set to the hWnd of it's MDI-parent???
MyForm.Parent returns a Twincontrol, it does not include the information about Caption. So you cast it to TForm, this TForm.Caption is nil, it's normal.
if you want to get the mainform's caption, you needn't use Parent property. In your child form unit, you add a uses clause
to allow you directly use mainform. for example:
mainform unit name:main.pas
var
mainform:TMainForm;
.
in your child form unit file:
.
implementation
uses main;
.
// str:=TForm(MyForm.Parent). Caption;
// change to:
str:=mainform.caption;
.
Everything will ok!
if you want to get the mainform's caption, you needn't use Parent property. In your child form unit, you add a uses clause
to allow you directly use mainform. for example:
mainform unit name:main.pas
var
mainform:TMainForm;
.
in your child form unit file:
.
implementation
uses main;
.
// str:=TForm(MyForm.Parent).
// change to:
str:=mainform.caption;
.
Everything will ok!
ASKER
To Jaccu:
Nop same problem the caption is by Delphi said to be ''. Read buboi's comment to see why.
To Buboi:
That's what I would have done, but I'm writing a component which need's eighter the owner's caption (if it is a non-MDI) or the owner's parent (if it is MDI) so it is impossible to use USES in this case, any other clues?
Nop same problem the caption is by Delphi said to be ''. Read buboi's comment to see why.
To Buboi:
That's what I would have done, but I'm writing a component which need's eighter the owner's caption (if it is a non-MDI) or the owner's parent (if it is MDI) so it is impossible to use USES in this case, any other clues?
ASKER
Hmm by the way. If it was a cast-problem why don't this work:
Self.Parent
It also returns nil.
Is the property I'm looking for owner?????
I'm getting more and more confused. I thought I knew Delphi quite well.
Self.Parent
It also returns nil.
Is the property I'm looking for owner?????
I'm getting more and more confused. I thought I knew Delphi quite well.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yepp!
Two other options:
1)
Application.MainForm.Capti on := 'My new caption'
2)
for iForm:=0 to Screen.FormCount-1 do
for iChild:=0 to Screen.Forms[iForm].MDIChi ldCount-1 do
if Screen.Forms[iForm].MDIChi ldren[iChi ld]=Self then
Screen.Forms[iForm].Captio n:='Hallo' ;
Regards Jacco
1)
Application.MainForm.Capti
2)
for iForm:=0 to Screen.FormCount-1 do
for iChild:=0 to Screen.Forms[iForm].MDIChi
if Screen.Forms[iForm].MDIChi
Screen.Forms[iForm].Captio
Regards Jacco
Regards Jacco