After reading a few new posts I've got the bad feeling we have to stick with this new container
From my point of view, developing a skin engine (dll) that should hopefully work in any programming language, I have to write a 2nd subclass only for PB! One for the usual window (Frame + Client = 1 Callback) and one for the new static control on top. The new container also natively ignores GCL_HBRBACKGROUND, so you have to subclass now in order to change the background. I'm not saying it can't be done, but it's annoying and pretty time consuming (runtime + writing more code). And for what? So we can have self-adjusting controls IF we decide to toggle Menu, Toolbar or Statusbar after the window was created... We could do such a simple task manually without breaking so much already existing code! As you can see, I still don't get the powerful reason behind this change... But maybe that's just me!
Following code was written having a dll in mind, where the user most likely only passes the handle of the window. WindowId(), IsMenu(), IsStatusbar(), ... don't function within a dll for an external window.
Also the window is not vertically centered anymore, unless you call HideWindow(0, 0, #PB_Window_ScreenCentered) a second time.
Code: Select all
LoadImage(0, #PB_Compiler_Home + "Examples\3D\Data\Textures\Geebee2.bmp")
OpenWindow(0, 0, 0, 800, 500, "title", #WS_OVERLAPPEDWINDOW|#PB_Window_ScreenCentered|#PB_Window_Invisible)
CreateMenu(0, WindowID(0))
MenuTitle("File")
CreateToolBar(0, WindowID(0))
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
CreateStatusBar(0, WindowID(0))
Global brush = CreatePatternBrush_(ImageID(0)) : FreeImage(0)
SetClassLongPtr_(WindowID(0), #GCL_HBRBACKGROUND, brush)
;{ extra code only for the new gadget container ;(
;;----------------------------------------------
Global oldProc
Procedure WndCallback(hWnd, Msg, wParam, lParam)
Select Msg
Case #WM_ERASEBKGND
GetWindowRect_(GetParent_(hWnd), wRect.RECT)
GetClientRect_(hWnd, cRect.RECT)
If GetMenu_(GetParent_(hWnd))
menu_offset = GetSystemMetrics_(#SM_CYMENU)
EndIf
hStatusBar = FindWindowEx_(GetParent_(hWnd), #Null, "msctls_statusbar32", #Null)
If hStatusBar
GetWindowRect_(hStatusBar, sRect.RECT)
stb_offset = sRect\bottom - sRect\top
EndIf
tb_offset = wRect\bottom - wRect\top - cRect\bottom - cRect\top - (GetSystemMetrics_(#SM_CYFRAME)*2 + GetSystemMetrics_(#SM_CYCAPTION))
SetBrushOrgEx_(wParam, 0, menu_offset + stb_offset - tb_offset, 0)
FillRect_(wParam, cRect, brush)
ProcedureReturn 1
EndSelect
ProcedureReturn CallWindowProc_(oldProc, hWnd, Msg, wParam, lParam)
EndProcedure
Procedure PropEnumProc(hwnd, *lpszString, hData)
If *lpszString >> 16
If PeekS(*lpszString, 14) = "PB_GadgetStack"
ProcedureReturn #False
EndIf
EndIf
ProcedureReturn #True
EndProcedure
newGadCon = GetWindow_(WindowID(0), #GW_CHILD)
If newGadCon
If EnumProps_(newGadCon, @PropEnumProc()) = 0
oldProc = SetWindowLongPtr_(newGadCon, #GWL_WNDPROC, @WndCallback())
EndIf
EndIf
;;----------------------------------------------
;}
HideWindow(0, 0)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
DeleteObject_(brush)