Editing Components Properties

Once you have placed a component on the screen, it is time to edit its properties. We will explain this on the Rounded Button component.

Lets put the Rounded Button component on the screen, like this :

Display Window

Now, we will resize it by clicking the lower right edge and dragging it to fit the desired dimension :

Resizing Rounded Button Component

As you resize the Rounded Button component, the appropriate Width and Height edit fields in the Object Inspector will be populated.

Now, we will change the caption text of the button, entering "Visual TFT" string in the Caption field of the Object Inspector :

Chaning Caption Text

This will result in changing the caption on the screen :

Chaning Caption Text

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!