I'm trying to reposition a window, which has been deliberately placed at the X/Y coordinates of 0 and 0. However, I am not getting the results that I expected. Any advice?
Code: Select all
#MyWindow = 1
Define iThisWindowWidth.i
Define iThisWindowHeight.i
Define iMonitorXcoordinate.i
Define iDesktopHeight.i
Define iDesktopWidth.i
Define iMonitorYcoordinate.i
Define iEvent.i
If OpenWindow(#MyWindow, 0, 0, 400, 300, "", #PB_Window_SystemMenu)
If GetWindowState(#MyWindow) = #PB_Window_Normal
iThisWindowWidth = WindowWidth(#MyWindow)
iThisWindowHeight = WindowHeight(#MyWindow)
If ExamineDesktops()
iDesktopHeight = DesktopHeight(0)
iDesktopWidth = DesktopWidth(0)
iMonitorXcoordinate = Round( ( iDesktopHeight / 2 ) - ( WindowHeight(#MyWindow) / 2 ), 0)
iMonitorYcoordinate = Round( ( iDesktopWidth / 2 ) - ( WindowWidth(#MyWindow) / 2 ), 0)
ResizeWindow(#MyWindow, iMonitorXcoordinate, iMonitorYcoordinate, iThisWindowWidth, iThisWindowHeight)
EndIf
Repeat
iEvent = WindowEvent()
If iEvent <> 0 ; All events are assessed to display the coordinates of the mouse.
SetWindowTitle(#MyWindow, "Position of the mouse on the window: " + Str(WindowMouseX(#MyWindow)) + "," + Str(WindowMouseX(#MyWindow)))
Else
Delay(1) ; Free the CPU for the multitasking
EndIf
Until iEvent = #PB_Event_CloseWindow
EndIf
EndIf