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

Create own MessageBoxWindow with MessageBoxResult

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

    Create own MessageBoxWindow with MessageBoxResult

    Hi, I have a problem with my own message box. I don't know exactly how to implement the "MessageBoxResult" to make it work properly. Maybe someone can help me.
    This is what the message box looks like:

    Click image for larger version

Name:	NinjaTrader_fi8Ut9MwZF.jpg
Views:	153
Size:	4.5 KB
ID:	1218755

    I hereby call the messagebox
    Code:
    var result = MessageBoxTest.Show(ChartControl, "Text");
    await result;
    
    Print("1=>" + result.Result);
    I don't know how to implement this correctly in the. Show method so that I get the feedback when the "Ok" button was pressed. After the "Ok" button is pressed, for example, a next method with other functions should be executed, but only after the "Ok" button was pressed and not already when the window was opened.

    Code:
        public static async Task<MessageBoxResult> Show(ChartControl chartControl, string text, MessageBoxButton buttons = MessageBoxButton.OK)
            {
                if (chartControl == null)
                {
                    return MessageBoxResult.None;
                }
    
                MessageBoxWindowTest msgBox = null;
                System.Windows.Threading.DispatcherOperation msgResult = null;
    
                msgResult = chartControl.Dispatcher.InvokeAsync(() =>
                {
                    msgBox = CreateMessageBox(chartControl, text, buttons);
                    if (msgBox != null)
                    {
                        msgBox.Show();
                        return msgBox.MsgBoxResult;
                    }
    
                    return MessageBoxResult.None;
                });
    
                await msgResult;
    
                return msgBox.MsgBoxResult;
            }
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    The call and return of the message box would be synchronous. Meaning within the same block of the InvokeAsync action, trigger whatever actions you are going to trigger with the message box result.

    Below is a link to a forum post with tips.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB, thank you for your reply. Unfortunately, with this variant, the chart is locked. Is there no alternative where a message box is displayed while the chart is not locked, waiting for the message "MessageBoxResult"? I would like to call only .Show() instead of .ShowDialog(), because with .Show() the chart is not locked. Unfortunately, the "MessageBoxResult" do not arrive there.
      Last edited by sidlercom80; 10-10-2022, 09:27 AM.
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        Hello sidlercom80,

        The MessageBox is intended to be a modal window (meaning the chart or calling window is locked) and is intended to be code blocking until the OK or Cancel is clicked.

        If you want a window that is not modal, you can open an actual window.

        For example:



        The result of the message box can be called directly under the show which is synchronous, but not outside of the invoke action.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        9 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,235 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        3 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        8 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,415 views
        0 likes
        Last Post Traderontheroad  
        Working...
        X