Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - statusbar stops responding
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

statusbar stops responding

 Post Reply Post Reply
Author
Message
leojay View Drop Down
Groupie
Groupie


Joined: 07 March 2005
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote leojay Quote  Post ReplyReply Direct Link To This Post Topic: statusbar stops responding
    Posted: 22 May 2008 at 5:03am
i'm using c#.
in a very simple project, i just add a statusbar in the main form like this:
private const int MIN_VALUE = 0;
private const int MAX_VALUE = 300;
private const int DEFAULT_VALUE = 100;


public void SliderPaneClick(XtremeCommandBars.StatusBarSliderPane pane,
                            XtremeCommandBars.XTPSliderCommand command,
                            int pos)
{
    System.Diagnostics.Debug.WriteLine(string.Format("cmd: {0}, pos: {1}, pane: {2}", command.ToString(), pos, pane.ToString()));

    int newvalue = pos;

    switch (command)
    {
        case XtremeCommandBars.XTPSliderCommand.XTP_SB_LEFT:
            newvalue = MIN_VALUE;
            break;
        case XtremeCommandBars.XTPSliderCommand.XTP_SB_RIGHT:
            newvalue = MAX_VALUE;
            break;
        case XtremeCommandBars.XTPSliderCommand.XTP_SB_LINELEFT:
            newvalue = Math.Max(MIN_VALUE, pane.Value - 10);
            break;
        case XtremeCommandBars.XTPSliderCommand.XTP_SB_LINERIGHT:
            newvalue = Math.Min(MAX_VALUE, pane.Value + 10);
            break;
        case XtremeCommandBars.XTPSliderCommand.XTP_SB_THUMBTRACK:
            newvalue = pos;
            break;
        case XtremeCommandBars.XTPSliderCommand.XTP_SB_PAGELEFT:
            newvalue = Math.Max(MIN_VALUE, pane.Value - 30);
            break;
        case XtremeCommandBars.XTPSliderCommand.XTP_SB_PAGERIGHT:
            newvalue = Math.Min(MAX_VALUE, pane.Value + 30);
            break;
        default:
            System.Diagnostics.Debug.WriteLine(
                string.Format("strange value: cmd: {0}, pos: {1}", command.ToString(), pos));
            return;
    }

    if (newvalue != pane.Value)
    {
        pane.Value = newvalue;
        CommandBars.StatusBar.FindPane(1).Text = newvalue + "%";
    }
}

private void Form1_Load(object sender, EventArgs e)
{
    XtremeCommandBars.StatusBar sb = CommandBars.StatusBar;
    sb.AddPane(0);

    XtremeCommandBars.StatusBarPane p = sb.AddPane(1);
    p.Width = 40;
    p.Alignment = XtremeCommandBars.XTPTextAlignment.xtpAlignmentRight;
    p.Text = DEFAULT_VALUE + "%";

    XtremeCommandBars.StatusBarSliderPane slider = sb.AddSliderPane(2);
    slider.Min = MIN_VALUE;
    slider.Max = MAX_VALUE;
    slider.Value = DEFAULT_VALUE;
    slider.Width = 150;
    slider.SetTicks(DEFAULT_VALUE);
    sb.SliderPaneClick += SliderPaneClick;
    sb.Visible = true;

}


if i press the thumb of the slider, and drag it left and right for about one minute, the slider will stop responding any events.

you can get my project and screenshot here:
http://python.leojay.googlepages.com/sbtest.zip

btw, another strange thing is in the SliderPaneClick function,  the value of parameter command could be 8 which does not exist in the definition of XtremeCommandBars.XTPSliderCommand.


Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 22 May 2008 at 8:55am
its .NET - you never know when object will be destroyed.  :) So just move StatusBar declaration to variables of Form:
 

XtremeCommandBars.StatusBar sb;

private void Form1_Load(object sender, EventArgs e)

{

sb = CommandBars.StatusBar;

....
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
leojay View Drop Down
Groupie
Groupie


Joined: 07 March 2005
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote leojay Quote  Post ReplyReply Direct Link To This Post Posted: 22 May 2008 at 9:44pm
thanks, it works.

but i'm still not convinced by your explanation. how could the statusbar be GCed, when it's still referenced by "CommandBars"?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 2008 at 1:30am
Hello,
 
Its ActiveX control.  line
XtremeCommandBars.StatusBar sb = CommandBars.StatusBar;
 
creates temporary object sb that become wrapper of StatusBar COM Object. it will be destroyed after method leave scope and Garbage collection decide to clean dead objects.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
leojay View Drop Down
Groupie
Groupie


Joined: 07 March 2005
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote leojay Quote  Post ReplyReply Direct Link To This Post Posted: 23 May 2008 at 4:09pm
thanks.

in the SliderPaneClick function,  the value of parameter command could be 8 which does not exist in the definition of XtremeCommandBars.XTPSliderCommand. what's the meaning of 8?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 24 May 2008 at 12:46pm
HI,
 
We added XTP_SB_ENDSCROLL for next release - fired when user release mouse after scroll.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.281 seconds.