` Printed Icetips Article

Icetips Article



Par2: Progress bar color
2002-01-02 -- David Bratovich
 
've never have got the color to change in a 32-bit app, I had to use a few
Windows API calls to make it work.


Try this...

In your global includes...

WM_USER                                       EQUATE(400H)
PBM_SETBARCOLOR                    EQUATE(WM_USER + 9)
CCM_SETBKCOLOR                      EQUATE(2001H)

LPARAM                                          EQUATE(LONG)
LRESULT                                         EQUATE(LONG)
WPARAM                                        EQUATE(UINT)
HANDLE                                          EQUATE(UNSIGNED)
HWND                                              EQUATE(UNSIGNED)



In your map...

  MODULE('Windows.DLL')

SendMessage(HWND,UNSIGNED,WPARAM,LPARAM),LRESULT,PASCAL,NAME'SendMessageA')
  END
  MODULE('COMCTL32.DLL')
    InitCommonControls(),PASCAL
  END

Inside your app...
 InitCommonControls()
 SELECT(progress1)
 trash = SendMessage(?PROGRESS1{PROP:HANDLE},PBM_SETBARCOLOR,0,COLOR:RED)
 trash = SendMessage(?PROGRESS1{PROP:HANDLE},CCM_SETBKCOLOR,0 ,COLOR:BLUE)

The last parameter is the color value, from the book...

"The COLOR attribute (PROP:COLOR) specifies the default background and
selected foreground and background colors.
The color values in each of the three parameters are constants which contain
the red, green, and blue components to create the color in the three
low-order bytes of a LONG value (bytes 0, 1, and 2: Red = 000000FFh, Green =
0000FF00h, and Blue = 00FF0000h), or EQUATEs for a standard Windows color
value (which are all negative values). EQUATEs for Windows' standard colors
are contained in the EQUATES.CLW file. Each of the runtime properties
returns COLOR:None if the associated parameter is absent. Windows
automatically finds the closest match to the specified color value for the
hardware on which the program is run. Windows standard colors may  be
reconfigured by the user in the Windows Control Panel. Any control using a
Windows standard color is automatically repainted with the new color when
this occurs."



Printed November 21, 2024, 12:33 pm
This article has been viewed/printed 35216 times.