Remove title bar from main window


#1

 

Hi, how would it be possible to remove the title bar from the main application window?

Thanks,

Baptiste


#2

I was looking for the answer myself.
Searched through all methods there, found nothing.
HOWEVER, managed to get a workaround going which does the job flawlessly.
in Main.cpp file’s constructor, set these:

        setUsingNativeTitleBar (false);
        setTitleBarHeight(0);

setting Height with native title bar does nothing, but with that turned off and height 0 it hides it completely.


#3

Another way to do it, maybe less hacky, is not to instanciate a DocumentWindow component but a simple Component instead, and call addToDesktop to it.

The default class MainWindow in main.cpp inherit from DocumentWindow. First we need to remove this inheritance, and instanciate the MainContentComponent as a root component.

class MainWindow
{
public:
    MainWindow (String name)
    {
        mMainCompotnent = createMainContentComponent();
        mMainCompotnent->setVisible (true);
        mMainCompotnent->addToDesktop (ComponentPeer::windowHasDropShadow);
    }

    ~MainWindow()
    {
        delete mMainCompotnent;
    }
    
private:
    Component * mMainCompotnent;
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
};

#4

wizard! there is one issue with both methods though, the window can’t be dragged. Can’t find a solution as of yet… Probably a method already exists for something like this, else it could be “hacked” with mouseDrag events, im sure. New to JUCE I am :confused:


#5

You can use ComponentDragger to implement dragging. Using some conditions within mouseDown/mouseDrag (e.g. “if (e.getMouseDownY() < 20)”) you can also make dragging available within a given area instead of the whole component.


#6

works like magic! thx :slight_smile: