Click to See Complete Forum and Search --> : QBColor Text


thiyagarajan
June 19th, 2001, 01:58 AM
Hello All,
I am using QBColor function to get list the 16 colors in a ComboBox . I wanted to display the text of the color say "Red","Blue" etc . But instead of hardcoding , i would like get from the system for the current locale.Is there any way to do this.
Thanks for your time
Regards,
Thiyagarajan M

Cimperiali
June 19th, 2001, 02:47 AM
To get system colors (warning: you will get system colors. You have to provide a conversion to qbcolor...)

from Api-guide (example of usage at bottom)

'KPD-Team 1998
'URL: http://www.allapi.net/ 'you can download it here, it is free!
'E-Mail: KPDTeam@Allapi.net

The GetSysColor function retrieves the current color of the specified display element. Display elements are the parts of a window and the Windows display that appear on the system display screen.

'-----------------------------------------------------------------------------
declaration:

Declare Function GetSysColor Lib "user32" Alias "GetSysColor" (byval nIndex as Long) as Long




'-----------------------------------------------------------------------------
parameters:
· nIndex
Specifies the display element whose color is to be retrieved. This parameter must be one of the following values:
COLOR_3DDKSHADOW
Dark shadow for three-dimensional display elements.
COLOR_3DFACE,
COLOR_BTNFACE
Face color for three-dimensional display elements.
COLOR_3DHILIGHT, COLOR_3DHIGHLIGHT, COLOR_BTNHILIGHT, COLOR_BTNHIGHLIGHT
Highlight color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DLIGHT
Light color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DSHADOW, COLOR_BTNSHADOW
Shadow color for three-dimensional display elements (for edges facing away from the light source).
COLOR_ACTIVEBORDER
Active window border.
COLOR_ACTIVECAPTION
Active window caption.
COLOR_APPWORKSPACE
Background color of multiple document interface (MDI) applications.
COLOR_BACKGROUND, COLOR_DESKTOP
Desktop.
COLOR_BTNTEXT
Text on push buttons.
COLOR_CAPTIONTEXT
Text in caption, size box, and scroll bar arrow box.
COLOR_GRAYTEXT
Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.
COLOR_HIGHLIGHT
Item(s) selected in a control.
COLOR_HIGHLIGHTTEXT
Text of item(s) selected in a control.
COLOR_INACTIVEBORDER
Inactive window border.
COLOR_INACTIVECAPTION
Inactive window caption.
COLOR_INACTIVECAPTIONTEXT
Color of text in an inactive caption.
COLOR_INFOBK
Background color for tooltip controls.
COLOR_INFOTEXT
Text color for tooltip controls.
COLOR_MENU
Menu background.
COLOR_MENUTEXT
Text in menus.
COLOR_SCROLLBAR
Scroll bar gray area.
COLOR_WINDOW
Window background.
COLOR_WINDOWFRAME
Window frame.
COLOR_WINDOWTEXT
Text in windows.

'-----------------------------------------------------------------------------
Example:

private Declare Function SetSysColors Lib "user32" (byval nChanges as Long, lpSysColor as Long, lpColorValues as Long) as Long
private Declare Function GetSysColor Lib "user32" (byval nIndex as Long) as Long
Const COLOR_SCROLLBAR = 0 'The Scrollbar colour
Const COLOR_BACKGROUND = 1 'Colour of the background with no wallpaper
Const COLOR_ACTIVECAPTION = 2 'Caption of Active Window
Const COLOR_INACTIVECAPTION = 3 'Caption of Inactive window
Const COLOR_MENU = 4 'Menu
Const COLOR_WINDOW = 5 'Windows background
Const COLOR_WINDOWFRAME = 6 'Window frame
Const COLOR_MENUTEXT = 7 'Window Text
Const COLOR_WINDOWTEXT = 8 '3D dark shadow (Win95)
Const COLOR_CAPTIONTEXT = 9 'Text in window caption
Const COLOR_ACTIVEBORDER = 10 'Border of active window
Const COLOR_INACTIVEBORDER = 11 'Border of inactive window
Const COLOR_APPWORKSPACE = 12 'Background of MDI desktop
Const COLOR_HIGHLIGHT = 13 'Selected item background
Const COLOR_HIGHLIGHTTEXT = 14 'Selected menu item
Const COLOR_BTNFACE = 15 'Button
Const COLOR_BTNSHADOW = 16 '3D shading of button
Const COLOR_GRAYTEXT = 17 'Grey text, of zero if dithering is used.
Const COLOR_BTNTEXT = 18 'Button text
Const COLOR_INACTIVECAPTIONTEXT = 19 'Text of inactive window
Const COLOR_BTNHIGHLIGHT = 20 '3D highlight of button
Const COLOR_2NDACTIVECAPTION = 27 'Win98 only: 2nd active window color
Const COLOR_2NDINACTIVECAPTION = 28 'Win98 only: 2nd inactive window color
private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'get the caption's active color
col& = GetSysColor(COLOR_ACTIVECAPTION)
'Change the active caption's color to red
t& = SetSysColors(1, COLOR_ACTIVECAPTION, RGB(255, 0, 0))
MsgBox "The old title bar color was" + Str$(col&) + " and is now" + Str$(GetSysColor(COLOR_ACTIVECAPTION))
End Sub





Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

thiyagarajan
June 20th, 2001, 01:07 AM
Hello Mr.Cimperiali ,
Thanks for the reply.But i would like to get the "Text" in the Locale langauge rather than the long value.For example QBColor(4) returns a long value representing Red Color.i use this value to paint a Combo item in Red Background . Apart from that i want to display "Red" or "Rot" string in the combo item depending on the Locale settings. Can i query the system components for the Color Text or do i need to hardcode it into the Program.
Thanks once again.
Regards,
Thiyagarajan

Cimperiali
June 20th, 2001, 04:36 AM
maybe here you can find something:
http://www.vb2themax.com/Item.asp?PageID=CodeBank&Cat=1300&ID=184

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.