# More native window fun

**URL:** <https://forum.juce.com/t/more-native-window-fun/765>\
**Category:** General JUCE discussion\
**Created:** [March 31, 2006, 12:22am UTC](https://forum.juce.com/t/more-native-window-fun/765 "2006-03-31T00:22:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [March 31, 2006, 12:22am UTC](https://forum.juce.com/t/more-native-window-fun/765/1 "2006-03-31T00:22:38Z")

</div>

In Windows, Alt-F4 doesn’t close the window in native mode, but does work in non-native mode.

Same results with command-W on Mac OS X.

In Windows, you can sometimes hit alt-spacebar to get the system menu for the window and sometimes not. I haven’t figured out the pattern, but it’s not consistent.

Sorry to gripe so much - I’m really pleased to see native window support added.

Matt

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 3, 2006, 8:32am UTC](https://forum.juce.com/t/more-native-window-fun/765/2 "2006-04-03T08:32:38Z")

</div>

Could it just be that it won’t work unless you’ve got a close button on there?..

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [April 3, 2006, 4:05pm UTC](https://forum.juce.com/t/more-native-window-fun/765/3 "2006-04-03T16:05:44Z")

</div>

It doesn’t work with the demo app, on either platform. Sorry…

Matt

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [April 3, 2006, 4:12pm UTC](https://forum.juce.com/t/more-native-window-fun/765/4 "2006-04-03T16:12:53Z")

</div>

While I’m complaining, there’s one other minor issue. On WinXP, when you mouse over the title bar buttons of non-JUCE apps, you see a subtle highlight on the button you’re rolling over. With the latest JUCE stuff, you don’t get the roll-over highlight.

Sorry to complain so much. : )

Matt

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 3, 2006, 4:59pm UTC](https://forum.juce.com/t/more-native-window-fun/765/5 "2006-04-03T16:59:39Z")

</div>

oh that really is subtle! It’s a typo in juce\_win32\_Windowing.cpp, line 1850ish. Should be:

```auto
            case WM_NCMOUSEMOVE:
                if ((styleFlags & windowHasTitleBar) != 0)
                    return DefWindowProc (h, message, wParam, lParam);

```

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [April 3, 2006, 10:09pm UTC](https://forum.juce.com/t/more-native-window-fun/765/6 "2006-04-03T22:09:23Z")

</div>

[quote=“jules”]oh that really is subtle! It’s a typo in juce\_win32\_Windowing.cpp, line 1850ish. Should be:

[code]  
case WM\_NCMOUSEMOVE:  
if ((styleFlags & windowHasTitleBar) != 0)  
return DefWindowProc (h, message, wParam, lParam);

[/code][/quote]

I just tried it and it works fine. Nice.

I realize that this is the World’s Least Important Bug, but it’s good to have it fixed. Thanks.

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [April 3, 2006, 11:24pm UTC](https://forum.juce.com/t/more-native-window-fun/765/7 "2006-04-03T23:24:09Z")

</div>

For Windows, I added this to peerWindowProc and alt-F4 closes the window with the native title bar active:

```auto
			case WM_SYSCOMMAND :
				if ((styleFlags & windowHasTitleBar) != 0)
				{
					if (SC_CLOSE == wParam)
						handleUserClosingWindow();

                return DefWindowProc (h, message, wParam, lParam);
				}

				return 0;
```

Alt-spacebar still doesn’t work quite right; if you click on the native title bar and then hit alt-spacebar, you get the system menu every time. If you click elsewhere in the window and hit alt-spacebar, you don’t get the system menu.

Matt

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 4, 2006, 8:35am UTC](https://forum.juce.com/t/more-native-window-fun/765/8 "2006-04-04T08:35:52Z")

</div>

Ah, nice one. Not sure about the ctl+space thing, it’s probably getting eaten by my key handler callbacks.

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [April 4, 2006, 10:55pm UTC](https://forum.juce.com/t/more-native-window-fun/765/9 "2006-04-04T22:55:23Z")

</div>

Looks like it should actually be this:

[code] case WM\_SYSCOMMAND :  
if ((styleFlags & windowHasTitleBar) != 0)  
{  
if (SC\_CLOSE == wParam)  
handleUserClosingWindow();

```
			}

			break; // let DefWindowProc handle it

```

[/code]

Otherwise, you can’t close the window from the taskbar if you’re not using native mode.

I don’t know why DefWindowProc doesn’t just issue the WM\_CLOSE message in response to WM\_SYSCOMMAND when you’re in native mode.

Matt

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [April 27, 2006, 12:41am UTC](https://forum.juce.com/t/more-native-window-fun/765/10 "2006-04-27T00:41:35Z")

</div>

A further change:

[code] case WM\_SYSCOMMAND :  
if ((styleFlags & windowHasTitleBar) != 0)  
{  
if (SC\_CLOSE == (wParam & 0xfff0))  
handleUserClosingWindow();  
}

```
			break;

```

[/code]

Windows uses the low four bits of wParam internally, so you have to mask it.

Matt

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 10:02am UTC](https://forum.juce.com/t/more-native-window-fun/765/11 "2017-05-12T10:02:22Z")

</div>

Closed on May 12, 2017, 10:02am UTC


