Page 1 of 1

SetClassLong_() and #GCL_HBRBACKGROUND

Posted: Thu Jul 10, 2008 6:11 pm
by eriansa
I am subclassing a containergadget so that it's background is a pattern brush.

All is well, but, as expected, all subsequent containergadgets share this setting.

How can I avoid that?

tia.

Posted: Thu Jul 10, 2008 6:15 pm
by srod
Don't use #GCL_HBRBACKGROUND! :wink:

You are setting a class-style bit here which will effect all instances of this registered window class.

One way around this is to simply process #WM_ERASEBKGND within your container gadget's subclass procedure and use your patterned brush with FillRect_() etc.

Posted: Thu Jul 10, 2008 6:36 pm
by eriansa
srod wrote: You are setting a class-style bit here which will effect all instances of this registered window class.

One way around this is to simply process #WM_ERASEBKGND within your container gadget's subclass procedure and use your patterned brush with FillRect_() etc.
Yep, I know.
But if I subclass a window to have a pattern based background, all subsequent windows do not share that.
I can easily give multiple windows different background brushes, but I can't do that with containergadgets... :?

Furthermore : using a callback + FillRect_() is slower than letting windows take care of the redraw.

Posted: Thu Jul 10, 2008 6:47 pm
by srod
Purebasic Window's use different registered classes in order to avoid this problem! :wink:

As for #WM_ERASEBKGND being slower than Windows... Windows uses exactly the same method!!!

Posted: Thu Jul 10, 2008 6:59 pm
by eriansa
srod wrote:Purebasic Window's use different registered classes in order to avoid this problem!
Ok, I understand. Thanks!

Perhaps a stupid question :
Can't I do the same with the "PureContainer"-class?

Posted: Thu Jul 10, 2008 7:00 pm
by srod
Not sure what you mean?

Why not use an image gadget?

Code: Select all

If OpenWindow(0, 100, 100, 640, 600, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget) And CreateGadgetList(WindowID(0))

  UseJPEGImageDecoder()
  LoadImage(1, #PB_Compiler_Home + "Examples\Sources\Data\terrain_texture.jpg")
  ResizeImage(1, 300, 300)
  ImageGadget(1, 0, 0, 300,300, ImageID(1))
  UseGadgetList(GadgetID(1))
    StringGadget(2, 20,20, 80, 30, "")

  Repeat 
    EventID = WaitWindowEvent() 
  Until EventID = #PB_Event_CloseWindow 
EndIf 

Posted: Thu Jul 10, 2008 8:36 pm
by Marco2007
@Srod: thanx for the tip with UseGadgetList + GadgetID :D