My TitleBar buttons are disabled

I’ve never heard the term “daughter class” either, but I thought you might have meant it like “child class”…

First things first it’s not me but Monkol, I am assuming he meant derived class. Lets see. He will be on-line sometime soon.

My application CPP file:

#include “juce.h”
#include “MainWindow.h”

//==============================================================================
class JUCEDemoApplication : public JUCEApplication
{
public:

MainWindow* pMainWindow;

//==============================================================================
JUCEDemoApplication()	{ }
~JUCEDemoApplication()	{ }
//==============================================================================

void initialise (const String& commandLine)
{
    // just create the main window...
    pMainWindow = new MainWindow();			
}

void shutdown()
{
    deleteAndZero(pMainWindow);
}


//==============================================================================
const String getApplicationName()
{
    return T("JUCE Demo");
}

const String getApplicationVersion()
{
    return T("1.0");
}

};

//==============================================================================
/*
This macro creates the application’s main() function…
*/
START_JUCE_APPLICATION (JUCEDemoApplication)

My MainWindow.h

// MainWindow.h: interface for the MainWindow class.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include “juce.h”

class MainWindow : public DocumentWindow
{
public:
MainWindow();
~MainWindow();

protected:
void buttonClicked(Button* pButton);

private:
Button* pCloseButton;
};

My MainWindow.cpp

// MainWindow.cpp: implementation of the MainWindow class.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include “MainWindow.h”

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction/Destruction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

MainWindow::MainWindow()
: DocumentWindow(T(“Document”),
Colours::lightcoral,
DocumentWindow::allButtons, true)
{
setResizable(true, false);
centreWithSize(400, 200);
setVisible(true);

pCloseButton = getCloseButton();

}

MainWindow::~MainWindow ()
{

}

void MainWindow::buttonClicked(Button* pButton)
{
if (pButton == pCloseButton)
{
//if (AlertWindow::showYesNoCancelBox(AlertWindow::AlertIconType::QuestionIcon,
// “Do you want quit”,
// “Really”) == 1)
JUCEApplication::getInstance()->systemRequestedQuit();
}
}

Compiled program to demonstrate TitleBar disabled
http://rapidshare.com/files/344877141/example.exe.html

You don’t have to do this.

MainWindow::MainWindow()
: DocumentWindow(T("Document"),
Colours::lightcoral,
DocumentWindow::allButtons, true)
{
setResizable(true, false);
centreWithSize(400, 200);
setVisible(true);

pCloseButton = getCloseButton();
}

You can just.


// for the main class

void initialise (const String& commandLine)
{
     // i prefer setting bounds here
     pMainWindow = new MainWindow();
     pMainWindow ->centreWithSize (400, 200);
     pMainWindow ->setVisible (true);
}


MainWindow::MainWindow()
: DocumentWindow(T("Document"),
Colours::lightcoral,
DocumentWindow::allButtons, true)
{
     setResizable (true, false); // can be put in main class
    // set any component
}
// over-ride this method
void MainWindow::closeButtonPressed ()
{   
	JUCEApplication::getInstance()->systemRequestedQuit();
}

otherwise it looks okay to me.

I compiled your code and has old result…
May be problem in my windows or computer…

http://rapidshare.com/files/344914077/example2.rar.html

2 Jules: u r right about “child class”. “daughter class”(try to say: dochernij дочерний, deeper - производный ) - means inherits from an a base class, it’s a russian language :slight_smile: ( i’m russian, tartar! :slight_smile: ).U 'd treat this words, about “daughter class”, in the way of the parents and their kids, might be a little clearly :slight_smile:

2 Monkol: About the problem, never happens to me. u 'd try to build an example project from JUCE extras directory and try to put your code in there, and see what happens. Ah, a little question: do u have any overloads for virtual methods marked ‘for internal use’ ?

Thx, bye…

Alimjan (Алимжан) :slight_smile:

Which version of windows are you using? Did you try compiling juce demo? If so, Does it gives a disabled window?

Good news vishvesh…
Its not launching in my Pc and Windows 7 too…

@Monkol
R u derived the look and feel class of the JUCE.

Have u overloaded this method from the Look and feel class…

virtual Button * createDocumentWindowButton (int buttonType)

Another suggestion will be to use this code in the main window constructor

 getCloseButton ()->setEnabled( true );

getMinimiseButton ()->setEnabled( true );

getMaximiseButton ()->setEnabled( true );

I got the first exe to work on my machine(Windows XP). Didn’t try the other one.(not sure whether it’s a exe)

[quote=“Godwin”]
Have u overloaded this method from the Look and feel class…

virtual Button * createDocumentWindowButton (int buttonType)

Another suggestion will be to use this code in the main window constructor

[code]
getCloseButton ()->setEnabled( true );

getMinimiseButton ()->setEnabled( true );

getMaximiseButton ()->setEnabled( true );
[/code][/quote]

Jules might kill you for suggesting that. :smiley:

Not sure whether implementing "virtual Button * createDocumentWindowButton (int buttonType) " would be of much help, since he isn’t creating custom button.

getCloseButton ()->setEnabled( true );

getMinimiseButton ()->setEnabled( true );

getMaximiseButton ()->setEnabled( true );

It’s woooorks!!! :mrgreen:

It might seem to work, but is completely missing the point.

The buttons get disabled automatically when your window loses focus, and they get enabled when it gains focus. Your problem has nothing to do with the buttons themselves - the problem is that your window isn’t getting focus.

Have you tried actually putting a content component in your window so there’s something in it to actually focus on?

@Monkol
Have u used look and feel class in ur code???

[quote=“Godwin”]@Monkol
Have u used look and feel class in ur code???[/quote]

No i haven’t

I am inserted component

#include “MainWindow.h”
#include “NewComponent.h”
//==============================================================================
MainWindow::MainWindow ()
: DocumentWindow (T(“Coverflow Example”),
Colours::darkgrey,
DocumentWindow::allButtons,
true)
{
setResizable (true, false);
setResizeLimits (400, 300, 8192, 8192);
centreWithSize (800, 300);
setVisible (true);

NewComponent* newComponent = new NewComponent();
setContentComponent(newComponent);

}
//==============================================================================
MainWindow::~MainWindow()
{

}
//=============================================================================
void MainWindow::closeButtonPressed()
{
JUCEApplication::getInstance()->systemRequestedQuit();
}
//==============================================================================

But window has no focus, if i clicked on TitleBar and don’t maximised when doubleclicked on it

http://rapidshare.com/files/345292259/example3.rar.html

and it worked fine when u added the code

getCloseButton ()->setEnabled( true );

getMinimiseButton ()->setEnabled( true );

getMaximiseButton ()->setEnabled( true );

[quote=“Godwin”]and it worked fine when u added the code

getCloseButton ()->setEnabled( true );

getMinimiseButton ()->setEnabled( true );

getMaximiseButton ()->setEnabled( true );[/quote]

Yes it is works, but if the window lost focus buttons are stay Enabled

Hi! Are you using Windows 7? If so, try to switch off the ‘Aero’ first. Then try to use ‘standard’ theme for Windows XP or Windows7, i don’t know wich one u are…

Good Luck!

Try also calling newComponent->setWantsKeyboardFocus (true). By default, component don’t get focus.

It would be helpful to know what OS you’re running this on? (But don’t bother messing with Aero like the previous poster suggested, that’s not relevant)

I’m use XP SP3, I compiled example_project_for_Win32 and it’s work correctly!

Did you try my setWantsKeyboardFocus suggestion?