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

Launching NTWindow

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

    Launching NTWindow

    Hello, i am launching a new NTWindow within an indicator.

    How can i set this to be modal - is there an owner attribute i need to set to be the parent chart window?

    thanks

    #2
    Hello,

    For a window to be a Modal and not just Always on top like most NT windows, you would need to utilize the ShowDialog() method to show the window in addition to setting its Owner property to the parent window.

    We don't have a sample of this specifically but these are standard properties on Window which NTWindow is derived from.

    Code:
    Dispatcher.Invoke((Action)(() => {  				
        Window 	chartWindow = Window.GetWindow(ChartControl.Parent) as Window;
        NTWindow win = new NTWindow();
        win.Owner = chartWindow;
        win.ShowDialog();
    }));

    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 08-09-2017, 11:40 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks, yes in searching i realise NTWindow derived from that. Which is why i was asking on the owner as you have illustrated. I want to emulate the same process as say opening the indicator panel - is the always on top again another standard property or is a property of NTWindow ? - as i would like it to always be on top to ensure is processed and not hidden

      thanks

      Comment


        #4
        Hello,

        The use of a Modal by using ShowDialog and the Owner property is the suggested way to make a modal window that is on top of the parent window. This would also prevent other windows from being clicked or taking focus. This would be similar to the Indicator window.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello, following from the below I now have the following scenario which is part of the Addon Section of the application i am working on.

          I have owner for the parent window which happens to be the chart window.
          So a new NTWindow is opened and i set the owner and use ShowDialog() - so all is good.

          I now have sub NTWindows from this NTWindow which is invoked via the AddonBase.

          I also would like this to then be set to modal but the parent is already modal.

          I have read up on some of how to potentially handle this -
          1. get the parent NTWindow A and this will be the owner
          2. temporarily disable the modal property of the 1st NTWindow A
          3. set modal for the new sub window B
          4. when then new sub window B is closed - reset back the modal property of the prior NTWindow A

          in order to do this ... .how do i get the window id of the NTWindow A in the constructor of this? Then i can pass this into the constructor of each sub window that may be invoked..

          The reason i have the above is that NTWindow A has several tabs which then launch separate sub NTWindows..

          If there is another way to approach this let me know - & or how to get the window id of NTWindow A and not the parent of this which is the chart which is 2 levels above
          thanks

          Comment


            #6
            Hello, im just wondering is there a big backlog of issues support are working on? Or will jesse be the person to respond to below?
            thanks

            Comment


              #7
              Hello,

              I just wanted to reply to let you know this item will be reviewed and replied to. We do have a number of items to work through so there can be a delay when posting on the forums.

              Once I have reviewed your reply, I will reply back with further details.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Hello,

                After reviewing your comments further my current thought on this would be that you could pass an instance of a window to another window when you create it to allow access the methods or property of that instance.

                When you create the window, you do not have to immediately call Show or ShowDialog, you can pass in an instance to the owner window before showing the window. You can then use this instance in the sub window call public methods of the owner window where you could toggle the owner or do other actions.

                WIthout seeing what you are currently trying it would be difficult to give any direction or example. Do you have a simple example of the structure you currently have and how you are opening the subwindow? If you can provide an export that demonstrates the problem I may be able to provide a more accurate answer on what may need to occur with your specific code.


                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hello, thanks for the confirmation - as i had suggested i passed down the parent NTWindow and was able to set the owner and ShowDialog for the child windows - and works well for my purposes - it wasnt as complicated as some other .net and wpf forums seemed to indicate - so i now have each subequent NTWindow as modal focusing user to work on this open dialog until closed.

                  What i did need to change to get this working and brings up another question.

                  I did use previously ;

                  Globals.RandomDispatcher.InvokeAsync((Action)(() =>

                  in the code to handle the button/image which launches the window

                  but it seemed to need quite a few button clicks to get a response to then show the dialog etc.

                  So i changed it to :

                  Dispatcher.InvokeAsync((Action)(() =>

                  and it works perfectly so far with some testing ....

                  the original parent window in the Addonbase is called using :

                  _chartControl.Dispatcher.InvokeAsync((Action)(() =>

                  using the chartcontrol and this works for launching the parent NTWindow which is set to modal...

                  I then tried to pass down the chartcontrol to use this for the children but couldnt seem to get this to work and even though setting the value - it was null at the time i was launching the dispatcher with a null check ...

                  Is there any rule/guidance as to which version or mode of calling dispatcher to use - i read the help page but it didnt differentiate on the different ways. And then there is the BeginInvoke method which i have used but not sure why.

                  any input on the above?

                  thanks

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    Regarding dispatchers, in general, you would need to use the dispatcher for the thread being used. For example, if you are modifying some control of the ChartControl, you would want to use the ChartControls dispatcher. This is pretty much the same for most objects and you would get an error in the output if you try to access different threads object with the incorrect dispatcher or without a dispatcher. As far as which invoke to use, we suggest always using InvokeAsync to allow NinjaScript methods to continue. We do have a short guide at the following link, I am unsure if this is the same information you had mentioned already: http://ninjatrader.com/support/helpG...-threading.htm

                    As far as your issue surrounding passing the chart control, I am unsure in this case why the object would be null without seeing some example of what had been tried. You are able to pass instances of objects to other objects, perhaps the ChartControl was null at the time when the object was passed? If you have a sample of what you had tried here, I could try to provide guidance.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Barry Milan, Today, 10:35 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by WeyldFalcon, 12-10-2020, 06:48 PM
                    14 responses
                    1,428 views
                    0 likes
                    Last Post Handclap0241  
                    Started by DJ888, Yesterday, 06:09 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    3 responses
                    40 views
                    0 likes
                    Last Post jeronymite  
                    Started by bill2023, Today, 08:51 AM
                    2 responses
                    16 views
                    0 likes
                    Last Post bill2023  
                    Working...
                    X