# Crash in juce\_win32\_windowing.cpp

**URL:** <https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838>\
**Category:** Windows\
**Created:** [December 9, 2011, 9:47am UTC](https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838 "2011-12-09T09:47:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adit](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Adit](https://forum.juce.com/u/Adit)\
**Post date:** [December 9, 2011, 9:47am UTC](https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838/1 "2011-12-09T09:47:12Z")

</div>

Hi,  
my juce application crashes, whenever i have 2 juce application running together.  
my juce applications are developed using juce\_1\_53 version of juce.  
Scenario:  
i have launched my application\_1 and it has a scrollbar, now i simultaneously launch juce\_helloworld app , now i give focus to juce\_helloworld app and do mouse wheel move on my application\_1 , juce\_helloworld app crashes…  
similarly if i give focus to my application\_1 and do mouse wheel move on juce\_helloworld app my application\_1 crashes at the below shown code.

updateKeyModifiers();  
const float amount = jlimit (-1000.0f, 1000.0f, 0.75f \* (short) HIWORD (wParam));

// Because win32 stupidly sends all wheel events to the window with the keyboard  
// focus, we have to redirect them here according to the mouse pos…  
POINT p = { globalPos.getX(), globalPos.getY() };  
Win32ComponentPeer\* peer = getOwnerOfWindow (WindowFromPoint §);

if (peer == nullptr)  
peer = this;

—\>place of crash-----\> peer-\>handleMouseWheel (0, peer-\>globalToLocal (globalPos), getMouseEventTime(),  
isVertical ? 0.0f : -amount,  
isVertical ? amount : 0.0f);

can somebody help me on this. where am i going wrong. ☹ i am not able to solve this issue for quite sometime now.

---

<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:** [December 9, 2011, 9:54am UTC](https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838/2 "2011-12-09T09:54:46Z")

</div>

Hmm. Interesting. I think I know what this may be, and will add some code to the modules branch today which should help, but it’d be up to you to translate that back to the old 1.53 version if you don’t want to update.

---

<div class="post-metadata">

**Author:** ![Adit](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Adit](https://forum.juce.com/u/Adit)\
**Post date:** [December 9, 2011, 10:02am UTC](https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838/3 "2011-12-09T10:02:45Z")

</div>

Thanks Jules, for replying.

i tried with previous version of juce i.e. juce\_1\_51, the code there is entirely different.

updateKeyModifiers();

const float amount = jlimit (-1000.0f, 1000.0f, 0.75f \* (short) HIWORD (wParam));

handleMouseWheel (0, position, getMouseEventTime(),  
isVertical ? 0.0f : amount,  
isVertical ? amount : 0.0f);

but i don’t want to mess around with juce code myself.

And I am ready to translate whatever changes you make.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Adit](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Adit](https://forum.juce.com/u/Adit)\
**Post date:** [December 9, 2011, 10:14am UTC](https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838/4 "2011-12-09T10:14:44Z")

</div>

I believe you may want to make some changes in getOwnerWindow() method… and if you could explain the cause of bug… i would be grateful to you…

---

<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:** [December 9, 2011, 10:20am UTC](https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838/5 "2011-12-09T10:20:22Z")

</div>

It tags windows with an integer to recognise them as being juce windows, but I don’t think that number was unique to each app, so it may be incorrectly trying to pull a pointer out of a foreign window.

I’ve committed a fix now, so have a look at the diff, but I think the classes may be different to the way it was done in the old version.

---

<div class="post-metadata">

**Author:** ![Adit](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Adit](https://forum.juce.com/u/Adit)\
**Post date:** [December 9, 2011, 10:39am UTC](https://forum.juce.com/t/crash-in-juce-win32-windowing-cpp/7838/6 "2011-12-09T10:39:38Z")

</div>

godly jules!!!  
Thanks a lot!!! i even got your explanation…  
I made the changes you committed, to the version of juce i have. And it worked… No crash… Now i can happily run all my juce applications together 😉

Thanks a lot. 🙂
