CreateWindowEx
Publié : dim. 13/mars/2011 16:13
Bonjour à tous,
Je viens de récupérer le code suivant dans le forum. Ma question est, je voudrais positionner la ReBar avec les coordonnées suivantes:
x=5
y=5
width=500
height=300
Je pense que c'est avec cette liigne, mais après plusieurs essais, je n'y suis toujours pas arrivé:
Code principal:
Merci à tous pour votre aide!
Je viens de récupérer le code suivant dans le forum. Ma question est, je voudrais positionner la ReBar avec les coordonnées suivantes:
x=5
y=5
width=500
height=300
Je pense que c'est avec cette liigne, mais après plusieurs essais, je n'y suis toujours pas arrivé:
Code : Tout sélectionner
hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,0,0,0,0,WindowsID,#Null, GetModuleHandle_(0),#Null)
Code : Tout sélectionner
#TB_GETBUTTONSIZE=#WM_USER + 58
Structure myINITCOMMONCONTROLSEX
dwSize.l
dwICC.l
EndStructure
Procedure.l CreateRebar(WindowsID,StGadget,HtToolBar,HtCombobox)
rbi.REBARINFO
rbBand.REBARBANDINFO
rc.RECT
icex.myINITCOMMONCONTROLSEX
icex\dwSize=SizeOf(myINITCOMMONCONTROLSEX)
icex\dwICC =#ICC_COOL_CLASSES|#ICC_BAR_CLASSES
InitCommonControlsEx_(@icex)
;Créer Rebar dans la fenêtre
hwndRB=CreateWindowEx_(#WS_EX_TOOLWINDOW,"ReBarWindow32",#Null,#WS_CHILD|#WS_VISIBLE|#WS_CLIPSIBLINGS|#WS_CLIPCHILDREN|#RBS_VARHEIGHT|#CCS_NODIVIDER,0,0,0,0,WindowsID,#Null, GetModuleHandle_(0),#Null)
rbi\cbSize=SizeOf(REBARINFO)
rbi\fMask =0
rbi\himl=#Null
SendMessage_(hwndRB,#RB_SETBARINFO,0,@rbi)
rbBand\cbSize=SizeOf(REBARBANDINFO)
rbBand\fMask =#RBBIM_COLORS|#RBBIM_TEXT|#RBBIM_STYLE|#RBBIM_CHILD |#RBBIM_CHILDSIZE|#RBBIM_SIZE;
rbBand\fStyle=#RBBS_CHILDEDGE
;turn off XP Skin support to see your color choices in the Rebar here
rbBand\clrBack=RGB(200,200,128)
rbBand\clrFore=RGB(64,100,0)
;Set values for band with the StringGadget
GetWindowRect_(StGadget,@rc)
sttext$="String" ; Texte libellé pour StringGadget
rbBand\lpText=@sttext$
rbBand\hwndChild=StGadget ; Associe le libellé (sttext$) à StringGadget
rbBand\cxMinChild=100 ; largeur minimum de l'onglet
rbBand\cyMinChild=rc\bottom - rc\top ; min height of band
rbBand\cx=200 ; width of band
SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand);Ajoute sttext$ à StringGadget
;Get the height of the ToolBar we created earlier
dwBtnSize=SendMessage_(HtToolBar,#TB_GETBUTTONSIZE,0,0)
;Set values for band with the ToolBar
tbtext$="ToolBar"
rbBand\lpText=@tbtext$ ; text to display for ToolBar
rbBand\hwndChild=HtToolBar ; handle to our ToolBar
rbBand\cxMinChild=100 ; min width of band (0 hides ToolBar)
rbBand\cyMinChild=dwBtnSize>>16 ; min height of band set to button height
rbBand\cx=200 ; width of band
;Add the band that has the toolbar.
SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand);
;Set values for the band with the ComboBox
GetWindowRect_(HtCombobox,@rc);
cbtext$="ComboBox"
rbBand\lpText=@cbtext$ ; text to display for ToolBar
rbBand\hwndChild=HtCombobox ; handle to our ComboBOxGadget
rbBand\cxMinChild=100 ; min width of band (0 hides ComboBox)
rbBand\cyMinChild=rc\bottom - rc\top ; min height of band
rbBand\cx=300 ; width of band
;Add the band that has the combobox
SendMessage_(hwndRB,#RB_INSERTBAND,-1,@rbBand);
ProcedureReturn hwndRB;
EndProcedure
If OpenWindow(0,50,50,1440,900,"Rebar Control",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
StGadget=StringGadget(0,10,50,150,20,"Hello World")
HtToolBar=CreateToolBar(0,WindowID(0));
ToolBarStandardButton(0,#PB_ToolBarIcon_New)
ToolBarStandardButton(1,#PB_ToolBarIcon_Open)
ToolBarStandardButton(2,#PB_ToolBarIcon_Save)
SetWindowLong_(HtToolBar,#GWL_EXSTYLE,128) ; best I can do for now
SetWindowLong_(HtToolBar,#GWL_STYLE,1442879821) ; best I can do for now
HtCombobox=ComboBoxGadget(1,10,100,100,20)
For a=1 To 5
AddGadgetItem(1,-1,"ComboBox item " + Str(a))
Next
SetGadgetState(1,0)
CreateRebar(WindowID(0),StGadget,HtToolBar,HtCombobox)
EndIf
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_Menu
If Event=#PB_Event_Menu
SetGadgetText(0,"ToolBar ID: " + Str(EventMenu()))
EndIf
Case #PB_Event_Gadget
If EventGadget()=1
SetGadgetText(0,GetGadgetText(1))
EndIf
Case #PB_Event_CloseWindow
Quit=#True
EndSelect
Until Quit=#True
End