# Bug in SDL2 RC2 under Visual studio 2008

**URL:** <https://discourse.libsdl.org/t/bug-in-sdl2-rc2-under-visual-studio-2008/19668>\
**Category:** SDL Development\
**Created:** [June 11, 2013, 10:06am UTC](https://discourse.libsdl.org/t/bug-in-sdl2-rc2-under-visual-studio-2008/19668 "2013-06-11T10:06:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aggelos\_Kolaitis](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@Aggelos\_Kolaitis](https://discourse.libsdl.org/u/Aggelos_Kolaitis)\
**Post date:** [June 11, 2013, 10:06am UTC](https://discourse.libsdl.org/t/bug-in-sdl2-rc2-under-visual-studio-2008/19668/1 "2013-06-11T10:06:03Z")

</div>

With SDL2 RC2, creating a window under Windows XP at position 0,0 will position the window border off-screen.

Linking with rc2 of SDL2 under Visual Studio 2008.------------------------  
C is the God’s Programming Language

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [June 13, 2013, 5:22am UTC](https://discourse.libsdl.org/t/bug-in-sdl2-rc2-under-visual-studio-2008/19668/2 "2013-06-13T05:22:51Z")

</div>

This actually isn’t technically a bug, since the window position is in  
terms of the client area, and there aren’t API functions to get the window  
border size.

I agree it’s not ideal though and am open to suggestions.On Tue, Jun 11, 2013 at 3:06 AM, neoaggelos wrote:

> \*\*  
> With SDL2 RC2, creating a window under Windows XP at position 0,0 will  
> position the window border off-screen.
> 
> Linking with rc2 of SDL2 under Visual Studio 2008.
> 
> * * *
> 
> C is the God’s Programming Language
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Andreas\_Schiffler](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@Andreas\_Schiffler](https://discourse.libsdl.org/u/Andreas_Schiffler)\
**Post date:** [June 13, 2013, 5:44am UTC](https://discourse.libsdl.org/t/bug-in-sdl2-rc2-under-visual-studio-2008/19668/3 "2013-06-13T05:44:59Z")

</div>

As per web-search wisdom, one CAN get the border size (and thus could  
automatically adjust the position away from 0,0 accordingly).

On XP one can use GetWindowRect (see  
[GetWindowRect function (winuser.h) - Win32 apps | Microsoft Learn](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx)).  
On Vista and above OS’s it is more complicated. One needs to dynamically  
bind to dwmapi.dll, use GetProcAddress() to obtain the  
DwmGetWindowAttribute() function (see  
[DwmGetWindowAttribute function (dwmapi.h) - Win32 apps | Microsoft Learn](http://msdn.microsoft.com/en-us/library/windows/desktop/aa969515%28v=vs.85%29.aspx)),  
then call it with the DWMWA\_EXTENDED\_FRAME\_BOUNDS argument to request  
the genuine window frame dimensions.

Here is some working Python code to illustrate this:

> <https://stackoverflow.com/questions/3192232/getwindowrect-too-small-on-windows-7>

In either case one would need to create the window off screen, query for  
the framesize and then position with the framesize as fudge factor.

What are the positioning behaviors across other platforms? Client area  
or client+frame area?On 6/12/2013 10:22 PM, Sam Lantinga wrote:

> This actually isn’t technically a bug, since the window position is in  
> terms of the client area, and there aren’t API functions to get the  
> window border size.
> 
> I agree it’s not ideal though and am open to suggestions.
> 
> On Tue, Jun 11, 2013 at 3:06 AM, neoaggelos \<neoaggelos at [gmail.com](http://gmail.com) \<mailto:neoaggelos at [gmail.com](http://gmail.com)\>\> wrote:
> 
> ```
> With SDL2 RC2, creating a window under Windows XP at position 0,0
> will position the window border off-screen.
> 
> Linking with rc2 of SDL2 under Visual Studio 2008.
> 
> ------------------------------------------------------------------------
> 
> C is the God's Programming Language
> 
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> 
> ```
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [June 13, 2013, 5:46am UTC](https://discourse.libsdl.org/t/bug-in-sdl2-rc2-under-visual-studio-2008/19668/4 "2013-06-13T05:46:44Z")

</div>

Sorry, to clarify, there aren’t _SDL_ functions to get the window borders.  
🙂

The positioning behavior is (should be) client area across all platforms.On Wed, Jun 12, 2013 at 10:44 PM, Andreas Schiffler \<aschiffler at [ferzkopp.net](http://ferzkopp.net) wrote:

> As per web-search wisdom, one CAN get the border size (and thus could  
> automatically adjust the position away from 0,0 accordingly).
> 
> On XP one can use GetWindowRect (see  
> [GetWindowRect function (winuser.h) - Win32 apps | Microsoft Learn](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx)).  
> On Vista and above OS’s it is more complicated. One needs to dynamically  
> bind to dwmapi.dll, use GetProcAddress() to obtain the  
> DwmGetWindowAttribute() function (see  
> [DwmGetWindowAttribute function (dwmapi.h) - Win32 apps | Microsoft Learn](http://msdn.microsoft.com/en-us/library/windows/desktop/aa969515%28v=vs.85%29.aspx)),  
> then call it with the DWMWA\_EXTENDED\_FRAME\_BOUNDS argument to request the  
> genuine window frame dimensions.
> 
> Here is some working Python code to illustrate this:  
> [python - GetWindowRect too small on Windows 7 - Stack Overflow](http://stackoverflow.com/questions/3192232/getwindowrect-too-small-on-windows-7)
> 
> In either case one would need to create the window off screen, query for  
> the framesize and then position with the framesize as fudge factor.
> 
> What are the positioning behaviors across other platforms? Client area or  
> client+frame area?
> 
> On 6/12/2013 10:22 PM, Sam Lantinga wrote:
> 
> This actually isn’t technically a bug, since the window position is in  
> terms of the client area, and there aren’t API functions to get the window  
> border size.
> 
> I agree it’s not ideal though and am open to suggestions.
> 
> On Tue, Jun 11, 2013 at 3:06 AM, neoaggelos wrote:
> 
> > With SDL2 RC2, creating a window under Windows XP at position 0,0 will  
> > position the window border off-screen.
> > 
> > Linking with rc2 of SDL2 under Visual Studio 2008.
> > 
> > * * *
> > 
> > C is the God’s Programming Language
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> > [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
> 
> * * *
> 
> SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

---

<div class="post-metadata">

**Author:** ![Andreas\_Schiffler](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@Andreas\_Schiffler](https://discourse.libsdl.org/u/Andreas_Schiffler)\
**Post date:** [June 13, 2013, 5:59am UTC](https://discourse.libsdl.org/t/bug-in-sdl2-rc2-under-visual-studio-2008/19668/5 "2013-06-13T05:59:02Z")

</div>

This may be a good candidate for a new SDL 2.1 API - either in the form  
of a special window creation flag that adjusts the position according to  
the frame size and/or a function operating on an existing window that  
returns the framesize.On 6/12/2013 10:46 PM, Sam Lantinga wrote:

> Sorry, to clarify, there aren’t _SDL_ functions to get the window  
> borders. 🙂
> 
> The positioning behavior is (should be) client area across all platforms.
> 
> On Wed, Jun 12, 2013 at 10:44 PM, Andreas Schiffler \<@Andreas\_Schiffler [mailto:Andreas\_Schiffler](mailto:Andreas_Schiffler)\> wrote:
> 
> ```
> As per web-search wisdom, one CAN get the border size (and thus
> could automatically adjust the position away from 0,0 accordingly).
> 
> On XP one can use GetWindowRect (see
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519%28v=vs.85%29.aspx).
> On Vista and above OS's it is more complicated. One needs to
> dynamically bind to dwmapi.dll, use GetProcAddress() to obtain the
> DwmGetWindowAttribute() function (see
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa969515%28v=vs.85%29.aspx),
> then call it with the DWMWA_EXTENDED_FRAME_BOUNDS argument to
> request the genuine window frame dimensions.
> 
> Here is some working Python code to illustrate this:
> http://stackoverflow.com/questions/3192232/getwindowrect-too-small-on-windows-7
> 
> In either case one would need to create the window off screen,
> query for the framesize and then position with the framesize as
> fudge factor.
> 
> What are the positioning behaviors across other platforms? Client
> area or client+frame area?
> 
> On 6/12/2013 10:22 PM, Sam Lantinga wrote:
> 
> ```
> 
> > ```
> > This actually isn't technically a bug, since the window position
> > is in terms of the client area, and there aren't API functions to
> > get the window border size.
> > 
> > I agree it's not ideal though and am open to suggestions.
> > 
> > On Tue, Jun 11, 2013 at 3:06 AM, neoaggelos <neoaggelos at gmail.com <mailto:neoaggelos at gmail.com>> wrote:
> > 
> > With SDL2 RC2, creating a window under Windows XP at position
> > 0,0 will position the window border off-screen.
> > 
> > Linking with rc2 of SDL2 under Visual Studio 2008.
> > 
> > ------------------------------------------------------------------------
> > 
> > C is the God's Programming Language
> > 
> > _______________________________________________
> > SDL mailing list
> > SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> > 
> > _______________________________________________
> > SDL mailing list
> > SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> > 
> > ```
