Strange: I tried your code and indeed it centres, even though I wasn't expecting GetActiveWindow to work. However, yes there is a flicker.
here's my full code:
here's my full code:
Strict Local mygraphics:TGraphics = CreateGraphics(640 , 480,0,0,GRAPHICS_BACKBUFFER) 'ccCentreWindow() SetGraphics mygraphics EnablePolledInput() Repeat Cls DrawText "Hello World!" , 0 , 0 Flip Until KeyHit(KEY_ESCAPE) ?win32 Extern "win32" Function GetActiveWindow%() Function GetDesktopWindow%() Function GetWindowRect%(hWnd%, lpRect: Byte Ptr) Function SetWindowPos%(hWnd%, after%, x%, y%, w%, h%, flags%) End Extern ? Type TRect Field L%, T%, R%, B% End Type 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