I need help using ResizeWindow

Just starting out? Need help? Post your questions and find answers here.
percy_b
User
User
Posts: 72
Joined: Mon Jan 12, 2015 10:25 am

I need help using ResizeWindow

Post by percy_b »

Hi Everyone,
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
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: I need help using ResizeWindow

Post by AZJIO »

iMonitorXcoordinate = Round( ( iDesktopHeight / 2 ) - ( WindowHeight(#MyWindow) / 2 ), 0)
percy_b
User
User
Posts: 72
Joined: Mon Jan 12, 2015 10:25 am

Re: I need help using ResizeWindow

Post by percy_b »

Thank you.
Post Reply