Create a Borderless Window (require Source Code changes).

Previous topic - Next topic

spacefractal

gb.h: under // Extern Symbols

Code (glbasic) Select

extern int __DG_DOBORDERLESSWINDOW;


glb-full somewhere under namespace __GLBASIC__ {
Code (glbasic) Select

int             __DG_DOBORDERLESSWINDOW=0;


gb_pc.cpp: under void   SETSCREEN(DGNat w, DGNat h, DGNat fs) {

Code (glbasic) Select

// do you want a borderless window?
__DG_DOBORDERLESSWINDOW=0;
if (fs==2) { __DG_DOBORDERLESSWINDOW=1; fs=0; }
   
   
openglrainbows.cpp in the function bool OpenGLRainbows::DoWindowed()

replaec all code between    // -------- WIN32 -------- and  // update desktop

Code (glbasic) Select

#elif defined(WIN32)
if (m_WND.fullscreen)
{
::ChangeDisplaySettings(NULL, 0);
restore_desktop();
}

if (__DG_DOBORDERLESSWINDOW==1)
{
::SetWindowLong(m_WND.hwnd, GWL_STYLE, WS_POPUP);
}
else
{
::SetWindowLong(m_WND.hwnd, GWL_EXSTYLE, 0);
::SetWindowLong(m_WND.hwnd, GWL_STYLE, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX); // | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
}
::UpdateWindow(m_WND.hwnd);

WINDOWPLACEMENT wpl;
if(0  ) // !::GetWindowPlacement(m_WND.hwnd, &wpl)) // Win98 will fail this here...
{
wpl.rcNormalPosition.top=0;
wpl.rcNormalPosition.right=m_WND.width;
wpl.rcNormalPosition.bottom=m_WND.height;
::OffsetRect(&wpl.rcNormalPosition, (::GetSystemMetrics(SM_CXSCREEN)-m_WND.width)/2, (::GetSystemMetrics(SM_CYSCREEN)-m_WND.width)/2);
}
else
{

RECT rcCenter, rcArea;
::GetWindowRect(m_WND.hwnd, &rcCenter);
HMONITOR hMonitor = MonitorFromRect(&rcCenter, MONITOR_DEFAULTTONEAREST);
if(hMonitor)
{
MONITORINFO MonitorInfo = { sizeof MonitorInfo };
GetMonitorInfo(hMonitor, &MonitorInfo);
rcArea = MonitorInfo.rcWork;
}
else
::SystemParametersInfo(SPI_GETWORKAREA, 0, &rcArea, 0);

wpl.rcNormalPosition.left=0;
wpl.rcNormalPosition.top=0;
wpl.rcNormalPosition.right=m_WND.width                                   +::GetSystemMetrics(SM_CXBORDER)*6;
wpl.rcNormalPosition.bottom=m_WND.height+::GetSystemMetrics(SM_CYCAPTION)+::GetSystemMetrics(SM_CYBORDER)*6;
::OffsetRect(&wpl.rcNormalPosition, ((rcArea.right-rcArea.left)-m_WND.width)/2, ((rcArea.bottom-rcArea.top)-m_WND.height)/2);
}

if (__DG_DOBORDERLESSWINDOW==0)
{
::SetWindowPos(m_WND.hwnd, HWND_NOTOPMOST,
wpl.rcNormalPosition.left,
wpl.rcNormalPosition.top,
wpl.rcNormalPosition.right - wpl.rcNormalPosition.left,
wpl.rcNormalPosition.bottom- wpl.rcNormalPosition.top,
SWP_SHOWWINDOW);
}
else
{
::SetWindowPos(m_WND.hwnd,HWND_NOTOPMOST,wpl.rcNormalPosition.left,wpl.rcNormalPosition.top, m_WND.width, m_WND.height, 0);
}
::ShowWindow(m_WND.hwnd, SW_SHOWNORMAL);


Now you can set a borderless window by just SETSCREEN, X, Y, 2
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

erico

Nice Space! This is a feat lots of people where looking for! :good:

spacefractal

Found a little issue I'm take a look later. Look like y position is still taking the top border as it's should not do it. But worked OK for the extracly purpose I'm wanted througt.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

And almost 11 years old code, what a nice world we live in when your stuff isn't obsolete within two months! :-)

spacefractal

Here it's just so you could use SETSCREEN directly and do a borderless window more correctly. I'm haven't update with a tiny bug, but I'm know how to do it and is not home yet to update it.

I'm required such a window for a little arcade frontend for my pinball machine..... Other programs simply did dent like the full screen glbasic is using and freak out.

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

Hi SF,

How does this differ to the older version of the borderless code - I used the older one and it worked - a bit of a delay between window and borderless (less 1 sec) but otherwise same.

Is this a borderless requirement for win 10 or specific platforms - glb 16?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

Im wasent aware of the other very old post and im property have not found it or aware of it. But. Here is so a integrated source code version of it, so you can invoke it by SETSCREEN command directly and its dosent break combatible, nor using inline when working.

This is how borderless windows should have been done really, which is what SETSCREEN is for. but both is actuelly valid and is not required if the old one still works.

Also there was various issues with the normal fullscreen in Windows 10 general, but its a totally different issue. But here all that was required is just mininmize its window when its got inactive from fullscreen.

PS. im also update the post for avoid a another little bug, so its fill the full window.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/