J'ai trouvé l'API qui va bien pour les thèmes, j'ai remarqué qu'un container sur un TabControl est toujours redessiné en entier même s'il n'est recouvert que partiellement (je ne sais pas si Fred pourra corriger cela), sinon ça marche très bien.
Code : Tout sélectionner
Structure Panel
Region.l
Parent.l
EndStructure
Procedure ChildWindows(hwnd.l,*Pointer.Panel)
Protected RegionGadget.l,rect.rect
If *Pointer\Region=0
*Pointer\Region=CreateRectRgn_(0,0,0,0)
EndIf
GetWindowRect_(hwnd,@rect.rect)
ScreenToClient_(*Pointer\Parent,@rect)
ScreenToClient_(*Pointer\Parent,@rect+8)
RegionGadget=CreateRectRgn_(rect\left,rect\top,rect\right,rect\bottom)
CombineRgn_(*Pointer\Region,*Pointer\Region,RegionGadget,#RGN_OR)
DeleteObject_(RegionGadget)
ProcedureReturn 1
EndProcedure
Procedure DrawBackGround(Gadget.l,hdc.l,*rc.RECT,hregion.l)
Protected rect.Rect,Parent.l,Class.s,ID_Library
Protected ThemePanel.l,hbrush.l,deleteBrush.l
Protected HdcMem.l,hbitmap.l,Panel.Panel
Protected HdcMem2.l,hbitmap2.l,rectParent.rect
Parent=Gadget
Repeat
Parent=GetParent_(Parent)
Class.s=Space(SizeOf(character)*255)
GetClassName_(Parent,@Class,254)
Until Class<>"PureContainer"
If Class="Static"
;-----------------------------------------------
; Dans ce cas je construit une région en ôtant les fenêtres enfants
; Car un ContainerGadget sur un Panel est toujours redessiné en entier!
;-----------------------------------------------
; d'où clignotement des fenêtres enfants
;-----------------------------------------------
Panel\Region=0
Panel\Parent=Gadget
EnumChildWindows_(Gadget,@ChildWindows(),@Panel)
If Panel\Region
CombineRgn_(hregion,hregion,Panel\Region,#RGN_DIFF)
DeleteObject_(Panel\Region)
EndIf
; ------- Traitement si le Parent est un Panel ---------------
If OSVersion()=>#PB_OS_Windows_XP And FindResource_(GetModuleHandle_(0),1,24)<>0
ID_Library=OpenLibrary(#PB_Any,"UxTheme.dll")
If ID_Library<>0
If CallFunction(ID_Library,"IsThemeActive")=1
If CallFunction(ID_Library,"IsAppThemed")=1
;Traitement si les thèmes sont activés
CopyMemory(*rc.RECT,rect.Rect,SizeOf(Rect))
ClientToScreen_(Gadget,@rect)
ClientToScreen_(Gadget,@rect+8)
ScreenToClient_(Parent,@rect)
ScreenToClient_(Parent,@rect+8)
GetClientRect_(Parent,@rectParent.rect)
HdcMem.l=CreateCompatibleDC_(hdc)
hbitmap=CreateCompatibleBitmap_(hdc,rectParent\right,rectParent\bottom)
SelectObject_(hdcmem,hbitmap)
HdcMem2.l=CreateCompatibleDC_(hdc)
hbitmap2=CreateCompatibleBitmap_(Hdc,*rc\right,*rc\bottom)
SelectObject_(hdcmem2,hbitmap2)
CallFunction(ID_Library,"DrawThemeParentBackground",Parent, HdcMem, rect)
BitBlt_(hdcMem2,0,0,*rc\right,*rc\bottom,HdcMem,rect\left,rect\top,#SRCCOPY)
hbrush=CreatePatternBrush_(hbitmap2)
FillRgn_(hdc,hregion,hbrush)
DeleteDC_(HdcMem)
DeleteObject_(hbitmap)
DeleteDC_(HdcMem2)
DeleteObject_(hbitmap2)
DeleteObject_(hbrush)
ThemePanel=1
EndIf
EndIf
CloseLibrary(ID_Library)
EndIf
EndIf
If ThemePanel
ProcedureReturn 1
Else
;Traitement si les thèmes ne sont pas activés
hbrush=CreateSolidBrush_(GetSysColor_(#COLOR_BTNFACE))
FillRgn_(hdc,hregion,hbrush)
DeleteObject_(hbrush)
ProcedureReturn 1
EndIf
EndIf
EndProcedure
Procedure.l ProcSkinGadget( hWnd, Msg, wParam, lParam)
Protected OriginProc.l,hrgn.l,rc.rect
OriginProc= GetProp_(hWnd, "ProcSkinGadget")
Select Msg
Case #WM_ERASEBKGND
ProcedureReturn 1
Case #WM_PAINT
GetClientRect_(hwnd,@rc)
hrgn=CreateRectRgn_(0,0,0,0)
GetUpdateRgn_(hwnd,hrgn,0)
HdcPaint=BeginPaint_(hWnd,@lpPaint.PAINTSTRUCT)
DrawBackGround(hwnd,HdcPaint,@rc,hrgn)
EndPaint_(hWnd,@lpPaint)
DeleteObject_(hrgn)
ProcedureReturn 0
Case #WM_THEMECHANGED,#WM_SYSCOLORCHANGE
; Pas nécessaire car le changement de thème ou de couleurs systèmes
; du Panel provoque un rafraichissement des fenêtres filles
;InvalidateRect_(hwnd,0,1)
Case #WM_NCDESTROY
SetWindowLong_(hWnd, #GWL_WNDPROC, OriginProc)
RemoveProp_(hWnd,"ProcSkinGadget")
EndSelect
ProcedureReturn CallWindowProc_(OriginProc,hWnd,Msg,wParam,lParam)
EndProcedure
#Fenetre=0
If OpenWindow(#Fenetre, 0, 0, 600, 600, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_SizeGadget| #PB_Window_ScreenCentered)
PanelGadget(0, 8, 8, 400, 400)
AddGadgetItem(0,-1, "Onglet 1")
ContainerGadget(15,180,160,200,200);,#PB_Container_Flat)
ContainerGadget(16,50,50,100,100);,#PB_Container_Flat)
ButtonGadget(17,10,10,60,20,"ok")
CloseGadgetList()
CloseGadgetList()
CloseGadgetList()
OriginProc = SetWindowLong_(GadgetID(15), #GWL_WNDPROC, @ProcSkinGadget())
SetProp_(GadgetID(15), "ProcSkinGadget", OriginProc)
OriginProc = SetWindowLong_(GadgetID(16), #GWL_WNDPROC, @ProcSkinGadget())
SetProp_(GadgetID(16), "ProcSkinGadget", OriginProc)
SetWindowColor(#Fenetre,RGB(125,200,255))
Repeat
event=WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case 17
Debug "Cliqué"
EndSelect
EndSelect
Until event=#PB_Event_CloseWindow
EndIf