Board index » cppbuilder » ShowModal Problem

ShowModal Problem

The following code in VCL-function ShowModal  can be found in Forms.Pas:

...
 if Visible or not Enabled or (fsModal in FFormState) or
    (FormStyle = fsMDIChild) then
    raise EInvalidOperation.Create(SCannotShowModal);
...

Calling ShowModal causes the exception to be raised, i.e. the logical
statement seems to return false.

Test:
Before calling ShowModal in c++ a similar construction evaluates
true:

   TMyForm* frm;
    bool result;
    frm = new TMyForme(Application);
   TFormState fst = frm->FormState;
    TFormStyle frmst = frm->FormStyle;
    if (        (frm->Visible) ||
                (!frm->Enabled) ||
                (frm->FormState.Contains(fsModal)) ||
                (frmst == fsMDIChild)
    ) result = false;
    else
      result = true;

   frm->ShowModal(); // Will often return with exception raised, but not always.

Question:
Is there a known problem in calling the VCL?
I just converted from CBuilder4 to CBuilder5.

Thanks for any response...

- Udo

 

Re:ShowModal Problem


I forgot :

the code is contained in a DLL which is exceuted via BC5.02 OWL app.

- Udo

Re:ShowModal Problem


Udo, is it not the case that when you call frm->ShowModal() it does that
check to see if it can set frm->FormState to include fsModal. If it is
raising an exception this means that the form is either 1) already visible
or 2) disabled or 3) its' state already contains fsModal.or 4) its'
FormStyle=fsMDIChild.

Quote
"Udo Piechottka" <ifmd.messdatensyst...@t-online.de> wrote in message

news:3C7EA9DF.A875B4F6@t-online.de...
Quote
> The following code in VCL-function ShowModal  can be found in Forms.Pas:

> ...
>  if Visible or not Enabled or (fsModal in FFormState) or
>     (FormStyle = fsMDIChild) then
>     raise EInvalidOperation.Create(SCannotShowModal);
> ...

> Calling ShowModal causes the exception to be raised, i.e. the logical
> statement seems to return false.

> Test:
> Before calling ShowModal in c++ a similar construction evaluates
> true:

>    TMyForm* frm;
>     bool result;
>     frm = new TMyForme(Application);
>    TFormState fst = frm->FormState;
>     TFormStyle frmst = frm->FormStyle;
>     if (        (frm->Visible) ||
>                 (!frm->Enabled) ||
>                 (frm->FormState.Contains(fsModal)) ||
>                 (frmst == fsMDIChild)
>     ) result = false;
>     else
>       result = true;

>    frm->ShowModal(); // Will often return with exception raised, but not
always.

> Question:
> Is there a known problem in calling the VCL?
> I just converted from CBuilder4 to CBuilder5.

> Thanks for any response...

> - Udo

Re:ShowModal Problem


Tom Byars schrieb:

Quote
> Udo, is it not the case that when you call frm->ShowModal() it does that
> check to see if it can set frm->FormState to include fsModal. If it is
> raising an exception this means that the form is either 1) already visible
> or 2) disabled or 3) its' state already contains fsModal.or 4) its'
> FormStyle=fsMDIChild.

Yes, that's true.
But prior I checked with the same funcionality via the c++ lines for the
same situation. The evalaution via c++ checked o.k. but the following
build-in check via Pascal/VCL checked false and raised the exception.
The seems to be a fault in the vcl runtime code in evaluation these vars.
I thought of a memory alignment problem.

Udo

Other Threads