Link to home
Start Free TrialLog in
Avatar of shaneholmes
shaneholmes

asked on

Couple MDI Form Questions.


I have a main form application which is creating and showing froms (mdiChild) i.e. runtime

mdiChild forms have no border and should be maximized in the only portion of the main form available (left open).

I can only have one form created and shown at a time.
 
1st Question:

When I go to create and show a mdiChild form, how can I check for a current MDIChild that is created and shown. if there is one, destroy it and then create and show my new mdiChild form.

2nd Question:

When I create and show a mdiChild form (border = none, windowState = wsMaximized), it seems that it is creating and showing the child form with the border, then the border goes away. I can see it all visually. Is there a way to prevent this?


Shane
Avatar of kretzschmar
kretzschmar
Flag of Germany image

>1st Question:

if mdichildcount = 0 then
  //create
else
  showmessage('Close First');

>2nd Question:

this is a normal bahaviour.
you could lock the mainform-canvas
with lockwindowupdate()

meikl ;-)

Avatar of shaneholmes
shaneholmes

ASKER

meikl, OK, how do I tell which one is first, and how to free it,

is it  -  MDIChildren[1].free or MDIChildren[0].free - if there is only one form created and opened?

Shane
Ah, i figured it out!

MDIChildren[0].free

Shane
if you can have only one,
then the mdiChildcount can only pending between 0 and 1,
therefore you can't have two at a time
-> should check before creating a child

but if i remember right, new childs are inserted at place 0,
so the oldest should have the highest index -> will check this

usual i prefer to use the release-method instead of free,
if you have assigned a onClose-proc with a closeaction= cafree in your childs, you can also simple use the close-method

will be back after my check

meikl ;-)
>so the oldest should have the highest index -> will check this

checked and confirmed
->the oldest child have the highest index

meikl ;-)
  kretzschmar,

  This doesn't seem to work, am i calling it wrong?

 Shane
 
     frmAF0:= TfrmAF0.Create(Application);
     LockWindowUpdate(frmAF0.Handle);
     frmAF0.Show;
     LockWindowUpdate(0);

This is what I am using. I have a ListView with Items. I create my child forms in the ListView's OnSelectItem Event

if mdichildcount = 0 then
 begin
  case Item.Index of
  0:begin
     frmAF0:= TfrmAF0.Create(Application);
     LockWindowUpdate(frmAF0.Handle);
     frmAF0.Show;
     LockWindowUpdate(0);
  { 1:}
    end;
 end;
 end
else
 MDIChildren[0].free;


Shane
IM sorry, the LockWindowUpdate doesn't seem to work, everything else seems to work just fine!

Shane
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ahhhhhhhh, lock the main form (duh..what a dufus i am).


Your right, im explicitly calling free anyways, so no need to create it as part of Application, i can create it nil - right!

Shane
i would use self, but well its just a style-question
Kool - Thanks! I may need ya again down the road, cause I've never done any MDI apps before!

This actually started out as part of the question I asked yesterday about packages. I decided to go this route instead.

I had a TPageControl on my form - which would have eventually had 60 pages. Each page has at an average of 10 labels and 10 comboboxes

A WHOLE SH*T load of Handles hah?

I am trying the MDI route, where I explicity create each form when needed.

It seems this may work as i need it to.

Shane
glad to helped you :-))

see you

meikl ;-)