# Alert Window ownership question

**URL:** <https://forum.juce.com/t/alert-window-ownership-question/3840>\
**Category:** General JUCE discussion\
**Created:** [April 16, 2009, 7:08pm UTC](https://forum.juce.com/t/alert-window-ownership-question/3840 "2009-04-16T19:08:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exponential\_Audo](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@Exponential\_Audo](https://forum.juce.com/u/Exponential_Audo)\
**Post date:** [April 16, 2009, 7:08pm UTC](https://forum.juce.com/t/alert-window-ownership-question/3840/1 "2009-04-16T19:08:34Z")

</div>

I’ll fully admit to an attack of the stupids, but I’m trying to understand the AlertWindow class. Here’s some example code:

[code] pAlertWindow = new AlertWindow(T(“Alert”), T(“Run for your life!”), AlertWindow::NoIcon);  
pAlertWindow-\>addButton(T(“OK”), 0);

// Very ugly colors here  
pAlertWindow-\>setColour(AlertWindow::backgroundColourId, Colour::Colour(0xff404040));  
pAlertWindow-\>setColour(AlertWindow::textColourId, Colour::Colour(0xffff8080));  
pAlertWindow-\>setColour(AlertWindow::outlineColourId, Colour::Colour(0xff000000));

// addChildComponent(pAlertWindow);

pAlertWindow-\>runModalLoop();  
pAlertWindow-\>setVisible(false);  
[/code]

First of all, this is the main editor component for an audio plugin. Second, I’m running the 1.46 version of Juce. I have two questions related to this code

[list]If I add the alert window as a child component (by uncommenting it), it doesn’t seem to appear anywhere on my screen. In addtion, I can’t seem to attract its attention (it never exits the loop), so I have to halt the parent application. BTW, calling toFront doesn’t seem to make any difference.

The call to ‘runModalLoop’ makes the alert visible, but I seem to have to manually turn off visibility after the loop exits. I thought this was taken care of by the loop exit code.[/list]

I’m trying to attach this thing as a child component so that it will appear in the vicinity of the plugin window. Have I got my head wrapped around this wrong? Thanks for any nudges in the right direction.

---

<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 18, 2009, 1:16pm UTC](https://forum.juce.com/t/alert-window-ownership-question/3840/2 "2009-04-18T13:16:26Z")

</div>

I made some changes in the tip code recently to make this easier… Can’t really remember if there are obstacles to doing it with the 1.46 codebase.

---

<div class="post-metadata">

**Author:** ![vishvesh](https://avatars.discourse-cdn.com/v4/letter/v/85e7bf/32.png) [@vishvesh](https://forum.juce.com/u/vishvesh)\
**Post date:** [April 18, 2009, 1:29pm UTC](https://forum.juce.com/t/alert-window-ownership-question/3840/3 "2009-04-18T13:29:55Z")

</div>

Hi,  
I had used it this way

```auto
juce::AlertWindow *alert = new juce::AlertWindow (T("Enter the text"),T("DISC ID"), juce::AlertWindow::InfoIcon );
	alert->addButton (T("Continue"),1,juce::KeyPress(),juce::KeyPress());
	alert->addTextEditor (T("edit"),T(""),T("Disc Id"));
	alert->addToDesktop (4); 
	alert->setBounds(230,150,300,500);
	int returnValue = alert->runModalLoop();
       delete alert
```

You can see you have not set any bounds for it nor have you made it visible.
