OpenWindow

Just starting out? Need help? Post your questions and find answers here.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: OpenWindow

Post by nco2k »

@GenRabbit
in your compiler options, there is a field called linker options file:
https://www.purebasic.com/documentation ... ptions.png

create a new text file and add /SUBSYSTEM:WINDOWS,6.0 to it. then select that file as your linker option file.

that will turn this: https://i.imgur.com/pdYXHCF.png

into this: https://i.imgur.com/vmxTkOy.png

both windows have the exact same coordinates, but notice how the borders and close button get cut off in the first pic?
MSFT wrote:Due to compatability requirements, certain metrics are reported in such a way that they're not consistent with what is actually drawn on the screen when Aero Glass (more accurately, "Windows Vista Aero") is enabled. This sort of approach is needed in order to change the look of the system for the vast majority of apps for which this isn't an issue.

However, there's been a recent change in the system which will be coming out in Vista RC1 that will return the correct rendered value from GetWindowRect() for executables that are linked with "winver = 6.0". This allows new and newly-linked applications to get the "correct" values from GetWindowRect().
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
GenRabbit
Enthusiast
Enthusiast
Posts: 118
Joined: Wed Dec 31, 2014 5:41 pm

Re: OpenWindow

Post by GenRabbit »

@nco2k
Here is my now settings in the compiler
https://i.imgur.com/08BEH1C.png

For some reason I have no more air on all sides of the window except top.
https://i.imgur.com/DZKEAZ0.png
The linker file has this in it; /SUBSYSTEM:WINDOWS,6.0

I'm on a dual monitor setup btw, Do not know if that has any influence on it.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: OpenWindow

Post by RASHAD »

No matter where is your TaskBar or you moved it while running your application

Code: Select all

