Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Win Plugin, MBS ComputerControl Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/WindowsList
This example is the version from Sun, 17th Mar 2012.
Project "WindowsList.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub Change()
PushButton1.Enabled = me.ListIndex>=0
PushButton2.Enabled = me.ListIndex>=0
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
// find window with handle
dim h as integer = val("&h"+List.Cell(List.ListIndex,0))
const WM_CLOSE = &h0010
call RemoteControlMBS.WinSendMessage(h, WM_CLOSE, 0, 0)
// remove row
List.RemoveRow List.ListIndex
End EventHandler
End Control
Control UpdateButton Inherits PushButton
ControlInstance UpdateButton Inherits PushButton
EventHandler Sub Action()
update
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
dim WindowTitle as string = List.Cell(List.ListIndex,1)
dim WindowClass as string = List.Cell(List.ListIndex,7)
// find window with name and class
dim h as integer = RemoteControlMBS.WinFindWindow(WindowClass,WindowTitle)
const WM_CLOSE = &h0010
call RemoteControlMBS.WinSendMessage(h, WM_CLOSE, 0, 0)
// remove row
List.RemoveRow List.ListIndex
End EventHandler
End Control
EventHandler Sub Open()
update
End EventHandler
Sub update()
dim w as new WindowsListMBS
dim i,c as integer
dim s(-1) as string
List.DeleteAllRows
c=w.WindowCount-1
for i=0 to c
List.AddRow ""
List.Cell(List.LastIndex,0)=hex(w.WindowHandle(i))
List.Cell(List.LastIndex,1)=w.WindowText(i)
List.Cell(List.LastIndex,2)=hex(w.WindowProcessID(i))
List.Cell(List.LastIndex,3)=hex(w.WindowThreadHandle(i))
List.Cell(List.LastIndex,4)=str(w.WindowLeft(i))+"/"+str(w.WindowTop(i))+" "+str(w.WindowWidth(i))+"/"+str(w.WindowHeight(i))
redim s(-1)
if w.WindowVisible(i) then
s.Append "visible"
end if
if w.WindowIconic(i) then
s.Append "iconic"
end if
if w.WindowZoomed(i) then
s.Append "zoomed"
end if
List.Cell(List.LastIndex,5)=Join(s,", ")
List.Cell(List.LastIndex,6)=w.WindowImageFileName(i)
List.Cell(List.LastIndex,7)=w.WindowClassName(i)
next
End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project
The items on this page are in the following plugins: MBS Win Plugin.