Pop up message box doesn't work

Created at 04 Mar 2014, 14:09
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Cerunnos's avatar

Cerunnos

Joined 27.06.2013

Pop up message box doesn't work
04 Mar 2014, 14:09


Hi Spotware-Team!

I want to display a pop up message box with user32.dll  in my indicator, but it no longer works. Also the page P/Invoke Example with the sample code  has been removed. Why that? Is there now a new API alternative?

Thanks


@Cerunnos
Replies

Spotware
05 Mar 2014, 09:10

We didn't block P/Invoke approach. Everything should work.

You can find such example on MSDN.


@Spotware

Cerunnos
06 Mar 2014, 11:28

RE:

Spotware said:

We didn't block P/Invoke approach. Everything should work.

You can find such example on MSDN.

Thanks, but in my case it doesn't work within Calculate(). With Initialize() the message box appears...  

For example:

        [DllImport("user32.dll", CharSet=CharSet.Auto)]
        static extern int MessageBox(IntPtr hWnd, String text, String caption, int options);
        
        ...
             
        public override void Calculate(int index)
        {
        ...   
        if(ema_short.Result.HasCrossedAbove(ema_long.Result,0)...)
            {            
            var alertMessage = string.Format("EMA - CROSSING {0} ", Symbol.Code);
            MessageBox(IntPtr.Zero, alertMessage, "EMA - CROSSING", 0);                         }
           }
	...
        }

 


@Cerunnos

gainer
13 Feb 2016, 02:53

to show a popup you can also use the .net framework System.Windows.Forms

of course, remember to add the reference to System.Windows.Forms
________

....
using System.Windows.Forms;
.....

// the cBot must have the full access privileges
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]

...

protected override void OnStart()
{
    ...

    // check to avoid to use a live accounts by mistake
    if (Account.IsLive && MessageBox.Show("Warning!!! LIVE ACCOUNT!!!\r\n\r\nDo you want to continue anyway?", label, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
    {
        Stop();
        // I noticed that the Stop is immediate if you add also a return after it
        return;
    }

    ,,,
}

 


@gainer

kliko
29 Dec 2016, 16:04

RE:

Cerunnos said:

Hi Spotware-Team!

I want to display a pop up message box with user32.dll  in my indicator, but it no longer works. Also the page P/Invoke Example with the sample code  has been removed. Why that? Is there now a new API alternative?

Thanks

What was that example that about? I search for a way to draw custom shapes on the chart window and attach callbacks to mouse events on them (clicks, mouseenter, mouseleave, etc).


@kliko

hayes_paul
01 Jul 2022, 15:53

Try this it works.

 

 


@hayes_paul