Simple Benchmark application

No, you don’t need that if you want to create many identical windows.

The .h file just declares a new “class” (or type) of windows, where there will be some code to set up the window with its buttons, controls, scrollbars, etc as needed. Once this is all defined, you can create many new windows.

In the example I gave earlier, I just created an empty BWindow without any specialization:

BWindow* window = new BWindow(...);
window->Show();

Qs I mentionned we need to provide some more info as documented in BWindow documentation. So here is a more complete version:

BWindow* window = new BWindow(BRect(100, 100, 300, 300), "Test window", B_DOCUMENT_WINDOW, 0);
window->Show();

In this case you do not need any new .h files and class declarations, since you are just using the basic BWindow already provided by Haiku and don’t need to add anything to it.

So let’s put it all together:

void
MainWindow::MessageReceived(BMessage *msg)
{
// The way that BMessages are identified is by the public property ‘what’.
switch (msg->what)
{
    // If the message was the one sent to the window by the button
    case M_BUTTON_CLICKED:
    {
        // Here is the code that is run when the button is clicked
        BWindow* window = new BWindow(BRect(100, 100, 300, 300), "Test window", B_DOCUMENT_WINDOW, 0);
        window->Show();
	    break;
    }
    // Here there are probably more cases for other messages that can be received
}

Now, every time you click your button, a new window should appear.

Also, when sharing code on the forum, it will look much easier to read if you use the Preformatted text button (it looks like this: </>) or put some marks around your code: ``` at the start and at the end of the code block. Otherwise the forum will attempt to reformat it and it will be a bit unreadable.