scrollarea : background color (fixed)

Share your advanced PureBasic knowledge/code with the community.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

scrollarea : background color (fixed)

Post by eddy »

Code updated For 5.20+

For PB 4.XX

Code: Select all

Procedure ScrollAreaColor(ID, r, g, b)
   ScrollAreaChild=GetWindow_(GadgetID(ID), #GW_CHILD)
   ScrollAreaColor=CreateSolidBrush_(RGB(r, g, b))
   SetClassLong_(ScrollAreaChild, #GCL_HBRBACKGROUND, ScrollAreaColor)
   InvalidateRect_(ScrollAreaChild, #Null, #True)
EndProcedure

Enumeration
   #WIN
   #SCROLL
EndEnumeration

OpenWindow(#WIN, 0, 0, 500, 300, "", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget)
If 1;CreateGadgetList(WindowID(#WIN))
   ScrollAreaGadget(#SCROLL, 0, 0, WindowWidth(#WIN), WindowHeight(#WIN), 500, 500, 10, #PB_ScrollArea_Single)
   CloseGadgetList()
   ScrollAreaColor(#SCROLL, 255, 0, 0)
EndIf

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
End
Last edited by eddy on Sat Oct 04, 2008 11:01 pm, edited 3 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Eddy,
your code doesn't work on WinXP 8O

Here is the changed

Code: Select all

Procedure ScrollAreaColor(ID,r,g,b)
   ScrollAreaChild=GetParent_(GetWindow_(GadgetID(ID),#GW_CHILD))
   ScrollAreaColor=CreateSolidBrush_(RGB(r,g,b))
   SetClassLong_(ScrollAreaChild, #GCL_HBRBACKGROUND,ScrollAreaColor) 
   InvalidateRect_(ScrollAreaChild, #Null, #True)   
EndProcedure

Enumeration
   #WIN
   #SCROLL
EndEnumeration

OpenWindow(#WIN,0,0,500,300,#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered | #PB_Window_MaximizeGadget,"PB_Scrollbar")
If CreateGadgetList(WindowID())
   ScrollAreaGadget(#SCROLL,0,0,WindowWidth(),WindowHeight(),AreaX,AreaY,10,#PB_ScrollArea_Single)
   ScrollAreaColor(#SCROLL,255,0,0)
   CloseGadgetList()
EndIf

Repeat : Until WaitWindowEvent()=#PB_EventCloseWindow
End 
now it works here too (WinXP home)
Only added a GetParent to the GetWindow function.
Hope it works for you too - which OS are you using :?:
BTW: Thanks for your tip :wink:
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

I forgot to set scrollarea size ( AreaX = 500 : AreaY = 500 ) :!:
That's why my example does not work.

It's fixed now. :arrow: You don't need to use GetParent
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Post Reply