Not really a coding question, but related.
Take a look at the below pic below showing the ButtonGadget() buttons created for this post:
Notice the slight white border around the button and contrasting against the blue'ish background in the button at the top? This button was created with 'Enable XP Skin Support' enabled in the compiler options.
Now, take a look at the bottom pic. Notice there is no white border around the button and contrasting against the blue'ish background? This is the same button as the top button in the pic above only without 'Enable XP Skin Support' enabled in the compiler options.
Is there an easy way to get rid of the white border (around the top button in the pic) so the somewhat 'rounded corner' view of the button can be used? The white border detracts from the look of the button. (I assume 'XP Skin Support' is the only way to get the look of the 'rounded corners' natively in PureBasic.)
Is this really even theme support or simply adding and subtracting 'shadow' ? Notice also in the bottom button the font used on the button has slightly changed from the top button even though the font its self did not change.
if it matters any, this is with PB 5.10 Beta 8 in Windows 7.
ButtonGadget() border
ButtonGadget() border
Last edited by SFSxOI on Thu Feb 14, 2013 5:22 pm, edited 2 times in total.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Re: ButtonGadget() border
I have no idea if this is the right way to do it, but here's something that seems to work on XP:
Code: Select all
Global hBrush = CreateSolidBrush_(RGB(255,0,0))
Procedure Callback(hWnd, msg, wParam, lParam)
Ret = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_CTLCOLORBTN ;see http://msdn.microsoft.com/en-us/library/windows/desktop/bb761849%28v=vs.85%29.aspx
If lParam = GadgetID(0)
ProcedureReturn hBrush
EndIf
EndSelect
ProcedureReturn Ret
EndProcedure
If OpenWindow(0, 0, 0, 220, 70, "Button gadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@Callback(), 0)
SetWindowColor(0, RGB(255,0,0))
ButtonGadget(0, 10, 10, 200, 20, "Transparent button")
ButtonGadget(1, 10, 40, 200, 20, "Normal button")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(hBrush)
EndIf
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Re: ButtonGadget() border
Thanks InfoByte, that works here on Windows 7. Doesn't remove the white but colors it the same color as the window color which visually accomplishes the goal, and thats Ok in this case so it works for its use and makes the buttons look more attractive than the white border did.
Last edited by SFSxOI on Thu Feb 14, 2013 5:53 pm, edited 1 time in total.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Re: ButtonGadget() border
Great! Unless you will use gradient colors on the window, it will probably look ok. I think that Uxtheme.dll (activated when XP theme support is enabled) uses bitmaps to draw the states of the controls. These bitmaps seem to lack the alpha channel but they have a color used as a transparency mask which can be changed at will. Might be talking out of my hat though.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
- VB6_to_PBx
- Enthusiast
- Posts: 626
- Joined: Mon May 09, 2011 9:36 am
Re: ButtonGadget() border
Code: Select all
;-< Top >
;-
;- Transparent_Button__v3.pb
;-
;- Link : http://www.purebasic.fr/english/viewtopic.php?p=404516#p404516
;-
;-< Start Program >------------------------------------------------------------
;-
;
Global hBrush = CreateSolidBrush_(RGB(255,0,0))
Global hBrushGreen = CreateSolidBrush_(RGB(0,255,0))
Procedure Callback(hWnd, msg, wParam, lParam)
Ret = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_CTLCOLORBTN
Select lParam
Case GadgetID(0), GadgetID(3)
ProcedureReturn hBrush
Case GadgetID(1)
ProcedureReturn hBrushGreen
EndSelect
EndSelect
ProcedureReturn Ret
EndProcedure
If OpenWindow(0, 0, 0, 220, 130, "Button gadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@Callback(), 0)
SetWindowColor(0, RGB(255,0,0))
ButtonGadget(0, 10, 10, 200, 20, "Transparent Border button 0")
ButtonGadget(1, 10, 40, 200, 20, "Normal button • Green Border 1")
ButtonGadget(2, 10, 70, 200, 20, "Normal button • Normal Border 2") ;<--- Normal Border = RGB(240,240,240)
ButtonGadget(3, 10, 100, 200, 20, "Transparent Border button 3")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
DeleteObject_(hBrush)
DeleteObject_(hBrushGreen)
EndIf
;-
;-< End Program >--------------------------------------------------------------
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison
- VB6_to_PBx
- Enthusiast
- Posts: 626
- Joined: Mon May 09, 2011 9:36 am
Re: ButtonGadget() border
Code: Select all
;-< Top >
;-
;- Colored_Text_ButtonGadget_without_Border_Edge__v2.pb
;-
;- Link : http://www.purebasic.fr/english/viewtopic.php?p=404516#p404516
;- Post Subject/Date :
;- Compiler : PB 5.31
;-
;-< Start Program >------------------------------------------------------------
;
LoadFont (0, "Verdana", 8)
Procedure ColoredButtonGadget(GadgetNumber, X, Y, Width, Height, Text.S, TextColor = $000000)
Protected ImageNr
If GadgetNumber = #PB_Any
ProcedureReturn -1
EndIf
ImageNr = CreateImage(#PB_Any, Width, Height, 32, #PB_Image_Transparent)
If ImageNr
StartDrawing(ImageOutput(ImageNr))
DrawingMode(#PB_2DDrawing_AlphaBlend | #PB_2DDrawing_Transparent)
DrawingFont(FontID(0))
DrawText((Width - TextWidth(Text)) / 2, (Height - TextHeight(Text)) / 2, Text, TextColor | $FF000000)
StopDrawing()
ButtonImageGadget(GadgetNumber, X, Y, Width, Height, ImageID(ImageNr))
EndIf
ProcedureReturn ImageNr
EndProcedure
Global hBrush = CreateSolidBrush_(RGB(200,200,200))
Procedure Callback(hWnd, msg, wParam, lParam)
Ret = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_CTLCOLORBTN ;~~~~~ see http://msdn.microsoft.com/en-us/library/windows/desktop/bb761849%28v=vs.85%29.aspx
Select lParam
Case GadgetID(1),GadgetID(2):ProcedureReturn hBrush
EndSelect
EndSelect
ProcedureReturn Ret
EndProcedure
If OpenWindow(0, 0, 0, 220, 70, "Button gadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0, RGB(200,200,200))
SetWindowCallback(@Callback(), 0)
ButtonGadget(1, 10, 10, 200, 20, "Text Color Button 1")
ColoredButtonGadget(1, 10, 10, 200, 20, "Text Color Button 1", RGB(0,0,140))
ButtonGadget(2, 10, 40, 200, 20, "Text Color Button 2")
ColoredButtonGadget(2, 10, 40, 200, 20, "Text Color Button 2", RGB(0,140,0))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
;-
;-< End Program >--------------------------------------------------------------
PureBasic .... making tiny electrons do what you want !
"With every mistake we must surely be learning" - George Harrison