Frame3DGadget text color

Just starting out? Need help? Post your questions and find answers here.
User avatar
sirrab
Enthusiast
Enthusiast
Posts: 106
Joined: Thu Dec 07, 2006 8:52 am
Location: New Zealand

Frame3DGadget text color

Post by sirrab »

Hi All

Sorry if this has been asked before but I have been able to find an answer in the form.

can you change the text color in a Frame3DGadget gadget?

Thanks :D
Craig
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

It can be done, but the normal SetGadgetColor in PureBasic won't do it.

Code: Select all

Global TextBackground=CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))
Global TextForeground=#Red 

Procedure WinProc(hWnd,Msg,wParam,lParam) 
  result = #PB_ProcessPureBasicEvents 
  If Msg=#WM_CTLCOLORSTATIC And lParam=GadgetID(0) 
    SetBkMode_(wParam,#TRANSPARENT) 
    SetTextColor_(wParam,TextForeground) 
    result = TextBackGround
  EndIf
  ProcedureReturn result
EndProcedure 

OpenWindow(0,0,0,250,100,"Colored Frame3D",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 
SetWindowCallback(@WinProc()) 

Frame3DGadget(0,10,10,230,80,"This is a Frame3D") 

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 

DeleteObject_(TextForeground) 
DeleteObject_(TextBackground) 
Using code from this sample, you can also change the background color of the text if so desired.
BERESHEIT
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

If you don't mind using userlibs, PureCOLOR is an alternative.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
sirrab
Enthusiast
Enthusiast
Posts: 106
Joined: Thu Dec 07, 2006 8:52 am
Location: New Zealand

thanks for the info

Post by sirrab »

Thanks netmaestro :D

Glad that it wasn't me not being able to find the command
User avatar
sirrab
Enthusiast
Enthusiast
Posts: 106
Joined: Thu Dec 07, 2006 8:52 am
Location: New Zealand

Post by sirrab »

gnozal wrote:If you don't mind using userlibs, PureCOLOR is an alternative.
Hi I'm new to purebasic, what is userlibs?

Thanks
Sirrab
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

sirrab wrote:
gnozal wrote:If you don't mind using userlibs, PureCOLOR is an alternative.
Hi I'm new to purebasic, what is userlibs?
A userlib is a special library created by a user wich adds functions to purebasic.
Once the userlib is installed (in %PureBasic%\PureLibraries\UserLibraries\), you can use it's functions like any other genuine purebasic function.
You can find some on my web site ( http://people.freenet.de/gnozal/ ) and many more here : http://www.purearea.net/pb/english/userlibs.php
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
sirrab
Enthusiast
Enthusiast
Posts: 106
Joined: Thu Dec 07, 2006 8:52 am
Location: New Zealand

Hi I just found it :)

Post by sirrab »

Hi,

I just downloaded your libary, very cool Thanks :)

Craig
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

The PureColor library (while being great), doesn't set the colour of a frame3dgadget in xp theme mode.

Is this a bug, or can it not be done?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

You can only disable the xp-theme for the Frame3DGadget
here the changed example by netmaestro:

Code: Select all

Procedure DisableXPTheme(Gadget.l)
  Protected DLL.l, Null.w
  If OSVersion() >= #PB_OS_Windows_XP
    DLL = OpenLibrary(#PB_Any, "uxtheme.dll")
    CallFunction(DLL, "SetWindowTheme", GadgetID(Gadget), @Null.w, @Null.w)
    CloseLibrary(DLL)
    ProcedureReturn #True
  EndIf
EndProcedure

Global TextBackground=CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))
Global TextForeground=#Red

Procedure WinProc(hWnd,Msg,wParam,lParam)
  result = #PB_ProcessPureBasicEvents
  If Msg=#WM_CTLCOLORSTATIC And lParam=GadgetID(0)
    SetBkMode_(wParam,#TRANSPARENT)
    SetTextColor_(wParam,TextForeground)
    result = TextBackGround
  EndIf
  ProcedureReturn result
EndProcedure

OpenWindow(0,0,0,250,100,"Colored Frame3D",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
SetWindowCallback(@WinProc())

Frame3DGadget(0,10,10,230,80,"This is a Frame3D")
DisableXPTheme(0)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

DeleteObject_(TextForeground)
DeleteObject_(TextBackground)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Thats a good idea. :)

Its a pity though that the XP theme curved box looks so much better.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Found a fix (until its maybe sorted out)...
I create the frame3dgadget without any text...
then put a normal text gadget over the frame3d gadget and use normal colouring on that.

Works great! :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

The PureColor library (while being great), doesn't set the colour of a frame3dgadget in xp theme mode.
Still possible! :wink:

http://www.purebasic.fr/english/viewtop ... 12&t=42743
Last edited by Fluid Byte on Tue Jun 29, 2010 5:49 pm, edited 1 time in total.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Very nice. Great example. 8)
I may look like a mule, but I'm not a complete ass.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

It would be good if this could be integrated into either the native or PureColor commands.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

thanks for this one Fluid Byte.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply