Ja! Vielen Dank, chi.
Code: Alles auswählen
;
; SetProperWindowCoordinates3.pb
;
; Author: Enrico Seidel
; Date: 10/30/2014
; Demo: no
Window = OpenWindow (#PB_Any, 0, 0, 315, 56, "Auswahl", #PB_Window_SystemMenu| #PB_Window_ScreenCentered)
Button1 = ButtonGadget (#PB_Any, 13, 17, 50, 22, "16 : 9")
Button2 = ButtonGadget (#PB_Any, 73, 17, 50, 22, "16 : 10")
Button3 = ButtonGadget (#PB_Any, 133, 17, 50, 22, "4 : 3")
Button4 = ButtonGadget (#PB_Any, 193, 17, 50, 22, "5 : 4")
Button5 = ButtonGadget (#PB_Any, 253, 17, 50, 22, "k/Ä")
DisableGadget (Button5, #True)
Repeat
Select WaitWindowEvent ()
Case #PB_Event_Gadget
Select EventGadget ()
Case Button1
H = 360
Break
Case Button2
H = 400
Break
Case Button3
H = 480
Break
Case Button4
H = 512
Break
Case Button5
OnlyCenter = #True
Break
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
CloseWindow (Window)
Procedure ListVisibleWindows ()
Protected HWnd, Txt.s
Shared ListIcon
HWnd = GetWindow_ (GetDesktopWindow_ (), #GW_CHILD)
While Not HWnd = #Null
If IsWindowVisible_ (HWnd)
txt = Space (#MAX_PATH)
GetWindowText_ (HWnd, Txt, #MAX_PATH)
If LCase (Txt) <> "start" And LCase (Txt) <> "program manager" And Txt <> ""
AddGadgetItem (ListIcon, -1, Str (HWnd) + #LF$ + Txt)
EndIf
EndIf
hwnd = GetWindow_ (HWnd, #GW_HWNDNEXT)
Wend
EndProcedure
Window = OpenWindow (#PB_Any, #PB_Ignore, #PB_Ignore, 630, 340, "Visible Windows on Desktop", #PB_Window_SystemMenu| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered)
ListIcon = ListIconGadget (#PB_Any, 15, 10, 600, 290, "Handle", 125, #PB_ListIcon_FullRowSelect)
AddGadgetColumn(ListIcon, 1, "Title", 300)
Button = ButtonGadget (#PB_Any, 535, 310, 80, 20, "Aktualisieren")
;{ Calculating desktop measures savely
DevMode. DEVMODE
DevMode\ dmSize = SizeOf (DEVMODE)
EnumDisplaySettings_ (#Null, #ENUM_CURRENT_SETTINGS, DevMode)
DesktopWidth = DevMode\ dmPelsWidth
DesktopHeight = DevMode\ dmPelsHeight
;}
ListVisibleWindows()
Repeat
Select WaitWindowEvent ()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_SizeWindow
ResizeGadget (ListIcon, 15, 10, WindowWidth (Window) - 30, WindowHeight (Window) - 50)
ResizeGadget (Button, WindowWidth (Window) - 95, WindowHeight (Window) - 30, #PB_Ignore, #PB_Ignore)
Case #PB_Event_Gadget
Select EventGadget ()
Case ListIcon
If EventType () = #PB_EventType_LeftDoubleClick
WindowHandle = Val (GetGadgetItemText (ListIcon, GetGadgetState (ListIcon), #Null))
If WindowHandle
If IsIconic_ (WindowHandle)
ShowWindow_ (WindowHandle, #SW_RESTORE)
EndIf
If OnlyCenter
Rect. RECT
GetClientRect_ (WindowHandle, Rect)
WindowWidth = Rect\ Right
WindowHeight = Rect\ Bottom
Else
WindowWidth = 630 * (1.0 * DesktopWidth / 640)
WindowHeight = 1.0 * WindowWidth / 630 * (336.0 / 360 * H)
EndIf
WindowRect. RECT
WindowRect\ Bottom = (DesktopHeight + WindowHeight) / 2
WindowRect\ Left = (DesktopWidth - WindowWidth) / 2
WindowRect\ Top = (DesktopHeight - WindowHeight) / 2
WindowRect\ Right = (DesktopWidth + WindowWidth) / 2
SolidWindowRect. RECT
SolidWindowRect = WindowRect
AdjustWindowRect_ (WindowRect, #WS_SYSMENU| #WS_CAPTION, #Null)
WindowRect\ Bottom = (DesktopHeight + SolidWindowRect\ Bottom - SolidWindowRect\ Top) / 2
WindowRect\ Left = (DesktopWidth - SolidWindowRect\ Right + SolidWindowRect\ Left) / 2
WindowRect\ Top = (DesktopHeight - SolidWindowRect\ Bottom + SolidWindowRect\ Top) / 2
WindowRect\ Right = (DesktopWidth + SolidWindowRect\ Right - SolidWindowRect\ Left) / 2
SetWindowPos_ (WindowHandle, #Null, WindowRect\ Left, WindowRect\ Top, WindowRect\ Right - WindowRect\ Left, WindowRect\ Bottom - WindowRect\ Top, #Null)
EndIf
EndIf
Case Button
ClearGadgetItems (ListIcon)
ListVisibleWindows ()
EndSelect
EndSelect
ForEver