Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Momentaliry Disabling Scroll Bar

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

    Momentaliry Disabling Scroll Bar

    Hello,

    The template switcher is basically finished. Still have to convert the types to dynamic, but the core logic itself was coded with dynamic in mind (as in parsing enums at run time instead of calling the NinjaTrader namespaces directly, etc.). Anyways, a feature I would like to include would be the use of the scroll bar as a means to switch templates. That part is done. However, when using the scroll wheel it moves the chart.

    Would it be possible to momentarily disable the scroll bar? Not sure if that's possible so I tried to simulate the scroll wheel. It ends up scrolling forever.

    The infinite scrolling problem is more of a C# problem. Wanted to see if NinjaTrader has a quick solution before diving deeper into my solution.

    Working Normally

    Click image for larger version  Name:	9t9OH9U.gif Views:	0 Size:	839.9 KB ID:	1129453
    Infinite Scrolling

    Click image for larger version  Name:	qtgUTnC.gif Views:	0 Size:	63.0 KB ID:	1129454

    Thanks
    Last edited by Unsuitable; 11-25-2020, 07:32 PM.
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable, thanks for writing in. There would be no supported way to disable the default mouse behavior for a chart, unfortunately.

    Please let me know if I may provide any further information.

    Comment


      #3
      Hello ChrisL,

      I tried looking for a way to disable scrolling in ChartControl but there's none as you mentioned. Turns out the reason it's sending out infinite scrolling is that when it simulates a scroll movement (to cancel out the movement of the chart), that sends out another mouse scroll wheel mouse listener thus creating an infinite loop of scrolling. I tried to remove the event listener and re-add after the scroll method is called, but the re-subscribing of the event listener happens before the simulated scroll finishes. I also tried to store a bool, isScrolling, and set that to false after the object switches templates. Again, that process finishes before the simulated scrolling does and creates an infinite loop of scrolling.

      Code:
      [DllImport("User32.dll")]
      public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, IntPtr dwExtraInfo);
      
      private void MouseWheelEvent(object sender, MouseWheelEventArgs e)
      {
      
        if (!isSomethingSelected & storedDrawObjectSlected != null)
        {
          ChartControl.MouseWheel -= MouseWheelEvent;
          storedDrawObjectSlected = null;
          isSomethingSelected = false;
          return;
        }
      
        ChartControl.MouseWheel -= MouseWheelEvent;
      
        if (e.Delta > 0)
        {
          changeIndexBy = 1;
          ChangeChartObjectSetting(storedDrawObjectSlected);
          mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -120, (IntPtr) 0);
          ChartControl.MouseWheel += MouseWheelEvent;
          return;
        }
        else if (e.Delta < 0 )
        {
          changeIndexBy = -1;
          ChangeChartObjectSetting(storedDrawObjectSlected);
          mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 120, (IntPtr) 0);
          ChartControl.MouseWheel += MouseWheelEvent;
          return;
        }
      }
      This is a C# problem and I don't expect NT to support it. Perhaps if someone knows a solution.
      Unsuitable
      NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by sjsj2732, Yesterday, 04:31 AM
      0 responses
      26 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      283 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      280 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      131 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      90 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X