OpenWindow(0,0,0,0,0,"Window & TaskBar",#PB_Window_SystemMenu| #PB_Window_Maximize) 
border = WindowX(0,#PB_Window_InnerCoordinate)-WindowX(0,#PB_Window_FrameCoordinate)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
        Quit = 1
             
    Case #PB_Event_MoveWindow,#PB_Event_Repaint
        SystemParametersInfo_(#SPI_GETWORKAREA,0,r.RECT,0)
        MoveWindow_(WindowID(0),r\left+border,r\top+border,r\right-r\left-2*border,r\bottom-r\top-2*border,1)
                
  EndSelect

Until Quit = 1
Egypt my love
GenRabbit
Enthusiast
Enthusiast
Posts: 118
Joined: Wed Dec 31, 2014 5:41 pm

Re: OpenWindow

Post by GenRabbit »

@Rashad. Your code does not allow me to move the window from on screen to another. It always fall back to primary monitor
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: OpenWindow

Post by nco2k »

@GenRabbit
im not using win10, but apparently 7 out of those 8 pixels per border, are transparent. you can use DwmGetWindowAttribute to return the visible offset:

Code: Select all

#DWMWA_EXTENDED_FRAME_BOUNDS = 9

Prototype DwmGetWindowAttribute_(hWnd, dwAttribute.l, *pvAttribute, cbAttribute.l)

Define DWMAPIDLL, DwmGetWindowAttribute_.DwmGetWindowAttribute_, WindowRect.RECT

DWMAPIDLL = OpenLibrary(#PB_Any, "DWMAPI.DLL")
If DWMAPIDLL
  
  OpenWindow(0, 0, 0, 640, 480, "Test")
  
  DwmGetWindowAttribute_ = GetFunction(DWMAPIDLL, "DwmGetWindowAttribute")
  If DwmGetWindowAttribute_ And DwmGetWindowAttribute_(WindowID(0), #DWMWA_EXTENDED_FRAME_BOUNDS, @WindowRect, SizeOf(RECT)) = #S_OK
    Debug WindowRect\left
    Debug WindowRect\top
    Debug WindowRect\right  - WindowRect\left
    Debug WindowRect\bottom - WindowRect\top
  EndIf
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  
EndIf
man, windows really turned to shit after win7. :?

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: OpenWindow

Post by Dude »

nco2k wrote:windows really turned to shit after win7
+1 8) That's why I'm staying on Win 7, and will stay until I'm forced to change beyond my control.

As someone in Reddit said, Win 7 was the last version of Windows where an admin had 100% full compete control over his PC.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: OpenWindow

Post by skywalk »

With Sceptre and Meltdown, you should reconsider running stale Windows...or Linux.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
DarkDragon
Addict
Addict
Posts: 2218
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: OpenWindow

Post by DarkDragon »

skywalk wrote:With Sceptre and Meltdown, you should reconsider running stale Windows...or Linux.
You could disable prefetching in your BIOS (if your BIOS provides this option).
bye,
Daniel
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: OpenWindow

Post by RASHAD »

Hi Dude
That's why I'm staying on Win 7
So why do not you stay on Win XP :)
Windows 10 is much powerful than Windows 7
- Dealing with memory
- Enhanced graphics [for exam. try to change the dpi while running]
- Better GUI
- Dealing with the new devices
- And more
It has some drawbacks but you can live with it [disable update - disable Windows defender] if you like

@GenRabbit
Next should work with any monitor
I do not have multi monitors setup to check

Code: Select all

Global m.MONITORINFO
m\cbSize = SizeOf(m)

Procedure curMonitor(win) 
  hMonitor = MonitorFromWindow_(WindowID(win),#MONITOR_DEFAULTTONEAREST)
  GetMonitorInfo_(hMonitor,@m)
EndProcedure

OpenWindow(0,0,0,400,300,"Window & TaskBar",#PB_Window_SystemMenu | #PB_Window_ScreenCentered);| #PB_Window_Maximize)
ButtonGadget(0,10,10,70,20,"Max/Rest",#PB_Button_Toggle)
border = WindowX(0,#PB_Window_InnerCoordinate)-WindowX(0,#PB_Window_FrameCoordinate)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
        Quit = 1
        
    Case #PB_Event_MoveWindow
        If GetGadgetState(0) = 1
          curMonitor(0)  ;Get any monitor information
          MoveWindow_(WindowID(0),m\rcWork\left+border,m\rcWork\top+border,m\rcWork\right-m\rcWork\left-2*border,m\rcWork\bottom-m\rcWork\top-2*border,1) 
          InvalidateRect_(WindowID(0),0,1)
        EndIf
        
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          If GetGadgetState(0) = 1
            x = WindowX(0) : y = WindowY(0) : w = WindowWidth(0) : h = WindowHeight(0)
            curMonitor(0)  ;Get any monitor information
            MoveWindow_(WindowID(0),m\rcWork\left+border,m\rcWork\top+border,m\rcWork\right-m\rcWork\left-2*border,m\rcWork\bottom-m\rcWork\top-2*border,1)
          Else
            MoveWindow_(WindowID(0),0,0,400,300,1)
            HideWindow(0,0,#PB_Window_ScreenCentered)
          EndIf
      EndSelect              
  EndSelect
Until Quit = 1
Egypt my love
GenRabbit
Enthusiast
Enthusiast
Posts: 118
Joined: Wed Dec 31, 2014 5:41 pm

Re: OpenWindow

Post by GenRabbit »

RASHAD wrote: @GenRabbit
Next should work with any monitor
I do not have multi monitors setup to check
It worked nicely on my dual monitor setup.
Well done!
GenRabbit
Enthusiast
Enthusiast
Posts: 118
Joined: Wed Dec 31, 2014 5:41 pm

Re: OpenWindow

Post by GenRabbit »

nco2k wrote:@GenRabbit
im not using win10, but apparently 7 out of those 8 pixels per border, are transparent. you can use DwmGetWindowAttribute to return the visible offset:
man, windows really turned to shit after win7. :?
c ya,
nco2k
Ah ok. So there are transparent borders there. No way to turn that of per application?
and Thanks for the code.

I also hated Win8, 8.1 and Win10 GUI. But after installing Start8/10 I never looked back. Win10 gives to many advantages.
Just remember to get Start10(stardock) and Shutup10 to remove all the shit MS has added
Fences (Stardock) I love aswell.. :)
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: OpenWindow

Post by nco2k »

like i said, im not familier with win10. maybe im wrong, but i dont think that you can change it. its another ms design change, that should "encourage" people to use the dwm api. its also probably a cosmetic change because of touch devices. which is kind of ironic, since win10 looks like ass on any type of device.

nah, im gonna skip win10 completely. dont see the point in installing 3rd party apps, to restored basic functionalities, that should have been there from the start. win10 has way too many drawbacks, and offers way too little in return. wish more people would skip it. then ms would be forced to release something that people actually want.

thankfully, win7 will be supported until 2020. probably even longer, if things keep going like this.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: OpenWindow

Post by Dude »

RASHAD wrote:why do not you stay on Win XP :)
Because of the quote I posted: "Win 7 was the last version of Windows where an admin had 100% full compete control over his PC."

Windows 10 takes over your PC at any time and does whatever it wants. You CAN'T disable updates at all - you can only defer them for a while; and each update brings new problems and issues that didn't exist before. Want proof? Take a read of the Win 10 problems that people post:

https://www.reddit.com/r/Windows10/new/

It's a nightmare OS. :evil: Even Calculator on Win 10 on my work PC takes 5-10 seconds to open! :shock:
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: OpenWindow

Post by RASHAD »

Hi Dude
Reddit nothing but a joke it looks like a forum for kids
How come I disabled the update for as long as one year from now and maybe more
For the Calculator you can use the old one and for Photo viewer as well
Some tips :
- Use Classic Shell(Free) it is more power full than stardock
- Use Winaero Tweaker (Free) v 0.9 right now
- Google for how to disable Update and more

I am a member of the insider program, downloaded RS4 but I will not install it for a while until I read about it more and more

I confirm that it is not easy task but it worth it
You have to swim with the stream asap
Egypt my love
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: OpenWindow

Post by heartbone »

https://answers.microsoft.com/en-us/win ... 10800dd62d

Eventually most everyone will agree about how bad Windows®10 is... right after the next new Windows® OS is released.
Why anyone would actually want to develop for the regressive Windows®10 is very obvious, love of money.
Certainly not old style love of computers and computing.

Having a stable computer operating system is much more important than using Windows®10 for the few MINOR advantages.
Then there's the security problem of to hooking up to the fascist data vacuum.
I can find and link to scores of professionals complaining about and waiting on fixes from Microsoft.
What a freaking joke, and it is getting worse as they brick user's systems with their ignorant forced update scheme.

Even though Windows®10 has resumed its upward movement in market share within the desktop arena,
the result of all their bad blunders to appease the spooks back in the Obama administration
will mean that eventually the herd will have little choice but to accept Linux as the future mainstream OS of computing.

Never 10.
Keep it BASIC.
Post Reply