Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Instantiating external window

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

    Instantiating external window

    Hi,
    I'm trying to create a form as an initial prototype for a much larger project.

    I've built a dll with a form in Visual Studio targeted to Dot Net 4.5. I declare my using clause at the top:

    using NinjatraderTest;

    I then declare my form in my indicator class as follows:

    NinjatraderForm frm;

    I initially tried to instantiate the form in my State == State.SetDefaults:as follows

    frm = new NinjatraderForm();
    frm.Show();

    and destroying it in the State.Terminated:

    else if(State == State.Terminated)
    {
    frm.Close();
    }

    but I was getting multiple forms created whenever the Indicators form was was brought up. I realized my mistake and then moved the creation to State == State.Historical.

    But this seems to work but the dialog seems hung. I then thought this may be due to the multithreading and tried to use the Dispatcher and moving the creation and termination to the functions called by the Dispatcher. However this does not seem to work as the form doesnt 'appear'.

    Is there a concrete example on how to do this please?
    Thank-you,
    iq



    #2
    Hello iq200,

    Thank you for the post.

    If you are opening a totally new window it would likely be suggested to do it in the same way that our addon sample does, could you try doing the following and see if that works in your use case?



    Code:
    Core.Globals.RandomDispatcher.BeginInvoke(new Action(() => new NinjatraderForm().Show()));

    If that does not work I would say the next best way to figure out what is happening would be to look at the structure of what you created and compare that to the general NTWindow class shown in the above linked "addon basic" sample. That is able to open a new window so if you are doing it in a different way that may be part of the problem. Additionally you mentioned "Form", if you are referring to a non wpf window that could also relate to the problem.

    I look forward to being of further assistance.


    Comment


      #3
      Many thanks for your reply Jesse. I'll have a look.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X