Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Calling NTMessageBoxSimple from a AddOn

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Calling NTMessageBoxSimple from a AddOn

    I am trying to invoke the call NTMessageBoxSimple from inside my AddOn code.

    I see the NTMessageBoxSimple requires access to some parent Window.

    In the examples, I found it requires a reference to ChartControl and needs to be called via InvokeAsync.

    https://ninjatrader.com/support/foru...ins#post729309

    Where my code logic lies subclassed from NTWindow there is no reference to a ChartControl?
    Last edited by archieoi; 08-22-2020, 02:31 PM. Reason: NTMessageBox, NTMessageBoxSimple, AddOn , c#

    #2
    lol solved my own question

    I guess using keyword "this" of what is subclassed from NTWindow will get the reference to its self as the window object
    Code:
    Dispatcher.InvokeAsync(() =>
    {
    NinjaTrader.Gui.Tools.NTMessageBoxSimple.Show(Wind ow.GetWindow(this as DependencyObject), "Hey there", "Guess What?", MessageBoxButton.OK, MessageBoxImage.Information);
    });

    Also a reference how to add other options to the popup
    Use the MessageBox.Show method in Windows Forms to display a dialog box. Change the buttons and text.
    Last edited by archieoi; 08-22-2020, 02:48 PM.

    Comment


      #3
      Hello archieoi,

      Yes, 'this' would refer to the parent class or object. The cast is to provide the current class as a window (DependencyObject) which is needed for Window.Show(). (NTMessageBoxSimple.Show())

      Thank you for updating you were able to find a solution.

      I've be sure our help guide gets updated with a page on NTMessageBoxSimple.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Using the keyword "this" seems not to work.
        I get this message error when using it :
        "Impossible de convertir le type 'NinjaTrader.Gui.NinjaScript.MyADDON' en 'System.Windows.DependencyObject' via une conversion de référence, une conversion boxing, une conversion unboxing, une conversion wrapping ou une conversion null type"

        Comment


          #5
          Hello thanajo,

          "this" refers the class of the current object. How are you trying to use this?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            I'm trying to have a MessageBox poping up when the user click on the addon item in the "new" menu.
            And I finally find a way to do so :

            In the "private void OnMenuItemClick(object sender, RoutedEventArgs e)" method, I'm accessing te the e.Source object as DependencyObject, and it's working.

            So the complete code of this block is :

            private void OnMenuItemClick(object sender, RoutedEventArgs e)
            {
            NinjaTrader.Gui.Tools.NTMessageBoxSimple.Show(Wind ow.GetWindow(e.Source as DependencyObject), "MessageBoxText", "Title", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            And when you click on the Item in the menu, you will see the MessageBox pop up.

            Comment


              #7
              Hello thanajo,

              I've given that a test and this seems to work without issue.

              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by frankthearm, Today, 09:08 AM
              3 responses
              7 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by yertle, Today, 08:38 AM
              5 responses
              15 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by adeelshahzad, Today, 03:54 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by bill2023, Yesterday, 08:51 AM
              6 responses
              27 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
              80 responses
              19,667 views
              5 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X