Bayesean Blog - Desktop, Mobile and IOT Developer Blog


Delphi A Professional VCL DBGrid Part Four

Posted on 13th Jun 2019 in Delphi VCL


part4header54.png

The Last in the series Part Four covers the following areas.

  • Progress bar single to multi-color 5 bar
  • Horizontal Stack Bar multi-colors

 Feel free to read part one, part two, part three

Progress bar single to multi-color

The progressbar procedure has the option of selecting up to 5 different colors. The procedure has many default settings which can easily be overridden to create a custom looking progressbar.

The standard settings allows maximum of 5 colors in its settings but can be easily adjusted to the minimum of one color.

The procedure has an overduebreakpoint and various breakpoint positions where the color of the progressbar will change color.

If no changes are added during usage then the defaults are automatically used.

In the procedure there are many adjustable settings that can be made which influence how the bar is visualised at run time. With few changes, a custom styled progress bar can be created.

Usage

Progressdrawcolumncell(Sender,dbgrid1,9,datacol,e,Rect,column,State,1);

Code

 

procedure Progressdrawcolumncell(sender:Tobject;grid:Tdbgrid;

  colpos,datacol,progressvalue: integer;

  Rect:Trect;column:Tcolumn;State: TGridDrawState;

  progressnumber:integer = 5;

  overduebreakpoint:integer = 1;

  breakpoint1:integer = 65;

  breakpoint2:integer = 40;

  breakpoint3:integer = 20;

  backgroundcolor:TColor = clgray;

  overduecolor:Tcolor=clwebFirebrick;

  Color1:Tcolor = clWebLightSkyBlue;

  Color2:Tcolor = clweborange;

  Color3:TColor = clWebGold;

  color4:Tcolor = clWebTomato;

  maxvalue:integer = 100;

  progresspadding:integer = 0;

  isbackground:boolean= false;

  showtext:boolean = true;

  Percentge:string = '%');

 The code for this procedure is many lines and can be found in the full code download.

 

Horizontal Stack Bar multi-colors

This is a stacked bar with up to five different colors. To initiate the colors, the formOncreate event is used to activate the bar. It uses a shape to draw each bar.  Select the color that the shape must take and a stacked bar is formed.

Usage

 

ColorhorizontalBarshape(shape1,clWebLightSkyBlue);

 ColorhorizontalBarshape(shape2,clWebLightSeaGreen);

 ColorhorizontalBarshape(shape3,clweborange);

 ColorhorizontalBarshape(shape4,clWebGold);

 ColorhorizontalBarshape(shape5,clWebTomato);

 Code

 

procedure ColorhorizontalBarshape(shape:Tshape;color:Tcolor);

  begin

  shape.Brush.Color:= color;

  shape.Pen.Style:= psClear;

  end;

 The stack Bar is drawn in the DBgrid onDrawColumncell event. Progress values for each shape must be added. The example uses random numbers to populate the chart, numbers from a Database can easily be incorporated into the chart. The maximum bars that can be added are five and minimum bar requirement is one.

The percentage can be changed from %e to any string item. Be aware that the bar would look best with a $ sign for value but the bar would become crowded if a long string name were used. There is the ability to not show any indicators in the bar.

Usage

HorizontalBardrawcolumncell(sender,dbgrid1,3,datacol,a,b,20,c,d,Rect,column,State,5);

 Code

 

procedure HorizontalBardrawcolumncell(sender:Tobject;grid:Tdbgrid;

  colpos,datacol,progressvalue1,progressvalue2,progressvalue3,progressvalue4,

progressvalue5: integer;

  Rect:Trect;column:Tcolumn;State: TGridDrawState;

  progressnumber:integer = 5; //min 1

  Color1:Tcolor = clWebLightSkyBlue;

  Color2:Tcolor = clWebLightSeaGreen;

  Color3:TColor = clweborange;

  color4:Tcolor = clWebGold;

  color5:Tcolor = clWebTomato;

  maxvalue:integer = 100;

  progresspadding:integer = 0;

  isbackground:boolean= false;

  showtext:boolean = true;

  Percentge:string = '%');

 The lengthy code for this can be viewed in the example download.

 Code Repository

Feel Free to download the code that covers all four parts here

 

Download Code


Enrico      Commented   1 year ago Reply

I'm trying to study your interesting example but I can not configure the server section (SLIM). In WAMP I created a PhpSlimAuth folder and unzipped the PHPSlimRestServer.zip file. The path is c:\wamp\www\ PhpSlimAuth and to test the server use http://localhost/PhpSlimAuth/public/user but I get the error Fatal error: Interface 'Interop \ Container \ ContainerInterface' not found in C: \ wamp \ www \ PhpSlimAuth \ vendor \ slim \ slim \ Slim \ Container.php online 46 You can help me understand where is the error ?

