# Window trick (win32 only)

**URL:** <https://discourse.libsdl.org/t/window-trick-win32-only/13132>\
**Category:** SDL Development\
**Created:** [March 13, 2006, 4:58am UTC](https://discourse.libsdl.org/t/window-trick-win32-only/13132 "2006-03-13T04:58:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Nagle](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@John\_Nagle](https://discourse.libsdl.org/u/John_Nagle)\
**Post date:** [March 13, 2006, 4:58am UTC](https://discourse.libsdl.org/t/window-trick-win32-only/13132/1 "2006-03-13T04:58:44Z")

</div>

Hi everyone,

I’m new to the list, and an SDL user for only a few months now. I think SDL  
is awesome, I intend to use it a lot.

I’m developing some stuff with SDL which I want to run in a window, but I  
don’t want the window itself to be visible at all (not even a frame). That  
way I can put widgets of my own in the render window and allow the user to  
drag it around if I want. Not sure how you’d do this on any other OS. So  
here’s my code, which strips SDL of it’s frame and centers it on your  
screen.

I hope some of you find this useful.

// … initialize SDL video up here…  
// …  
//=================================  
// Strip the window of it’s border  
//=================================  
SDL\_SysWMinfo Info;  
SDL\_VERSION(&Info.version);  
SDL\_GetWMInfo( &Info );  
LONG Style = GetWindowLong( Info.window, GWL\_STYLE );  
Style &= (~WS\_BORDER);  
Style &= (~WS\_DLGFRAME);  
SetWindowLong( Info.window, GWL\_STYLE, Style );  
//=================================  
// Center the window on the screen  
//=================================  
int Width, Height;  
Width = GetSystemMetrics( SM\_CXSCREEN );  
Height = GetSystemMetrics( SM\_CYSCREEN );  
MoveWindow( Info.window, (Width - XRES)/2, (Height - YRES)/2, XRES, YRES,  
TRUE );

John Nagle

President/CEO  
Nagle Research  
13809 Research Blvd. Suite 745  
Austin, TX 78750  
[http://www.NagleResearch.com](http://www.NagleResearch.com)  
512.260.9533 (office)  
512.300.8906 (cell)

---

<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:** [March 13, 2006, 3:38pm UTC](https://discourse.libsdl.org/t/window-trick-win32-only/13132/2 "2006-03-13T15:38:10Z")

</div>

> I’m developing some stuff with SDL which I want to run in a window, but I  
> don’t want the window itself to be visible at all (not even a frame).

You mean something like the SDL\_NOFRAME flag passed SDL\_SetVideoMode()?

_grin_  
-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment

---

<div class="post-metadata">

**Author:** ![John\_Nagle](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/bcef8e/32.png) [@John\_Nagle](https://discourse.libsdl.org/u/John_Nagle)\
**Post date:** [March 13, 2006, 4:13pm UTC](https://discourse.libsdl.org/t/window-trick-win32-only/13132/3 "2006-03-13T16:13:15Z")

</div>

Doh! :-)\> ----- Original Message -----

> From: [slouken@devolution.com](mailto:slouken@devolution.com) (Sam Lantinga)  
> To: “A list for developers using the SDL library. (includes SDL-announce)”  
>   
> Sent: Monday, March 13, 2006 9:38 AM  
> Subject: Re: [SDL] Window trick (win32 only)
> 
> > > I’m developing some stuff with SDL which I want to run in a window, but I  
> > > don’t want the window itself to be visible at all (not even a frame).
> > 
> > You mean something like the SDL\_NOFRAME flag passed SDL\_SetVideoMode()?
> > 
> > _grin_  
> > -Sam Lantinga, Senior Software Engineer, Blizzard Entertainment
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [libsdl.org](http://libsdl.org)  
> > [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)
