There are some containers and a splitter in this dialog and if all is to look right, they must all have colored backgrounds imho. So here's a thing, I'm pretty noobish when it comes to dialogs and while I could use DialogGadget() to retrieve the ID of the splitter, I had no luck with the containers. You probably know how to do that but I couldn't so I went to some lengths to get the IDs. Sorry for the extra code. Once I had those, It was a matter of subclassing the relevant controls and handling WM_ERASEBKGND with the appropriate hBrush and hPen. So this code is working on Windows. Unfortunately I know less about Linux and MacOS than I do about dialogs so someone else will have to help on those platforms. Wilbert can handle the MacOS without difficulty I'm sure, perhaps Idle for the Linux. But there are others. Anyway, here's Windows:
Code: Select all
Global hBrush = CreateSolidBrush_(RGB(200, 223, 205)), hPen = CreatePen_(#PS_SOLID, 1, RGB(200,223,205))
Global Dim containers(2), numcontainers=0
Procedure BackColorProc(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, "oldproc")
gadget = GetDlgCtrlID_(hwnd)
Select msg
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
Case #WM_ERASEBKGND
SelectObject_(wparam, hBrush)
SelectObject_(wparam, hPen)
GetClientRect_(hwnd, @r.RECT)
Rectangle_(wparam, r\left, r\top, r\right, r\bottom)
ProcedureReturn 1
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
Procedure Enummer(hwnd, lparam)
cn$ = Space(100)
GetClassName_(hwnd, @cn$, 100-SizeOf(Character))
If cn$ = "PureContainer"
containers(numcontainers) = GetDlgCtrlID_(hwnd)
numcontainers+1
EndIf
ProcedureReturn 1
EndProcedure
CompilerIf #PB_Compiler_Unicode
#XmlEncoding = #PB_UTF8
CompilerElse
#XmlEncoding = #PB_Ascii
CompilerEndIf
#Dialog = 0
#Xml = 0
#Image = 0
XML$ = "<window id='#PB_Any' name='test' text='test' minwidth='400' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
"<singlebox name='singlebox' margin='10'>"+
" <splitter name='splitter' flags='#PB_Splitter_Separator'>"+
" <vbox align='left'>"+
" <button text='Some button' />"+
" <empty />"+
" <vbox>"+
" <button text='Example UI content' />"+
" <button text='Example UI content' />"+
" </vbox>"+
" </vbox>"+
" <vbox align='center'>"+
" <button text='Example UI content' />"+
" <button text='Example UI content' />"+
" </vbox>"+
" </splitter>"+
"</singlebox>"+
"</window>"
If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
SetWindowColor(DialogWindow(#Dialog), RGB(200, 223, 205))
; Find the containers and enumerate them in an array
EnumChildWindows_(WindowID((DialogWindow(#Dialog))), @Enummer(), 0)
; Subclass the found containers
For i=0 To numcontainers-1
SetProp_(GadgetID(containers(i)), "oldproc", SetWindowLongPtr_(GadgetID(containers(i)), #GWLP_WNDPROC, @BackColorProc()))
Next
; and the splitter too. Now splitter and containers will
; have their backgrounds erased with the colored brush.
hwndSplitter = GadgetID(DialogGadget(#dialog, "splitter"))
SetProp_(hwndSplitter, "oldproc", SetWindowLongPtr_(hwndSplitter, #GWLP_WNDPROC, @BackColorProc()))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Else
Debug "Error -Dialog- : " + DialogError(#Dialog)
EndIf
Else
Debug "Error XML : " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf