Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove "Untitled - " from main frame window caption

Tags:

c++

mfc

I have an MFC document application where I want to remove the "Untitled - " from the caption.

It way my understanding that I need to remove the 'AddToTitle' property from the window style, and then I can set the title, and the'untitled' string would not be added.

I tried the following, but it does not work.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 ...

    lpCreateStruct->cx &= ~FWS_ADDTOTITLE;
    this->SetTitle(L"The New Title");
}

Anyone know how to remove 'Untitled' from the main window title?

Thanks,
-Matt

like image 744
netcat Avatar asked Mar 15 '26 19:03

netcat


1 Answers

OnCreate is simply too late. You have to modify the style before the window is created. Just remove FWS_ADDTOTITLE in PreCreateWindow.

This is fairly well documented here.

like image 166
xMRi Avatar answered Mar 18 '26 10:03

xMRi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!