Eikon and Grisu. I have some more information about your code to centre a window in BMax. I couldn't find it in Code Archives? Is it there, if not, maybe I could post it on your behalf?
Basically if you set the size to be bigger or the same as the desktop resolution, BlitzMax resizes the window so you don't want to use the GFX_WIDTH and GFX_HEIGHT variables any more for centring. My modifications below get the final window dimensions and use those instead.
Also, and this is weird, if you run my example below and your desktop is 1024x768, BlitzMax will resize the window but make it too short, worse still it starts drawing the window from line 13, thus the top 12 lines of pixels are NOT drawn. You can see this because the DrawText "test" output cannot be seen AND the top one of my four orange lines cannot be seen unless you change the y coords to 13! This is a bit annoying. However, if you DON'T recentre the window the top 12 lines ARE there BUT they are missing from the bottom instead. Talk about weird! [EDIT], commenting out the centring still results in the same error, my mistake due to running two tests at once.
Basically if you set the size to be bigger or the same as the desktop resolution, BlitzMax resizes the window so you don't want to use the GFX_WIDTH and GFX_HEIGHT variables any more for centring. My modifications below get the final window dimensions and use those instead.
Also, and this is weird, if you run my example below and your desktop is 1024x768, BlitzMax will resize the window but make it too short, worse still it starts drawing the window from line 13, thus the top 12 lines of pixels are NOT drawn. You can see this because the DrawText "test" output cannot be seen AND the top one of my four orange lines cannot be seen unless you change the y coords to 13! This is a bit annoying. However, if you DON'T recentre the window the top 12 lines ARE there BUT they are missing from the bottom instead. Talk about weird! [EDIT], commenting out the centring still results in the same error, my mistake due to running two tests at once.
' //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// ' // BlitzMax Window Framework by Eikon ' // modified by Grisu and GreyAlien ' // BMX 1.18 ' //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// Strict ' // Framework & Modules //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// Framework BRL.GLMax2D Import BRL.Basic Import BRL.System ' // Win32 API //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// Extern "win32" Function GetActiveWindow%() Function GetDesktopWindow%() Function GetWindowRect%(hWnd%, lpRect:Byte Ptr) Function SetWindowText%(hWnd%, lpString$z) = "SetWindowTextA@8" Function SetWindowPos%(hWnd%, after%, x%, y%, w%, h%, flags%) End Extern Type lpRECT Field l%, t%, r%, b% End Type ' // Create Window %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// Const GFX_WIDTH = 1024, GFX_HEIGHT = 768, BIT_DEPTH = 0, HERTZ = -1 Graphics GFX_WIDTH, GFX_HEIGHT, BIT_DEPTH, HERTZ Local hWnd% = GetActiveWindow() Local desk_hWnd% = GetDesktopWindow(), l:lpRect = New lpRECT Local window:lpRect = New lpRect GetWindowRect desk_hWnd, l:lpRECT ' Get Desktop Dimensions SetWindowText hWnd, "My Window" ' Set Window Text ' Get Window Dimensions because final window may have been resized to fit the desktop resultion! (Grey Alien) GetWindowRect hWnd, window:lpRECT ' Center Window SetWindowPos hWnd, -2, (l.r / 2) - ((window.r-window.l) / 2), (l.b / 2) - ((window.b-window.t) / 2), 0, 0, 1 'No longer need this as garbage collection is now automatic (Grey Alien) 'l:lpRECT = Null ' Mark for garbage collection 'GCCollect() ' Do collection :) Repeat; SetColor 255,200,0 DrawText "test",0,0 DrawLine 100,0,210,0 'top DrawLine 100,767,210,767 'bottom DrawLine 0,100,0,210 'left DrawLine 1023,100,1023,210 'right Flip; Until KeyDown(KEY_ESCAPE) Or (AppTerminate()=True) ' also exit if windowbutton is used!!!