How do I get the system colors?

BlitzPlus Forums/BlitzPlus Programming/How do I get the system colors?

sswift(Posted 2005) [#1]
There's code in the code archives that reads the windows INI file, but I don't trust that method and the code is overly complex.

How can I find out the colors of various interface elements with function calls?


sswift(Posted 2005) [#2]
Whoops, nevermind I found a post which explains how to do it... I found the info I need. I'll add a code archive entry after I code up a decent function.


sswift(Posted 2005) [#3]
As promised:
http://www.blitzbasic.com/codearcs/codearcs.php?code=1311


Damien Sturdy(Posted 2005) [#4]
Nice one Sswifty! Looks like itl work in blitz3d?


sswift(Posted 2005) [#5]
Yeah. it should work fine in Blitz 3D as well.


grumble GRUMBLE grumble...

NOW, does anyone know how I can set the background color of a TEXT FIELD?!?

(Oh how I hate programming for an hour only to realise that I can't even use the code I just wrote because of a missing feature!)


Damien Sturdy(Posted 2005) [#6]
this is why i use VB for my interfaces :(

I should Probably get blitzplus, right? seems nice but, so many people are finding the GUI bit hard still. I'd rather make a 3d GUI :/


sswift(Posted 2005) [#7]
Well I think I did find a solution to my problem which doesn't involve coding any GDI stuff to modify a textfield.

Instead, I'm using a textarea. You can change the background color of those, and if you make it small, and check to see the current text whenever it triggers an action event, you can keep it from displaying any unwanted characters or tabs or things.

I made this function to control the string:

; -----------------------------------------------------------------------------------------------------------------------------------
; This function returns a string that contains only the allowed characters, and of the allowed length.
; -----------------------------------------------------------------------------------------------------------------------------------
Function Allowed$(Txt$, MaxLen, AllowedChars$)
	
	Local N
	Local Char$
	Local NewTxt$

	; Scan through the input string, and create a new string that contains only those characters that are allowed in the string.
	For N = 1 To Len(Txt$)
		Char$ = Mid$(Txt$, N, 1) 	
		If Instr(AllowedChars$, Char$) Then NewTxt$ = NewTxt$ + Char$
	Next
	
	; Truncate the string to the maximum allowed length.
	NewTxt$ = Left$(NewTxt$, MAxLen)
	
	Return NewTxt$
	
End Function



Oh, btw, that color function I added to the code archives had the red and blue functions backwards. I've fixed it now. You can blame that on microsoft. As usual, they've coded things backwards. I don't know what the hell is with them and making stuff work backwards. For example:

1. Instead of xRGB, the colors are stored xBGR.

2. Instead of having the x byte default to 1, which it will need to be if future expansion changes it to be an Alpha component, (which it seems likely it will), they require it to be 0, which would be fully transparent.

3. Bitmaps aren't stored in such a way that they are upside down in memory. And I'm not talking last byte first. I'm talking last line first. So the last byte of the image is at the end of the first line in memory.


What the hell were they thinking when they made these decisions? Especially the bitmap thing. It makes no sense.

They screwed up so many things with Windows it is amazing. They can't even get something like remembering the location of your icons, or your folder settings right.

I mean honestly. HOW HARD IT IS NOT TO TOUCH IT? All they have to do is DO NOTHING. Yet they chose to DO SOMETHING, and that something screws up the icons and folder settings at times.

God I hate Microsoft. :-)


Damien Sturdy(Posted 2005) [#8]
...you forgot [/end rant]

hehe. yeah, their ways do my head in too. Not the place to discuss here though i suppose.

Nice work.


sswift(Posted 2005) [#9]
END RANT? I'm just getting started! There is no end to things to rant about when Microsoft is involved. :-)