Blitzmax apps (NOT MaxGUI) and mouse pointer

BlitzMax Forums/BlitzMax Programming/Blitzmax apps (NOT MaxGUI) and mouse pointer

GfK(Posted 2006) [#1]
Hello.

Why is it, that when you run a Blitzmax app in a window, it insists on opening in the top-left corner of the Windows Desktop? If it opened in the centre of the screen it would be better but still not ideal.

Also, the mouse pointer moves to the centre of the Blitmax window when the EXE is run. This one is nothing more than irritating. The first problem is just down right ugly.

Any way to fix either/both of these issues? I'm still struggling with finding my way around the documentation.


Grey Alien(Posted 2006) [#2]
This code from my BlitzMax Framework centres the window:
' -----------------------------------------------------------------------------
' ccCentreWindow
' -----------------------------------------------------------------------------
Function ccCentreWindow()
	'Centres the current graphics window on the desktop
	?Win32
	Local hWnd% = GetActiveWindow()
	ccCentreWindowHandle(hWnd%)
	?
End Function

Function ccCentreWindowHandle(hWnd%)
	'Centres the current graphics window on the desktop
	'Pass a handle in
	?Win32
	Local desk_hWnd% = GetDesktopWindow()
	Local desk:TRect = New TRect
	Local window:TRect= New TRect

	GetWindowRect(desk_hWnd,desk) ' Get Desktop Dimensions
    'Get Window Dimensions because final window may have been resized (by BlitzMax) to fit the desktop resultion! (Grey Alien)
	GetWindowRect(hWnd,window)
	
	'Centre Window
	SetWindowPos(hWnd, -2, (desk.r / 2) - ((window.r-window.l) / 2), (desk.b / 2) - ((window.b-window.t) / 2), 0, 0, 1)
	?
End Function


you can use the code to position it whereever you want.

As for mouse, BlitzPlus used to put it in the top left every time you called Graphics which wasn't that good, centre is good as far as I'm conconcerned when changing graphics modes, but if it does that when running a windowed mode .exe for the first time, then that's not so good. There is code to move the pointer somewhere on this forum but I can't help more than that right now I'm afraid.


ImaginaryHuman(Posted 2006) [#3]
Maybe a bug or something, on the Mac the window is centered automatically.