ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Color Randomizer

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Apr 14 2021 : 18:18:21
Here I show how to transform the TIEColorButton into a "Color Randomizer":

type
  TMyIEColorButton = class(TIEColorButton)
    protected
      procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
  end;
  TIEColorButton = class(TMyIEColorButton);

implementation

procedure TMyIEColorButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Form1.IEColorButton1.SelectedColor := RGB(Random(256), Random(256), Random(256)); 
end;


This saves the user a lot of work: Namely, to manually select a color in the color picker. He just has to click the button until he gets a color that he likes! ;-)
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 16 2021 : 18:25:49
Hi Peter

That is correct. Though you should also handle key presses by overriding KeyUp in the same way.



Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Apr 15 2021 : 06:13:20
Hi Nigel,

thanks for the hint. So the code would be:

type
  TMyIEColorButton = class(TIEColorButton)
    protected
      procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
  end;
  TIEColorButton = class(TMyIEColorButton);

implementation

procedure TMyIEColorButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Tag = 999 then // restrict randomness to a specific IEColorButton
    SelectedColor := hyieutils.IERandomColor 
  else
    inherited;
end;


Is this correct?
xequte Posted - Apr 15 2021 : 05:57:31
Hi Peter

You can also use this method in hyieutils.pas

function IERandomColor(PastelSet: Boolean = False): TColor;

Nigel
Xequte Software
www.imageen.com