Greg Bayes      Replied   1 year agoReply


Hi thanks for your interest in this. I will look into why this is not working and will establish which blog you are referring to and try to adjust this to the correct blog if it is possible.

Greg Bayes      Replied   1 year agoReply


Hi thanks for your interest in this. I will look into why this is not working and will establish which blog you are referring to and try to adjust this to the correct blog if it is possible.

Enrico      Commented   1 year ago Reply

Sorry I put my question in not correct article !!!

Hi Enrico      Replied   1 year agoReply


I will reallocate this to the correct blog. I will test this on my rest server to see if I get the same issue than I will try and trouble shoot your problem.

Greg Bayes      Replied    Moderator   1 year agoReply


Hi Enrico I see that a link had broken in Slim 3. I updated Slim 3 in github and deleted test code line in JWT.php. All works now. The public Index.php on load should show "Page not Found". Once this is working then you will be able to make local rest calls to the WAMP server. I hope this solves the issue. Regards Greg

Enrico      Commented   6 months ago Reply

I Greg I returned !!! I can't running your exemple ... I created a PhpSlimAuth in my wamp dir : C:\wamp\www\PhpSlimAuth I unzipped your PHPSlimRestServer dir in PhpSlimAuth dir the tree is : Directory di C:\wamp\www\PhpSlimAuth > middleware > public > routes > vendor In public dir there isn't .htaccess file is normal ??? In pas source I altered your http.Get('http://private.localhost/htdoc/PhpSlimAuth/public/user') in http.Get('http://localhost/PhpSlimAuth/public/user') to fit your example path Your VCL Example (Client CRUD INDY Authentication ) return me 404 error If I put in public dir a basic .htaccess ( RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] ) and I activate the SLIM debugger I have this error : Fatal error: Uncaught exception 'BadMethodCallException' with message 'Method config is not a valid method' in C:\wamp\www\PhpSlimAuth\vendor\slim\slim\Slim\App.php on line 126 ( ! ) BadMethodCallException: Method config is not a valid method in C:\wamp\www\PhpSlimAuth\vendor\slim\slim\Slim\App.php on line 126 Can You provide me a running SLIM / EXAMPLE dir for testing you very interesting example ? Thanks in advance Enirco

Add a Comment

9+5

Recent News

Delphi A Professional VCL DBGrid Part Four
Delphi A Professional VCL DBGrid Part Three
Delphi A Professional VCL DBGrid Part Two
Delphi A Professional VCL DBGrid Part One
Delphi VCL Buttons in DBGrid
Two Helper Apps for Delphi LibUSB
Delphi Libusb Library Introduction
Delphi Object directly to a Json string in a REST Client

Categories

Bootstrap 4
Delphi VCL
Delphi FMX
Ajax
Bootstrap 3
CSS
XE4>Delphi > XE4
Delphi < XE4
PHP

Archives

June 2019

Delphi A Professional VCL DBGrid Part Four

May 2019

Delphi A Professional VCL DBGrid Part Three

April 2019

Delphi A Professional VCL DBGrid Part Two

March 2019

Delphi A Professional VCL DBGrid Part One

November 2018

Delphi VCL Buttons in DBGrid

October 2018

Two Helper Apps for Delphi LibUSB

September 2018

Delphi Libusb Library Introduction

August 2018

Delphi Object directly to a Json string in a REST Client
Delphi using Environment Variables in your App

July 2018

Delphi FMX Leaflet Plotter using OSM Maps

June 2018

C2PAS32 Convertor Application
C to Delphi Open Source Convertors Shootout
Delphi command-line programs with DOSCommand

May 2018

Delphi PDF Embedded viewer with PDF.js

March 2018

Delphi FMX - Changing TCharacter to TCharHelper
Make Your Delphi App POP using Javascript!

January 2018

Delphi FMX Dashboard using Chart.JS
Delphi FMX Form Docking

December 2017

PHP Slim REST Server & Delphi Auth Part 5

November 2017

Delphi FMX REST Client App Part 4

October 2017

Delphi VCL REST Pricing Client App Part 3

September 2017

Delphi REST VCL Client Basic Auth Part 2B

August 2017

Delphi REST Client Part 2A
PHP PDO REST Server Part 1

July 2017

PHP REST Server and Delphi Client Intro

June 2017

Delphi SQLite Encryptor-Decryptor Tool
Updating Applications Manifest using Delphi

May 2017

Create a Visual IP Address Geolocation with PHP

March 2017

PHP Downloader using Countdown timer
PHP File Downloader from a Inbox Selection

February 2017

Javascript Image-File Uploader with ThumbViewer

January 2017

Morris Charts and PHP-PDO

December 2016

CSS to create a functional Toggle Button