Code: Select all
Structure FindWindowData
*handle ; variable to store a handle
name.s ; variable to store a Window name
class.s ; variable to store a window class name
EndStructure
Global FindEditor.FindWindowData
Procedure.i FindEditorWindow(WindowHandle, lParam)
Protected WindowName.s=Space(255)
Protected WindowClass.s=Space(255)
If GetWindowText_(WindowHandle, WindowName, 255)
Protected Result=GetClassName_(WindowHandle, WindowClass, 255)
If FindString(WindowName, "PureBasic 4.51", 0)
FindEditor\handle=WindowHandle
FindEditor\name=WindowName
FindEditor\class=WindowClass
;end of searching
ProcedureReturn 0
EndIf
EndIf
;continue searching
ProcedureReturn 1
EndProcedure
Procedure.i FindEditorTabberToChangeTab(EditorChild, SelectedTab)
Protected ChildName.s=Space(255)
Protected ChildClass.s=Space(255)
If Not GetWindowText_(EditorChild, @ChildName, 255)
SendMessage_(EditorChild, #WM_GETTEXT, 255, ChildName)
EndIf
If GetClassName_(EditorChild, @ChildClass, 255)
If FindString(ChildClass, "SysTab", 0)
Static EditorTabber
Static EditorTabberIndex
EditorTabberIndex+1
If EditorTabberIndex=2
EditorTabberIndex=0
;found the second editor tabber
EditorTabber=EditorChild
;select a tab
SendMessage_(EditorTabber, #TCM_SETCURFOCUS, SelectedTab, 0)
SendMessage_(EditorTabber, #TCM_SETCURSEL, SelectedTab, 0)
SendMessage_(EditorTabber, #WM_LBUTTONUP, SelectedTab, 0)
;end of searching
ProcedureReturn 0
EndIf
EndIf
EndIf
;continue searching
ProcedureReturn 1
EndProcedure
Procedure ChangeEditorTab(SelectedTab)
;find editor
EnumWindows_(@FindEditorWindow(), 0)
;find tabber and change tab
Protected Editor=FindEditor\handle
EnumChildWindows_(Editor, @FindEditorTabberToChangeTab(), SelectedTab)
EndProcedure
; ********************
; EXAMPLE
; ********************
#w=200
#h=100
OpenWindow(0, 0, 0, #w, #h, "IDE change tab", #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ChangeEditorTab(0)
Repeat
Define e=WaitWindowEvent()
Until e=#PB_Event_CloseWindow
End