Page 1 of 1
colorize grey shadow around buttons with xpskin on
Posted: Wed Feb 01, 2012 9:52 am
by MyTrial
Hi
I am working on a big layout with many buttons (imagebuttons) with areas with user defined background colors. My problem is, that all buttons have a grey shadow around the button which is not colorized like the background. I didn't found any command to do that. This happens when XPSkin is set on. If the background is grey, you don't see that. But if an other color is used, it looks very ugly.
Code: Select all
OpenWindow(0,0,0,100,100,"BUTTONSHADOW")
SetWindowColor(0,RGB($00,$8f,$00))
ButtonGadget(3,10,10,80,80,"")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Is someone out there who could help to colorize that shadow in background color? Many thanks.
Sigi
Re: colorize grey shadow around buttons with xpskin on
Posted: Wed Feb 01, 2012 10:24 am
by MyTrial
Forgotten to say that this problem is bigger on checkbox and option gadgets.
Code: Select all
OpenWindow(0,0,0,100,120,"BUTTONSHADOW")
SetWindowColor(0,RGB($00,$8f,$00))
ButtonGadget(3,10,10,80,40,"Button")
CheckBoxGadget(4,10,60,80,20,"CheckBox")
OptionGadget(5,10,90,80,20,"Option")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: colorize grey shadow around buttons with xpskin on
Posted: Wed Feb 01, 2012 3:52 pm
by netmaestro
On Windows you can manage the checkbox and option backgrounds by handling the WM_CTLCOLORSTATIC message. Unfortunately for buttons, Windows will ignore any brushes you return from WM_CTLCOLORBTN unless the button is ownerdrawn:
MSDN wrote:The WM_CTLCOLORBTN message is sent to the parent window of a button before drawing the button. The parent window can change the button's text and background colors. However, only owner-drawn buttons respond to the parent window processing this message.
Here is code for the check and option, as you can see it's quite simple to manage:
Code: Select all
Global hBrush = CreateSolidBrush_(RGB(0,$8f,0))
Procedure WinProc(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLORSTATIC
ProcedureReturn hBrush
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,100,120,"BUTTONSHADOW")
SetWindowColor(0,RGB($00,$8f,$00))
SetWindowCallback(@WinProc())
ButtonGadget(3,10,10,80,40,"Button")
CheckBoxGadget(4,10,60,80,20,"CheckBox")
OptionGadget(5,10,90,80,20,"Option")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
You should have no difficulty finding example code for ownerdrawing buttons on these forums or Purearea should you want to give it a go.
Re: colorize grey shadow around buttons with xpskin on
Posted: Wed Feb 01, 2012 4:50 pm
by MyTrial
Hi netmaestro
nice to meet you and thanks for your help - your help is always welcome
I'm afraid that your help is not usable for me ... sorry
1) I have more than one area with different background colors - all gadgets would get same background color
2) that damages the complete layout, because all setgadgetcolor() parts are drawn back to that given background color
Sigi
Re: colorize grey shadow around buttons with xpskin on
Posted: Wed Feb 01, 2012 7:04 pm
by netmaestro
The lParam parameter contains the hwnd of the control being drawn, all you need to do is check that and you can select the appropriate brush. No need for all gadgets to get the same background.
Re: colorize grey shadow around buttons with xpskin on
Posted: Thu Feb 02, 2012 9:14 am
by MyTrial
Thankyou, netmaestro, for your help points. I got the handles with GadgetID() for the color assignment and the checkboxes and options now working well. Now I have to look to the owner-drawn buttons receipt - and if I can use that.
First I tried to use transparency color with RGBA(), but that wasn't working. Maybe I did something wrong. I don't know.
Re: colorize grey shadow around buttons with xpskin on
Posted: Thu Feb 02, 2012 2:49 pm
by MyTrial
For your info: I will not use owner drawn buttons. That is not usable in the layout of my program. There are too much dynamic parts of all of the gadgets. I must live with that crux and be glad that the checkboxes and options are working for a colored background. But thankyou for your help, netmaestro.