Recent

Author Topic: custom component with different properties  (Read 642 times)

Espectr0

  • Full Member
  • ***
  • Posts: 221
custom component with different properties
« on: March 27, 2023, 01:20:37 am »
Hola,

is it possible to make a component that has certain properties in windows and not in macos?

and when loading the project in macos the error "property not found..." does not appear?

Would we have to modify the lfm every time?


thanks

jamie

  • Hero Member
  • *****
  • Posts: 6735
Re: custom component with different properties
« Reply #1 on: March 27, 2023, 01:31:38 am »
you can simply put a dummy property in there.

 in code you can use some compiler test to check for the OS being targeted and decide not to include code.
 At least that way you won't have that problem.

 This is why they make widget interfaces.
The only true wisdom is knowing you know nothing

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: custom component with different properties
« Reply #2 on: March 27, 2023, 01:44:22 am »
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. type
  4.   TMyString = class
  5.     strict private
  6.       FString: string;
  7.     published
  8.       {$IFDEF MSWINDOWS}
  9.       property MyString: string read FString write FString;
  10.       {$ENDIF}
  11.   end;
  12.  
  13. var
  14.   MyString: TMyString;
  15. begin
  16.   MyString := TMyString.Create;
  17.   try
  18.     // the next line works exclusive under windows
  19.     // all other OS do not have the "MyString" property
  20.     MyString.MyString := 'Some string';
  21.   finally
  22.     MyString.Free;
  23.   end;
  24. end.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

jamie

  • Hero Member
  • *****
  • Posts: 6735
Re: custom component with different properties
« Reply #3 on: March 27, 2023, 01:46:56 am »
and what happens when you move the project to MACos ?

The Lfm file still contains a property name that could of been set in the windows target.
The only true wisdom is knowing you know nothing

Espectr0

  • Full Member
  • ***
  • Posts: 221
Re: custom component with different properties
« Reply #4 on: March 27, 2023, 10:01:12 am »
I think one of the most practical solutions could be to move the properties from "published" to "public" with their conditionals and thus they would not be saved in the lfm.

 

TinyPortal © 2005-2018