Yahoo !!!
Thanks a lot for your great code.
It's exactly, what i search.
I have add some lines, for the beginners worse than me, if he exists
Code: Select all
; http://www.purebasic.fr/english/viewtopic.php?t=30961
; Code de SROD
; Agrandi par KCC pour montrer plusieurs exemples
Structure _countgadgets
className$
count.l
EndStructure
Procedure.l EnumChildWindowProc(hwnd, *cg._countgadgets)
Protected buffer$
buffer$=Space(100)
GetClassName_(hwnd, @buffer$, 100)
If buffer$ = *cg\className$
*cg\count + 1
EndIf
ProcedureReturn 1
EndProcedure
;The following function takes a window handle and a gadget handle and returns a count of the
;number of similar controls on the given window.
;This count includes the specified gadget.
Procedure.l CountSimilarGadgets(winhWnd, gadgethWnd)
Protected buffer$
Protected cg._countgadgets
If IsWindow_(winhWnd) And IsWindow_(gadgethWnd)
buffer$=Space(100)
GetClassName_(gadgethWnd, @buffer$, 100)
cg\className$ = buffer$
EnumChildWindows_(winhWnd, @EnumChildWindowProc(),@cg)
EndIf
ProcedureReturn cg\count
EndProcedure
If OpenWindow(0, 100, 100, 600, 600, "Count gadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left)
ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right)
ButtonGadget(3, 10,100, 200, 60, "Multiline Button (longer text gets automatically wrapped)", #PB_Button_MultiLine)
ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle)
StringGadget(5, 10, 200, 100, 20, "Coucou")
ComboBoxGadget(6, 10,240, 100, 50)
ComboBoxGadget(7, 10, 300, 100, 50)
ComboBoxGadget(8, 10, 350, 100, 50)
ListViewGadget(9, 10, 400, 100, 30)
ListViewGadget(10, 10, 450, 100, 30)
CountButton = CountSimilarGadgets(WindowID(0), GadgetID(4))
CountText = CountSimilarGadgets(WindowID(0), GadgetID(5))
CountBox = CountSimilarGadgets(WindowID(0), GadgetID(6))
CountList = CountSimilarGadgets(WindowID(0), GadgetID(9))
Debug "There are " + Str(countButton) + " buttons!"
Debug "There are " + Str(countText) + " Texte!"
Debug "There are " + Str(countBox) + " ComboBox!"
Debug "There are " + Str(countList) + " ListBox!"
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
I wish you a very very good day.
And the pleasure of having the honor to speak to you again
