Consultor Eletrônico



Kbase P165603: How to display a color dialog in a GUI for .NET form
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   07/05/2010
Status: Unverified

GOAL:

How to display a color dialog in a GUI for .NET form

GOAL:

How to add a color picker to a GUI for .NET application

GOAL:

How to allow the user to control the colors of GUI for .NET forms and controls

GOAL:

How to use System.Windows.Forms.ColorDialog to provide color choices to the application user

FACT(s) (Environment):

Windows
OpenEdge 10.2x

FIX:

The familiar Windows Forms color dialog can be provided to users of GUI for .NET applications by including a System.Windows.Forms.ColorDialog object. The following example code allows the user to change the background color of a button by clicking it:/* Define a Button object and a ColorDialog object in the form variables */

DEFINE PRIVATE VARIABLE button1 AS System.Windows.Forms.Button NO-UNDO.
DEFINE PRIVATE VARIABLE colorDialog1 AS System.Windows.Forms.ColorDialog NO-UNDO.

/* Initialize the button color in the form constructor */
button1:BackColor = System.Drawing.Color:LightSkyBlue.


...

/*
This is the button's Click event handler.
Show the color dialog when a button is clicked by the user. Set the background color of the
button to this color
*/

METHOD PRIVATE VOID button1_Click(
INPUT sender AS System.Object, INPUT e AS System.EventArgs ):

/* Always use WAIT-FOR to show a .NET dialog in ABL */
WAIT-FOR THIS-OBJECT:colorDialog1:ShowDialog().

button1:BackColor = colorDialog1:Color.
RETURN.

END METHOD.