Skip to main content

Problem:

MS APIs

--> SetSysColors: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsyscolor.asp

--> GetSysColor

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsyscolor.asp

--> Color Table, RGB's values:

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/colors/colors.asp

Resolution:

Paste of COBOL code ( attached to KB ):

      $set case

       copy "windows".

       identification division.

       special-names.

           call-convention 74 is STDCALL.

       working-storage section.

       78 RGBlightGrey   value x"C0C0C000".

       78 RGBwhite       value x"FFFFFF00".

       78 RGBfuchsia     value x"FF00FF00".

       78 RGBdeepskyblue value x"00BFFF00".

       78 RGBlavender    value x"E6E6FA00".

       78 RGBblanchedalmond value x"FFEBCD00".

       01 b bool.

       01 RGB-RedGreenBlue DWORD.

       01 RGB-BTNFACEinitial DWORD.

       01 RGB-WINDOWinitial  DWORD.

       01 RGB-MENUinitial    DWORD.

       01 RGB-MENUTEXTinitial    DWORD.

       *>

       01 MSCOLORREF is typedef.

           03 red      pic x comp-5.

           03 green    pic x comp-5.

           03 blue     pic x comp-5.

           03 leadByte pic x comp-5.

       01 nIndex       int.

       01 rgb  MSCOLORREF.

       78 V1 value 1.

       01 cElements    int value V1.

       01 lpaElements.

           02 anElement int occurs V1.

       procedure division.

           call "COB32API"

           move COLOR-BTNFACE to nIndex

           perform doGetSysColor

           move RGB-RedGreenBlue        to RGB-BTNFACEinitial

               move RGBlightGrey to rgb

               move COLOR-BTNFACE to anElement(cElements)

               perform doSetSysColor

                   move RGB-BTNFACEinitial          to rgb

                   perform doSetSysColor

           move COLOR-WINDOW to nIndex

           perform doGetSysColor

           move RGB-RedGreenBlue        to RGB-WINDOWinitial

               move RGBwhite to rgb

               move COLOR-WINDOW to anElement(cElements)

               perform doSetSysColor

               move RGBblanchedalmond to rgb

               perform doSetSysColor

                   move RGB-WINDOWinitial to rgb

                   perform doSetSysColor

           move COLOR-MENU to nIndex

           perform doGetSysColor

           move RGB-RedGreenBlue        to  RGB-MENUinitial

               move RGBlavender to rgb

               move COLOR-MENU to anElement(cElements)

               perform doSetSysColor

                   move  RGB-MENUinitial to rgb

                   perform doSetSysColor

           move COLOR-MENUTEXT to nIndex

           perform doGetSysColor

           move RGB-RedGreenBlue        to  RGB-MENUTEXTinitial

               move RGBdeepskyblue to rgb

               move COLOR-MENUTEXT to anElement(cElements)

               perform doSetSysColor

                   move  RGB-MENUTEXTinitial to rgb

                   perform doSetSysColor

           exit program.

           stop run.

       doSetSysColor.

      *    perform RGBdisplay

           call STDCALL SetSysColors

                       using by value     cElements

                             by reference lpaElements

                             by reference rgb

                       returning b

           if b = 1FALSE display "*--> " SetSysColors " KO" end-if

           .

       doGetSysColor.

           initialize RGB-RedGreenBlue

           call STDCALL GetSysColor

                       using by value nIndex

                       returning RGB-RedGreenBlue

           move RGB-RedGreenBlue   to rgb

      *    perform RGBdisplay

           .

      *RGBdisplay.

      *   display "*--> Red:      " Red      of rgb

      *   display "*--> Green:    " Green    of rgb

      *   display "*--> Blue      " Blue     of rgb

Attachments:

doSetSysColor.cbl

Old KB# 4187