Setting Component Properties From The Code

To set the desired properties from the code, you should write the following code in the Event Handler Routine :

mikroC Code

ComponentName.Property = Value;

mikroPascal Code

ComponentName.Property := Value;

mikroBasic Code

ComponentName.Property = Value

For example, you can change these properties :

mikroC Code

void Image1Click() {
  Image1.Left               = 7;
  Image1.Top                = 9;
  Image1.Width              = 107;
  Image1.Height             = 50;
  Image1.PictureWidth       = 100;
  Image1.PictureHeight      = 50;
  Image1.PictureName        = &mE;
  Image1.Visible            = 1;
}

mikroPascal Code

procedure Image1Click();
begin
  Image1.Left               := 7;
  Image1.Top                := 9;
  Image1.Width              := 107;
  Image1.Height             := 50;
  Image1.PictureWidth       := 100;
  Image1.PictureHeight      := 50;
  Image1.PictureName        := @mala;
  Image1.Visible            := 1;
end;

mikroBasic Code

sub procedure Image1Click()
  Image1.Left_              = 7
  Image1.Top                = 9
  Image1.Width              = 107
  Image1.Height             = 50
  Image1.PictureWidth       = 100
  Image1.PictureHeight      = 50
  Image1.PictureName        = @mala
  Image1.Visible            = 1
end sub

NoteGeneral Note

Bear in mind that when changing component properties, it is necessary to call an appropriate drawing routine in order to apply these changes.

NoteMaxLength Note

Concept for working with captions is made to minimize used memory. If caption won't be changed, MaxLength property should be set to 0. In this case allocated memory size corresponds to Caption length.

If Caption will be changed from project code, MaxLength property should be set to maximum possible Caption length. In this case Componentname_Caption variable should be used for working with caption.

This variable is introduced to enable easier coding, pointer mechanism takes care of updating actual ComponentName.Caption variable.

Copyright (c) 2002-2017 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!