Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator affecting window resizing

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

    Indicator affecting window resizing

    Hello,
    I've created a relatively simple indicator. It consists of several buttons added to the menu bar. They access methods which turn on/off chart drawing objects. The indicator does what it's supposed to. The glich is that if I have a chart maximized, select one of the buttons I've added, and then restore the chart to it's previous size the menu bar is widened. The chart is still fully functional. Another maximize and restore (no buttons selected) will return the chart window to it's normal display. My question is has anyone ever seen this behavior before. I've troubleshot various sections of the script to no avail for over a year. If anyone has any suggestions I would definitely appreciate them.
    Attached Files

    #2
    Hello ramckay,

    How are you adding the menu item to the chart? Normally when you add menu items they are appended to the menustrip and will be the last added item, just to the right ofthe last icon in the toolbar. Your placement seems to be inside the grid with the windows control buttons.

    If possible please provide a small sample that demonstrates the placement of the toolbar in the code and also shows the expanding problem. You can make a copy of your current script and remove any of your propritary logic leaving just a menu with the dropdown and 1 button so we can explore that further.

    Comment


      #3
      Hi Jesse,
      Thanks for the quick respone.
      Code:
       // Instantiate the buttons
      btnUserDrawObjs = new System.Windows.Controls.Button();
      
       // Set button names
      ​btnUserDrawObjs.Content = "Toggle Draw";
      
      // Set Button style  
      btnUserDrawObjs.Style = btnStyle;
      
      //  from 'public class ChartToolBarCustomMenuExample : Indicator'
      theMenu = new System.Windows.Controls.Menu
                  {
                      // important to set the alignment, otherwise you will never see the menu populated
                      VerticalAlignment = VerticalAlignment.Top,
                      VerticalContentAlignment = VerticalAlignment.Top,
      
                      // make sure to style as a System Menu    
                      //Style = System.Windows.Application.Current.TryFindResource("SystemMenuStyle") as Style
                  };
      
      theMenu.Items.Add(btnUserDrawObjs);
      
                  // add the menu which contains all menu items to the chart
                  chartWindow.MainMenu.Add(theMenu);
      
                  //  set visibility to .Visible
                  foreach (System.Windows.Controls.TabItem tab in chartWindow.MainTabControl.Items)
                      if ((tab.Content as ChartTab).ChartControl == ChartControl && tab == chartWindow.MainTabControl.SelectedItem)
                          theMenu.Visibility = Visibility.Visible;
      ​
                  // Subscribe to click events
                  btnUserDrawObjs.Click += btnUserDrawObjsClick;
      ​            //  hook up tab changed handler
                  chartWindow.MainTabControl.SelectionChanged += MySelectionChangedHandler;
      
                  // Set this value to true so it doesn't add the
                  // toolbar multiple times if NS code is refreshed
                  IsToolBarButtonAdded = true;
              }
      ​
              private void DisposeCleanUp()
              {
      ​        if (btnUserDrawObjs != null)
              {
                  chartWindow.MainMenu.Remove(btnUserDrawObjs);
                  btnUserDrawObjs.Click -= btnUserDrawObjsClick;
                  btnUserDrawObjs = null;
              }
      ​
      This is a summary of the code. From line 1 it's a copy of someone elses contribution because programming C# is not my 1st, 2nd, or 3rd occupation. I know it won't compile. It's hopefully an example of how I've put the various parts together.
      When I was initially coding this I think the problem began to appear when I started adding the buttons via 'theMenu = new System.Windows.Controls.Menu'. If you need any more specifics let me know. There's nothing propritary in the entire indicator.

      Comment


        #4
        Hello ramckay,

        From this snippet I don't see anything specifically out of place besides you are changing the VerticalAlignment of the menu which is not something that normally needs to be done. The menu you created is not appearing correctly, it should be the next item in the toolbar and not on the right side of the window. I would suggest comparing what you have with the custom menu sample from the following link. I just tried that and it appears in the correct location and does not have any effect when having the menu open and maximizing or restoring. You would need to make sure your code is similar to that script if you want to use a Menu specifically. You can otherwise do something like creating a custom panel and having a menu button that toggles the panels visibility, that would not have any issues with maximizing or restoring.

        Comment


          #5
          Thanks Jesse,
          I'll make the changes and let you know if it solves the problem.

          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