Je viens d'essayer de convertir un code que j'ai trouvé dans le Sdk en PureBasic.
Ce code sert à créer des RebarControl. C'est une barre d'outils avec plusieurs zones qui peuvent êtres redimensionnées. (Voir par exemple, dans la barre de taches de Windows, les marques verticales qu'on peut bouger. C'est l'extremité de ces fameux Rebar)
Bon, je mets le code, c'est pas très concluant comme truc. Si quelqu'un connaît un peu le truc, un petit coup de main ne serait pas de trop.
Code : Tout sélectionner
;/Constantes Window
Enumeration
#Window_0
EndEnumeration
;/Constantes Gadget
Enumeration
#Btn_Quit
#Combo
EndEnumeration
Global Style.s, hwndCB
Procedure CreateComboBox(Handle,Instance)
Cmbo.INITCOMMONCONTROLSEX;
Cmbo\dwSize = SizeOf(INITCOMMONCONTROLSEX);
Cmbo\dwICC = #ICC_USEREX_CLASSES;
InitCommonControlsEx_(@Cmbo);
HCmbo = CreateWindowEx_(0, "ComboBox", #NULL, #WS_BORDER | #WS_VISIBLE | #WS_CHILD | #CBS_DROPDOWN, 0, 0, 0, 100, Handle, #NULL, Instance, #NULL);
ProcedureReturn HCmbo;
EndProcedure
Procedure CreateNewToolBar(Handle,NewStyle)
; Bon là, au moins, on sait pourquoi ça marche pas ;o)
EndProcedure
Procedure CreateRebar(hwndOwner, g_hinst)
rbi.REBARINFO;
rbBand.REBARBANDINFO ;
rc.RECT ;
icex.INITCOMMONCONTROLSEX ;
Cb_Style.s = "ComboBox"
Tb_Style.s = "Tool Bar"
Img.s = "Img1.bmp" ; <-- C'est un bmp de 100 x 25
icex\dwSize = SizeOf(INITCOMMONCONTROLSEX);
icex\dwICC = #ICC_COOL_CLASSES|#ICC_BAR_CLASSES;
InitCommonControlsEx_(@icex);
hwndRB = CreateWindowEx_(#WS_EX_TOOLWINDOW, "ReBarWindow32", #NULL, #WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER, 0,0,0,0, hwndOwner, #NULL, g_hinst, #NULL);
If hwndRB
; Initialize And send the REBARINFO Structure.
rbi\cbSize = SizeOf(REBARINFO); // Required when using this structure.
rbi\fMask = 0;
rbi\himl = #NULL ;(HIMAGELIST)NULL <--- Comprends pas, là. C'est quoi ça, un Image List??
If SendMessage_(hwndRB, #RB_SETBARINFO, 0, @rbi)
; Initialize Structure members that both bands will share.
rbBand\cbSize = SizeOf(REBARBANDINFO); // Required
rbBand\fMask = #RBBIM_COLORS | #RBBIM_TEXT | #RBBIM_BACKGROUND | #RBBIM_STYLE | #RBBIM_CHILD | #RBBIM_CHILDSIZE | #RBBIM_SIZE;
rbBand\fStyle = #RBBS_CHILDEDGE | #RBBS_FIXEDBMP;
rbBand\hbmBack = LoadBitmap_(g_hinst, @Img);
; Create the combo box control To be added.
hwndCB = CreateComboBox(hwndRB, hInstance) ; Quand je cliques sur le combo, ça plante
; Set values unique To the band with the combo box.
GetWindowRect_(hwndCB, @rc);
rbBand\lpText = @Cb_Style;
rbBand\hwndChild = hwndCB;
rbBand\cxMinChild = 0;
rbBand\cyMinChild = rc\bottom - rc\top;
rbBand\cx = 200;
; Add the band that has the combo box.
SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand);
; Create the toolbar control To be added. <--- Bon, là, j'ai abandonné pour l'instant :o))
;hwndTB = CreateNewToolBar(hwndOwner, dwStyle);
; Get the height of the toolbar.
dwBtnSize = SendMessage_(hwndTB, #TB_GETBUTTONSIZE, 0,0);
; Set values unique To the band with the toolbar.
rbBand\lpText = @Tb_Style;
rbBand\hwndChild = hwndTB;
rbBand\cxMinChild = 0;
rbBand\cyMinChild = dwBtnSize;
rbBand\cx = 250;
; Add the band that has the toolbar.
SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand);
EndIf
EndIf
ProcedureReturn hwndRB;
EndProcedure
hWnd = OpenWindow(#Window_0, 300, 300, 300, 200, #PB_Window_SystemMenu, "Fenêtre 1",0)
hInstance = GetWindowLong_(hWnd,#GWL_HINSTANCE)
If CreateGadgetList(hWnd)
ButtonGadget(#Btn_Quit, 100, 170, 100, 25, "Quitter")
EndIf
hwnRb = CreateRebar(hWnd,hInstance)
Repeat
Select WaitWindowEvent()
Case #PB_EventGadget
Select EventGadgetID()
Case #Btn_Quit : quit = 1
EndSelect
Case #PB_EventCloseWindow : quit = 1
EndSelect
Until quit = 1
End
En plus, le fond est tout noir
Chris