0

In our legacy code Windows extended style WS_EX_TOOLWINDOW is being used.This is basically for showing the title bar narrow.But recently in the later winodws versions the title bar is not drawn as narrow.That is WS_EX_TOOLWINDOW doesnt give a narrow title bar in the newer windows versions.Making the title bar narrow is done on a click event.Let me know if there is another way of achieving this?

I have read that we need to handle WM_NCCALCSIZE.But is there any other way of doing it?.Or if this is the only way,how can I handle it in a button click?

Code Snippet:

HWND hwnd = m_hWnd;
......

DWORD dwStylesEx = ::GetWindowLong( hwnd, GWL_EXSTYLE );

if ( bNarrowTitle == true)
{
    dwStylesEx |= WS_EX_TOOLWINDOW;
}
else
{
    dwStylesEx &= ~WS_EX_TOOLWINDOW;
}
...

::SetWindowLong( hwnd, GWL_EXSTYLE, dwStylesEx );
Sana
  • 47
  • 8
  • 1
    Please provide a [mcve] . That is, show us some code that repros the issue – selbie Jun 03 '19 at 05:25
  • I have provided the code snippet. – Sana Jun 03 '19 at 06:18
  • 5
    That's hardly an MCVE. I have many years of Win32 programming experience. I'm engaged and motivated to debug your issue. But do you think, if I just took that code as-is, I have to enough to copy into a local Visual Studio project and suddenly reproduce your issue? Probably not. Go write a complete sample program with a WinMain that shows the same issue and post it. Or at least tell me one thing you did to debug the issue such as validating API return codes, using WinSpy to validate if the style was applied, etc.... You aren't going to get good answers unless you ask a good question. – selbie Jun 03 '19 at 06:41
  • Sorry,I thought one who knows about these would be able to help by looking at this code.But I will post the entire code.And regarding the style getting applied,when the style is applied I have problem with only title bar.Other properties getting changed.So though style is getting applied,title bar doesn't have any effect. – Sana Jun 04 '19 at 07:03

2 Answers2

0

MSDN says:

Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • SetWindowPos is already used.when the style is applied I have problem with only title bar.Other properties getting changed.So though style is getting applied,title bar doesn't have any effect.But MSDN says " ..A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font.." – Sana Jun 04 '19 at 07:05
  • Your code example did not call it. The exact size and style depends on the visual style, user metrics and font. If the icon and minimize/maximize buttons go away then it is a toolwindow. – Anders Jun 04 '19 at 10:20
0

The default look just doesn't distinguish it in any way. Which suggests that you will just have to live with it.

It's probably been changed due to not being finger friendly if smaller!

Refer : WS_EX_TOOLWINDOW doesn't give look I want

As you said, handle WM_NCCALCSIZE may be the only way to handle the size of non-client areas.

Refer: How to set the size of the Non-client area of a Win32 window (native)

Strive Sun
  • 5,988
  • 1
  • 9
  • 26