×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Change background color of a button or rectangle using Clarion 4

Change background color of a button or rectangle using Clarion 4

Change background color of a button or rectangle using Clarion 4

(OP)
Hi, I am using Clarion 4 and hope someone can help me!

I'm trying to draw rectangles or buttons on the screen, and then randomly change the background or fill color.  I have tried to do this, but can't get the colors to change on a hand-coded project.

My code:

 Program
 ! global declarations
 include('equates.clw')
 map !begin defining prototypes
main procedure
 end !prototypes

 code !begins here
 main !is called
 return !to OS
main procedure !defined
 ! local definitions
WinOne    WINDOW,AT(0,0,400,400),auto

b1                    Box,use(?b1),AT(100,100,20,20)
b2                    box,use(?b2),AT(140,140,20,20)
b3                    box,use(?b3),AT(180,180,20,20)
                    button,at(190,190,20,20)
                END
c long(0)
 code !for main procedure goes here

 open(winone)

 accept
 case event()
  of event:selected
  message(c)
   c=random(0,00ffffffh)
   message(c)
   ?b1{prop:fill} = c
   c=random(0,00ffffffh)
   message(c)
   ?b2{prop:fill} = c
   c=random(0,00ffffffh)
   message(c)
   ?b3{prop:fill} = c
     display
  .
 .

 return     !main procedure ends



Can anyone help?

RE: Change background color of a button or rectangle using Clarion 4

Hi!

Are your message being displayed? Once or repeatedly? A better way to test would be to change colors based on a button press i.e.

CODE

WinOne    WINDOW,AT(0,0,400,400),auto
                      Box,use(?b1),AT(100,100,20,20)
                      box,use(?b2),AT(140,140,20,20)
                      box,use(?b3),AT(180,180,20,20)
                      button,at(190,190,20,20),use(?Button1)
                END
c long(0)

 code !for main procedure goes here

 open(winone)
 
 ACCEPT
  CASE EVENT()
  OF EVENT:Accepted
    CASE ACCEPTED()
    OF ?Button1
      message(c)
      c = random(0,00ffffffh)
      message(c)
      ?b1{prop:fill} = c
      c = random(0,00ffffffh)
      message(c)
      ?b2{prop:fill} = c
      c = random(0,00ffffffh)
      message(c)
      ?b3{prop:fill} = c
      display()
    END
  END
 END

Now every time you press the button the colors should change.

Regards

 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close