Pop up message box doesn't work

04 Mar 2014, 14:09Pop up message box doesn't work#1
Cerunnosposts: 123since: 27 Jun 2013

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

05 Mar 2014, 09:10#2
cTrader Teamposts: 3391since: 23 Sep 2013

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

You can find such example on MSDN.


TRADERS FIRST™ Vote for your favorite features: http://vote.spotware.com/
06 Mar 2014, 11:28RE:#3
Cerunnosposts: 123since: 27 Jun 2013

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);                         }
           }
	...
        }

 

13 Feb 2016, 02:53#4
Marco posts: 29since: 24 Jan 2016

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;
    }

    ,,,
}

 


my nick "gainer" stands for the parkour evolution where you backflip while running forward, the minimum error and you smash your face or worst... I don't know why, but this remember me the forex!
29 Dec 2016, 16:04RE:#5
klikoposts: 2since: 29 Dec 2016

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).