Resizable DocumentWindow AND hide the Maximize Button?

There was a thread on this a few months back when I was having the same problem, and I see now that I never closed the loop with code that worked for me.

In a file ‘osxUtil.mm’ (with the obvious header file next to it), I have:

#include "osxUtil.h"
#import <AppKit/AppKit.h>


#include "../JuceLibraryCode/JuceHeader.h"

void HideFullscreenButton(void* view)
{

	NSView* nsView = (NSView*)view;
	NSWindow* nsWindow = [nsView window];
	NSButton *button = [nsWindow standardWindowButton:NSWindowZoomButton];
	[button setHidden:YES];
	button.alphaValue = 0.0;
	[button setEnabled:NO];
	button.image = nil;
	button.alternateImage = nil;   

}

…and then at the end of my MainWindow ctor this:

#if JUCE_MAC
   ComponentPeer* peer = this->getPeer();
   HideFullscreenButton(peer->getNativeHandle());
#endif

Note that I banged my head against this for a while–placing this code earlier in the ctor had no effect. I’m not a deep enough macOS developer to know why that is. The code that’s posted here is based on code posted in the forum by @Rebbur, who I never thanked for the tip. Thanks!

5 Likes