Showing results 1 to 3 of 3

Thread: press button - change color

  1. #1
    Join Date
    22.10.2013
    Posts
    14

    Default press button - change color

    Hello all,
    PLEASE, SOMEONE CAN TELL ME WHAT IS BAD. I want to change the color of the button when I press this button. The steps that I followed are the nexts:

    1- I have created one screen called: Main_screen
    2- In this screen I have created a button: Button1.
    3- In Button1, I go to properties, VBA Macros I open the LeftClickUp and I select the proper Macro.
    4- I created the macro in the MacroList. The macro is called: LeftClickUp_Button1
    5- The text of the program in VBA is:

    Sub change_color()
    Dim myElem As Element
    Dim myScrn As DynPicture
    Set myScrn = thisProject.DynPictures.Item("Main_screen")
    If Not myScrn Is Nothing Then
    Set myElem = myScrn.Elements.Item("Button1")
    If Not myElem Is Nothing Then
    myElem.BackColor = RGB(89, 58, 12)
    End If
    myScrn.UpdateAll
    End If
    End Sub
    --------------------------------------
    Public Sub LeftClickUp_Button1(obElem As Element)
    ´Call subroutine
    change_color
    End Sub

    WHAT IS BAD? I can not achieve anything.
    Thanks a lot.

    Roberto

  2. #2

    Default Re: press button - change color

    Hi Roberto,

    Thanks for your post, and welcome to the forum!

    You can easily change the color of a button without writing a single line of code.

    Check out the property "dynamic color". You can link a variable here. The limit colors of that variable can be used for e.g. the background color.

    This can be a variable of the internal driver.

    When this is a boolean variable, you can link the variable at the button (as a press button or switch) and if needed, execute a function through the limit of the variable.

    Best regards,
    Mark

  3. #3
    Join Date
    22.10.2013
    Posts
    14

    Default Re: press button - change color

    OK.GOOD!

    Did it.

    Thanks.
    Last edited by rgv0021 : 28th October 2013 at 08:17

Similar Threads

  1. Replies: 5
    Last Post: 18th July 2014, 13:06
  2. Replies: 1
    Last Post: 7th June 2013, 16:14
  3. Button Press On Different Monitors
    By allmendinger in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 1
    Last Post: 25th October 2011, 05:46
  4. how to change text and color of invisible button
    By tanveerali in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 1
    Last Post: 14th February 2011, 00:09
  5. How to increment a variable on button press
    By matholton in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 8
    Last Post: 24th September 2008, 12:51

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •