GLBasic forum

Codesnippets => Code Snippets => Topic started by: spacefractal on 2019-Mar-05

Title: Create a Borderless Window (require Source Code changes).
Post by: spacefractal on 2019-Mar-05
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
Title: Re: Source Code hack for allow borderless Window......
Post by: erico on 2019-Mar-05
Nice Space! This is a feat lots of people where looking for! :good:
Title: Re: Create a Borderless Window (require Source Code changes).
Post by: spacefractal on 2019-Mar-06
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.
Title: Re: Create a Borderless Window (require Source Code changes).
Post by: Schranz0r on 2019-Mar-06
No Code changes:
http://www.glbasic.com/forum/index.php?topic=1899.0


:good:
Title: Re: Create a Borderless Window (require Source Code changes).
Post by: Moru on 2019-Mar-07
And almost 11 years old code, what a nice world we live in when your stuff isn't obsolete within two months! :-)
Title: Re: Create a Borderless Window (require Source Code changes).
Post by: spacefractal on 2019-Mar-07
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.

Title: Re: Create a Borderless Window (require Source Code changes).
Post by: MrPlow on 2019-Mar-07
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?
Title: Re: Create a Borderless Window (require Source Code changes).
Post by: spacefractal on 2019-Mar-08
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.