Board index » delphi » Strange 1.0 Formstyle error

Strange 1.0 Formstyle error

I am trying to change form styles at run-time depending on INI values.
The code is as follows:

 if setup.hidecaption.checked then
   begin
    timeform.borderstyle := bsNone;
   end else
   begin
     timeform.borderstyle := bsSingle;
   end;

However, no matter what I try, the bsNone generates a 'Type Mismatch'
error from the compiler.  I can substitute bsSingle or bsDialog and
they work.

Can anyone explain my silly mistake?

Sean Cunningham
MSI Consulting Group

 

Re:Strange 1.0 Formstyle error


Quote
s...@alice.msiconsulting.com (Sean Cunningham) wrote:
>I am trying to change form styles at run-time depending on INI values.
>The code is as follows:

> if setup.hidecaption.checked then
>   begin
>    timeform.borderstyle := bsNone;
>   end else
>   begin
>     timeform.borderstyle := bsSingle;
>   end;

>However, no matter what I try, the bsNone generates a 'Type Mismatch'
>error from the compiler.  I can substitute bsSingle or bsDialog and
>they work.

>Can anyone explain my silly mistake?

Sean:

Not silly but subtle!

There are two bsNone constants. One is a TBorderStyle and the other is
a TFormBorderStyle. The type mismatch means that the compiler is
assuming you mean the wrong one. A typecast should fix it.

Best wishes

John Nurick

e-mail: j.nur...@dial.pipex.com
v-mail: <+44|0> 191 281 1306

Other Threads