Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Config window start position when windows text size (DPI) != 100%?

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

    Config window start position when windows text size (DPI) != 100%?

    When the user have set the default 100% font size in their windows settings the toolbar config menu window opens perfectly where the user clicked the toolbar icon.

    But when the windows font size is set to 125% or 150%,... the config window opens way more to the right und more down - see the screnshots below.

    How can I ensure that the config window opens directly where the user clicked even if the user windows font size is set to >100%?

    Code I use at the moment:
    Code:
    private void PreviewMouseDown(object sender, MouseButtonEventArgs e) {
        vl.ChartControl.Dispatcher.InvokeAsync(() => {
            clickPointScreen = vl.ChartControl.PointToScreen(e.GetPosition(vl.ChartControl));
        });
    }
    private void WindowCreate() {
        cw = new ConfigWindowInit() {
            Top = clickPointScreen.Y,
                Left = clickPointScreen.X,
        };
        cw.ShowConfigWindow();
    }​
    Attached Files

    #2
    Hello Heart,

    Thanks for your post.

    We have a sample script on the help guide called SampleWPFModifications that demonstrates how to create a custom menu on the title bar of the chart.

    I am unable to reproduce the behavior you are reporting when testing this with the SampleWPFModification reference sample.

    Please review the SampleWPFModifications reference sample linked below to see if you are able to reproduce the behavior and report your results.

    If you are not able to reproduce the behavior, you could compare your script's code to the reference sample code to see where differences might be when it comes to creating a custom menu on the title bar of the chart.

    SampleWPFModifications: https://ninjatrader.com/support/help...ui)-modifi.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks NinjaTrader_BrandonH - Unfortunately, these wpf modification examples don't help here, because no window is opened there, just some buttons are pressed. That's not the problem.

      Comment


        #4
        Hello Heart,

        Thanks for your notes.

        There is not any NinjaScript-specific code that deals with DPI and Window Positioning so this would go beyond the support we would be able to provide you with.

        You could research general WPF ways to account for the DPI and Window Positioning change to find more information about this topic.

        This forum thread will be open for other community members to share their insights as well.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Here is a possible solution

          Code:
          public System.Windows.Point GetTopLeftWindowPosition(Visual visual, double width, double height)
          {
              var output = new System.Windows.Point();
          
              if (visual == null)
              {
                  return output;
              }
          
              double dpiFactor = PresentationSource.FromVisual(visual).CompositionTarget.TransformToDevice.M11;
              //get mouse clickpoint convertet to screen
              var mousePoint = visual.PointToScreen(Mouse.GetPosition((IInputElement)visual));
              //top
              double top = (SystemParameters.PrimaryScreenHeight - height) / 2;
              double offset = top - (mousePoint.Y / dpiFactor);
              output.Y = top - offset;
              //left
              var left = (SystemParameters.PrimaryScreenWidth - width) / 2;
              offset = left - (mousePoint.X / dpiFactor);
              output.X = left - offset;
          
              return output;
          }
          sidlercom80
          NinjaTrader Ecosystem Vendor - Sidi Trading

          Comment


            #6
            Thanks sidlercom80

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X