System Colors Handling

Written by Jose A. Becerril

The example:

  • Creates a standard Visual Prolog Task window with three buttons and two menu items.
  • The menu items produce a window and a dialogue with a colored background.
  • Two buttons change a part or all the colors in the Windows system.
  • The third button restores all colors to their original state.
  • A "safety device" restores colors if you close the application. (In any case, the changes are only permanent until log off or reboot).

What you can experiment: (in colores.pro)

  • Call Windows APIs using : 
resolve
     getSysColor    externally ,
     setSysColors   externally
  • Check the way I use an API, which originally points to two arrays:
showColour([H|T]):-
        H=pair(Item,Colour),
        Punto = memory::allocHeap(sizeOfDomain(binary)),
        BI = uncheckedConvert(binary, Punto),
        binary::setIndexed_integer32(BI, 0,Item),
         Value= uncheckedConvert( core::integer32, BI ),
   % ......................................................................................
  Punto2 = memory::allocHeap(sizeOfDomain(binary)),
                BI2 = uncheckedConvert(binary, Punto2),
  binary::setIndexed_integer32(BI2, 0,Colour),
  Value2 = uncheckedConvert( core::integer32, BI2 ),
                   setSysColors(1,Value,Value2)=TOK,
     TOK<>0,
      showColour(T),!.
  • See how to call a window or a dialog changing a background color (in NewWindows pinkWindow.pro)
clauses
        onUpdate(Rectangle) = defaultHandling():-
        vpi::winClear( thisWin,Rectangle,0xFF80FF),!.
  • See how to get the original color values and store them in a dba  to recover them later. (in store.pro).
storing_Colour: colores::pairList:=[].

Download the project

Note

The example requires Visual Prolog 7.3 Commercial or Personal Edition.

Users of previous versions of Visual Prolog are welcome to upgrade to the current version of Visual Prolog  to use the latest versions of the Visual Prolog examples.

Use the WEB|Check for Update IDE menu command for upgrade information.

Home | Company | News | ProductsDownloads | Shop | Support | Visual Prolog Features | Visual Prolog Compiler | FAQ | Tutorials | Examples | Knowledge Base | Discussion Forum | wiki | Site Map

Prolog Development Center A/S - H.J. Holst Vej 3-5C - 2605 Broendby, Denmark - Tel +45 3636 0000 - Fax +45 3636 0001 - sales@visual-prolog.com