WindowWillResize equivalent

Is there an equivalent of this Cocoa function in Glut? I want to trap the resize event before it occurs.

Basically, under certain conditions I want to be able to prevent the user from being able to resize the window.

Any suggestions?


You might want to throw into this feature request:

All you’d need to do in that case, is have stored the last size, and just set it back when the window has been resized.

Yes, that’s the route I had taken, but the only problem is that the user can still drag the window as if to resize, except that now it pings back to the fixed width and height due to my custom resize event.

Just a little counter intuitive is all, but nothing too serious.

there might be an osx way to control properties of the window that could prevent it from being resized in the first place.

for example, on a pc, this code forces the window:

a) to be the topmost window (like a loading dialog)
b) not resizeable
c) no border or top menu (or shadow), just the window itself.

if (!showWindowBorder){  
		HWND m_hWnd = WindowFromDC(wglGetCurrentDC());  
		LONG style = ::GetWindowLong(m_hWnd, GWL_STYLE);  
		style &= ~WS_DLGFRAME;  
		style &= ~WS_CAPTION;  
		style &= ~WS_BORDER;  
		style &= WS_POPUP;  
		LONG exstyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);  
		exstyle &= ~WS_EX_DLGMODALFRAME;  
		::SetWindowLong(m_hWnd, GWL_STYLE, style);  
		::SetWindowLong(m_hWnd, GWL_EXSTYLE, exstyle);  
		HWND_TOPMOST, 0,0,0,0,  

there is probably a mac equivalent to setWindowLong…

hope that helps!

1 Like

What you suggest sounds plausible except for one minor detail.

I’ve read that GLUT on Mac OS X does not use Carbon, so there is no WindowRef for its
window. However, it would seem that AGL and NSOpenGL are the routes through to the native OS windowing system when using GLUT, ( OS X equivalents of WGL ).

Has anyone succeeded in linking to the AGL or Cocoa frameworks on OSX? (AppKit from Cocoa would be sufficient)?


oh yeah, that’s a pain. I was just playing around since I’m new to mac, and wanted to know how to do cocoa stuff… this code snippet will get you the ability to control the NSwindow. Here I just set it to be transparent :slight_smile:

take care,


This code snippet is so extremely helpful; thanks! Just needed a quick way to hide all borders and was able to throw this in setup()