From Clomosy Docs

No edit summary
No edit summary
Line 10: Line 10:
'''Code:'''<br>
'''Code:'''<br>
Now let's see the code part. Let's define the image variable. After that, let's create a field in the Form (AddNewImage) and add an image (SetImage).<br>
Now let's see the code part. Let's define the image variable. After that, let's create a field in the Form (AddNewImage) and add an image (SetImage).<br>
'''var'''
 
MyForm:TclForm;
:'''Base Syntax'''
testImg : TclImage;<br>
  var
'''begin'''
    MyForm:TclForm;
MyForm := TclForm.Create(Self);
    testImg : TclImage;
testImg:= MyForm.AddNewImage(MyForm,'testImg');
 
testImg.Align := alClient;
  begin
testImg.Height := 250;
    MyForm := TclForm.Create(Self);
testImg.Width := 300;<br>
    testImg:= MyForm.AddNewImage(MyForm,'testImg');
MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png');
    testImg.Align := alClient;
MyForm.AddNewEvent(testImg,tbeOnClick,'ShowMessage(<nowiki>''Background design..''</nowiki>);');
    testImg.Height := 250;
MyForm.Run;<br>
    testImg.Width := 300;
'''end;'''
   
    MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png');
    MyForm.AddNewEvent(testImg,tbeOnClick,'ShowMessage(<nowiki>''Background design..''</nowiki>);');
    MyForm.Run;
 
  end;
 
:'''TRObject Syntax'''
 
  var
    MyForm:TclForm;
    testImg : TclImage;
 
  {
    MyForm = TclForm.Create(Self);
    testImg= MyForm.AddNewImage(MyForm,'testImg');
    testImg.Align = alClient;
    testImg.Height = 250;
    testImg.Width = 300;
   
    MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png');
    MyForm.AddNewEvent(testImg,tbeOnClick,'ShowMessage(<nowiki>''Background design..''</nowiki>);');
    MyForm.Run;
 
  }
'''Output:'''<br>
'''Output:'''<br>
[[File:Image.png|frameless|450px]]
[[File:Image.png|frameless|450px]]

Revision as of 13:38, 13 February 2024

SetImage(TComponent, xImageFile)

Provides the ability to add images to the component.

TComponent : The variable name of the defined component is written.

xImageFile : You must add a string type url address to this field. You may encounter an error when the url address is not an image.


Code:
Now let's see the code part. Let's define the image variable. After that, let's create a field in the Form (AddNewImage) and add an image (SetImage).

Base Syntax
 var
   MyForm:TclForm;
   testImg : TclImage;
 
 begin
   MyForm := TclForm.Create(Self);
   testImg:= MyForm.AddNewImage(MyForm,'testImg');
   testImg.Align := alClient;
   testImg.Height := 250;
   testImg.Width := 300;
   
   MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png');
   MyForm.AddNewEvent(testImg,tbeOnClick,'ShowMessage(''Background design..'');');
   MyForm.Run;
 
 end;
TRObject Syntax
 var
   MyForm:TclForm;
   testImg : TclImage;
 
 {
   MyForm = TclForm.Create(Self);
   testImg= MyForm.AddNewImage(MyForm,'testImg');
   testImg.Align = alClient;
   testImg.Height = 250;
   testImg.Width = 300;
   
   MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png');
   MyForm.AddNewEvent(testImg,tbeOnClick,'ShowMessage(''Background design..'');');
   MyForm.Run;
 
 }

Output:
Image.png