Bonus: If the border color of a FrameGadget could be changed too, that would be great.
FrameGadget text color
FrameGadget text color
Windows XP shows FrameGadgets with blue text, but Windows 7 has black. Does anyone know how to change the text color manually? I assume a callback or ownerdraw situation? Thanks.
Bonus: If the border color of a FrameGadget could be changed too, that would be great.
Bonus: If the border color of a FrameGadget could be changed too, that would be great.
Re: FrameGadget text color
Thanks, RSBasic! 
However, that code has issues:
(1) It uses a deprecated command.
(2) It's hard-coded to use a window ID of 0.
(3) Doesn't work with frames on a PanelGadget.
(4) Has no error-checking for lpBuffer and hThemeButton.
So, here is my optimized solution which fixes all the above:
[Edit] A better and shorter solution is here: http://www.purebasic.fr/english/viewtop ... 12&t=69356
However, that code has issues:
(1) It uses a deprecated command.
(2) It's hard-coded to use a window ID of 0.
(3) Doesn't work with frames on a PanelGadget.
(4) Has no error-checking for lpBuffer and hThemeButton.
So, here is my optimized solution which fixes all the above:
[Edit] A better and shorter solution is here: http://www.purebasic.fr/english/viewtop ... 12&t=69356
Code: Select all
Procedure FrameGadgetColorProc(hWnd,uMsg,wParam,lParam)
Structure FrameColor
lpPrevFunc.i
clrText.l
bThemeXP.b
EndStructure
*frmex.FrameColor=GetWindowLongPtr_(hWnd,#GWL_USERDATA)
Select uMsg
Case #WM_NCDESTROY
FreeMemory(*frmex)
ProcedureReturn 0
Case #WM_PAINT
activewin=GetActiveWindow()
If activewin<>-1
hdc=BeginPaint_(hWnd,ps.PAINTSTRUCT)
SelectObject_(hdc,SendMessage_(hWnd,#WM_GETFONT,0,0))
text$=GetGadgetText(GetDlgCtrlID_(hWnd))
GetTextExtentPoint32_(hdc,text$,Len(text$),fts.SIZE)
GetClientRect_(hWnd,wrc.RECT)
SetRect_(wrc,wrc\left,(wrc\top+fts\cy)/2,wrc\right,wrc\bottom)
If OSVersion()=>#PB_OS_Windows_XP And IsThemeActive_() And IsAppThemed_() And *frmex\bThemeXP
lpBuffer=AllocateMemory(14)
If lpBuffer
PokeS(lpBuffer,"Button",-1,#PB_Unicode)
hThemeButton=OpenThemeData_(WindowID(activewin),lpBuffer)
If hThemeButton
DrawThemeBackground_(hThemeButton,hdc,4,1,wrc,0)
CloseThemeData_(hThemeButton)
EndIf
FreeMemory(lpBuffer)
EndIf
Else
DrawEdge_(hdc,wrc,#EDGE_ETCHED,#BF_RECT)
EndIf
c=GetSysColor_(#COLOR_3DFACE)
parent=GetParent_(hWnd)
grandparent=GetParent_(parent)
If grandparent
gad=GetDlgCtrlID_(grandparent)
If GadgetType(gad)=#PB_GadgetType_Panel
If StartDrawing(WindowOutput(activewin))
c=Point(GadgetX(gad)+3,GadgetY(gad)+3)
StopDrawing()
EndIf
EndIf
EndIf
SetBkColor_(hdc,c)
SetTextColor_(hdc,*frmex\clrText)
TextOut_(hdc,9,0,text$,Len(text$))
EndPaint_(hWnd,ps)
EndIf
ProcedureReturn 0
EndSelect
ProcedureReturn CallWindowProc_(*frmex\lpPrevFunc,hWnd,uMsg,wParam,lParam)
EndProcedure
Procedure FrameGadgetColor(gad,x,y,w,h,text$,col)
dvi.DLLVERSIONINFO\cbsize=SizeOf(DLLVERSIONINFO)
FrameGadget(gad,x,y,w,h,text$)
*frmex.FrameColor=AllocateMemory(SizeOf(FrameColor))
*frmex\lpPrevFunc=SetWindowLongPtr_(GadgetID(gad),#GWL_WNDPROC,@FrameGadgetColorProc())
*frmex\clrText=col
hInstance=OpenLibrary(#PB_Any,"comctl32.dll")
If hInstance
CallFunction(hInstance,"DllGetVersion",@dvi)
If dvi\dwMajorVersion=6 : *frmex\bThemeXP=#True : EndIf
CloseLibrary(hInstance)
EndIf
SetWindowLongPtr_(GadgetID(gad),#GWL_USERDATA,*frmex)
ProcedureReturn GadgetID(gad)
EndProcedure
OpenWindow(0,200,200,420,150,"Window",#PB_Window_SystemMenu)
PanelGadget(0,10,10,210,130)
AddGadgetItem(0,-1,"Panel")
FrameGadgetColor(1,10,10,180,85,"Blue",#Blue)
CloseGadgetList()
FrameGadgetColor(2,230,23,180,118,"Red",RGB(220,0,0))
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Last edited by Dude on Sun Oct 08, 2017 1:21 am, edited 7 times in total.
Re: FrameGadget text color
Too much code for simple task
Code: Select all
OpenWindow(0,200,200,420,150,"Window",#PB_Window_SystemMenu)
PanelGadget(0,10,10,210,130)
AddGadgetItem(0,-1,"Panel")
FrameGadget(1,10,10,180,85," Blue ")
txt = TextGadget(#PB_Any,10+8,10,30,20," Blue ")
SetGadgetColor(txt,#PB_Gadget_FrontColor,#Blue)
CloseGadgetList()
FrameGadget(2,230,23,180,118," Red ")
txt = TextGadget(#PB_Any,230+8,23,30,20," Red ")
SetGadgetColor(txt,#PB_Gadget_FrontColor,#Red)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Egypt my love
Re: FrameGadget text color
RASHAD wrote:Too much code for simple task![]()
![]()
You obviously have never had a job where you get paid per line of code.
Best wishes to the PB community. Thank you for the memories. 
Re: FrameGadget text color
Hold it -- not so fast this time, Rashad!RASHAD wrote:Too much code for simple task![]()
You need to test your code with all themes and window colors, etc.
Here's what your code produces on my test machine:

Last edited by Dude on Sat Oct 07, 2017 1:12 pm, edited 2 times in total.
Re: FrameGadget text color
Dude just increase the width of the TextGadget ex.from 30 to 50
And still there are many tech. to do the job
Try
- DrawEdge_(hDC,r,#EDGE_ETCHED,#BF_RECT)
- Rect_()
- RoundRect_()
Search the forum for examples made by NM,Danilo or srod
And still there are many tech. to do the job
Try
- DrawEdge_(hDC,r,#EDGE_ETCHED,#BF_RECT)
- Rect_()
- RoundRect_()
Search the forum for examples made by NM,Danilo or srod
Egypt my love
Re: FrameGadget text color
Thanks Rashad, I'll work on it.RASHAD wrote:Dude just increase the width of the TextGadget ex.from 30 to 50
Re: FrameGadget text color
Should do it for all circumstances
PB 5.61 x86 Windos 10 x64
PB 5.61 x86 Windos 10 x64
Code: Select all
OpenWindow(0,200,200,420,150,"Window", #PB_Window_SystemMenu)
If LoadFont(0,"Broadway",12)
SetGadgetFont(#PB_Default, FontID(0))
EndIf
PanelGadget(0,10,10,210,130)
AddGadgetItem(0,-1,"Panel")
FrameGadget(1,10,10,180,85," Blue ")
dummy = TextGadget(#PB_Any,0,0,0,0," Blue ")
w = GadgetWidth(dummy,#PB_Gadget_RequiredSize)
h = GadgetHeight(dummy,#PB_Gadget_RequiredSize)
txt = TextGadget(#PB_Any,10+8,10,w,h," Blue ")
SetGadgetColor(txt,#PB_Gadget_FrontColor,$FF0000)
FreeGadget(dummy)
CloseGadgetList()
FrameGadget(2,230,23,180,118," Red ")
dummy = TextGadget(#PB_Any,0,0,0,0," Red ")
w = GadgetWidth(dummy,#PB_Gadget_RequiredSize)
h = GadgetHeight(dummy,#PB_Gadget_RequiredSize)
txt = TextGadget(#PB_Any,230+8,23,w,h," Red ")
SetGadgetColor(txt,#PB_Gadget_FrontColor,$0000FF)
FreeGadget(dummy)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Egypt my love
Re: FrameGadget text color
Thanks, Rashad! I wrapped it up into a neat little procedure here:
http://www.purebasic.fr/english/viewtop ... 12&t=69356
With credit given to you, of course.
http://www.purebasic.fr/english/viewtop ... 12&t=69356
With credit given to you, of course.



