Winlitz3D: How to color a button? (help)

Blitz3D Forums/Blitz3D Programming/Winlitz3D: How to color a button? (help)

Danny(Posted 2005) [#1]
Anyone have any ideo how you can change the default windows grey on a button in winBlitz3D?

I want to change the 'background' color of a button to show the rgb color the user has picked before...

I've played with functions like
api_setbkMode hWnd,2 (setting background mode to opaque)
api_setbkColor hWnd, $ff0ff

but that no work :(

Any hints appreciated!!
Danny.


John Blackledge(Posted 2005) [#2]
Hi Danny,

It's 5 years since I programmed in C in Windows - don't know how much has changed since then, but at the time I used:
		case WM_CTLCOLOR:
			if (HIWORD(lParam)==CTLCOLOR_STATIC || HIWORD(lParam)==CTLCOLOR_BTN)
				{
				if (hBrushList!=NULL) DeleteObject(hBrushList);
				hBrushList = JCreateBrush(RGB(GetRValue(crBackClr)/2,GetGValue(crBackClr)/2,GetBValue(crBackClr)/2));
				SetBkColor((HDC) wParam, crListClr);
				SetTextColor((HDC) wParam, GetSysColor(COLOR_CAPTIONTEXT)); //crListText);
				SetBkMode((HDC) wParam, TRANSPARENT); //crListText);
				return (LRESULT)hBrushList;
				}
			if(HIWORD(lParam)==CTLCOLOR_EDIT)
				{
				if (hBrushEdit!=NULL) DeleteObject(hBrushEdit);
				hBrushEdit = JCreateBrush(crPaper);
				SetBkColor((HDC) wParam, crPaper);
				SetTextColor((HDC) wParam, crInk);
				return (LRESULT) hBrushEdit;
				}
			if(HIWORD(lParam)==CTLCOLOR_LISTBOX)
				{
				if (hBrushList!=NULL) DeleteObject(hBrushList);
				hBrushList = JCreateBrush(crListClr);
				SetBkColor((HDC) wParam, crListClr);
				SetTextColor((HDC) wParam, crListText);
				return (LRESULT) hBrushList;
				}
		break;



As you can see you couldn't just send a colour change to the button, you had to catch the message coming through WndProc, and 'reply' to it. Messy, but that's Microsoft for you.