BASIC

Author Topic: Create a Borderless Window (require Source Code changes).  (Read 636 times)

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3602
    • View Profile
    • Space Fractal
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
« Last Edit: 2019-Mar-08 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4177
    • View Profile
    • Portfolio
Nice Space! This is a feat lots of people where looking for! :good:

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3602
    • View Profile
    • Space Fractal
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.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
And almost 11 years old code, what a nice world we live in when your stuff isn't obsolete within two months! :-)

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3602
    • View Profile
    • Space Fractal
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.

Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Online MrPlow

  • Prof. Inline
  • *****
  • Posts: 1431
    • View Profile
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

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3602
    • View Profile
    • Space Fractal
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.
« Last Edit: 2019-Mar-08 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.