GUI ScreenIO for Windows

 ScreenIO.com


ChooseColor

The ChooseColor API launches the Choose Color common dialog which allows the user to select one colors from the standard windows dialog. 

The use of the ChooseColor API is beyond the scope of a typical GUI ScreenIO application.  ChooseColor is used by the GUI ScreenIO panel editor but is of limited use to you in your application, since you can't change colors in this method on-the-fly.   Use the Named Color Table to change colors of controls at run time instead of this api.

This may be useful for selecting colors for print items if you are doing low-level printing.

See the Microsoft Windows documentation if you intend to use this API.

Client/Server issues

No issues; this API will behave as if it were running locally on the client.

Files

Files available to copy to your system:

Usage

 

 

           COPY WIN32API.
           COPY CHOOSCLR.

           MOVE mymain-HINSTANCE TO CHOOSECOLOR-HINSTANCE.
           MOVE mypanel-HWND TO CHOOSECOLOR-HWNDOWNER.
      *
      * ------------------------: Set the flag bits by adding the
      *                         : values, giving CHOOSECOLOR-FLAGS.
      *                         : These are the useful ones.
      *
      *                         : Initializes selection to that passed
      *                     CC-RGBINIT               VALUE H'00000001'.
      *                         : Offers only nondithered colors
      *                     CC-SOLIDCOLOR            VALUE H'00000080'.
      *                         : Offers all colors
      *                     CC-ANYCOLOR              VALUE H'00000100'.
      *                         : Displays controls for custom colors
      *                         : (no need to press the button)
      *                     CC-FULLOPEN              VALUE H'00000002'.
      *                         : Prevents use of custom colors button
      *                     CC-PREVENTFULLOPEN       VALUE H'00000004'.
      *
           ADD CC-RGBINIT
               CC-SOLIDCOLOR
               CC-FULLOPEN
               GIVING CHOOSECOLOR-FLAGS.

           SET API-CHOOSECOLOR TO TRUE

      * ------------------------: Call the GUI ScreenIO API routine:
      *
           CALL 'GSWINAPI' USING WIN32API-PARMS
                                 CHOOSECOLOR-PARMS
                                 CHOOSECOLOR-CUSTOMCOLORS
                                 WIN32API-C
                                 WIN32API-D
                                 WIN32API-E
                                 WIN32API-F.

           IF WIN32API-FAILED
             do no-color-found
           ELSE
             color specifications are returned... 

Parameters specific to this function

CHOOSECOLOR-HINSTANCE

Instance handle of your application, from your main panel.

CHOOSECOLOR-HWNDOWNER

Handle of the owner window; panel-HWND.  (Can be low values)

CHOOSECOLOR-FLAGS

Flags used to initialize the COLOR dialog box.

A combination of bit flags that specify various options used to initialize the common dialog. 

You OR these values to specify the bit values used for CHOOSECOLOR-FLAGS.  You can ADD them together as shown in the code sample above.

Flag Value Description
CC-RGBINIT 1h Initializes the selected color to what was passed in.  Otherwise Black is usually selected.
CC-SOLIDCOLOR 80h Shows only solid colors (not dithered).
CC-ANYCOLOR 100h Allows use of the Customized Color portion of the dialog.
CC-FULLOPEN 2h Automatically displays the Custom Color portion of the dialog without the user needing to select it
CC-PREVENTFULLOPEN 4h Prevents the option to open the custom color dialog.

CHOOSECOLOR-RGBRESULT

This is the selected four byte color value that the user chose.  This color is IN WINDOWS NATIVE FORMAT AND MAY NOT BE USES TO CHANGE THE COLOR OF GUI SCREENIO FIELDS.

CHOOSECOLOR-CUSTOMCOLORS

An array of up to 16 custom colors that your user pre-configured.  If you retain this area, this same list of custom colors will be offered upon the next display of the dialog box.

WIN32API-PARMS - Used in all GSWINAPI calls

This argument is standard for all CALLs to GSWINAPI. It is used to select the desired API or function, and to return the status of the operation.

WIN32API-RC

Used to return the status of a call to GSWINAPI.  A value of zero is a failure, any other value indicates success.

Recommended usage is to test the 88-level value WIN32API to see if it worked, then to use the text error message to see why it failed.

* ------------------------: If function failed,
*                         :   display the error in a message box.
*
     IF WIN32API-FAILED
       MOVE WIN32API-ERROR-TEXT TO panel-MESSAGE-TEXT
       SET panel-MESSAGE-IN-MESSAGEBOX TO TRUE.

WIN32API-ERROR-CODE

Error code that was returned by Windows.  This is not generally useful unless you have the Windows Platform SDK documentation available to you.

WIN32API-ERROR-TEXT

Plain-text error message that describes why the operation failed.

WIN32API-A through WIN32API-F

The number of these present varies depending on how many arguments are used by the desired function.  These are not used, but must be present because this CALL requires seven arguments.


© 2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom