Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Suite Pro
  New Posts New Posts RSS Feed - Enter and Leave events don’t work
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Enter and Leave events don’t work

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


Joined: 09 February 2005
Location: Canada
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote blazej Quote  Post ReplyReply Direct Link To This Post Topic: Enter and Leave events don’t work
    Posted: 09 February 2005 at 5:52pm
Hi

I'm in the process of evaluating Xtreme Suite for the purposes of the software project we're working on. I'm using the ActiveX version of the components in C# (VS .NET 2003).

I'm using both Command Bars and Docking Pane Manager. In one of my panes I have an edit box. I subscribed to Enter and Leave events of this control. This allows me to automatically save text typed by the user when he/she leaves the edit box. This used to work before I switched my code to CodeJock but now - it doesn't. The Enter event I'm getting only once (no matter how many times I enter and leave the control) and the Leave event I don't get at all.

Knowing ActiveX, I think this problem is related to the fact that Xtreme Suite is implemented in ActiveX.

Any comments? Workarounds?

Michal Blazejczyk
Back to Top
blazej View Drop Down
Groupie
Groupie


Joined: 09 February 2005
Location: Canada
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote blazej Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 11:18am
Anyone?

:-)))))

Michal
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 11:50am

I just ran this scenario in one of my applications, and I'm seeing the same behavior.

The events will fire properly if you move between controls hosted on the same pane, but not if you move from one pane to another.

Codejock, any comments on how to get these events to fire properly?

Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 12:06pm

I just figured it out.  I remembered a similar problem when using these controls in Visual Basic.  Only one control within the same container should be able to have focus.  In Visual Basic, I use to use separate Forms to create each pane, and that created all kinds of focus problems (since two different forms can have two different active controls).  The workaround was to place all my pane controls within different PictureBoxes on the same form.  Since they were all in the same container, only one could have focus at a time.

When working with C#, I use separate UserControls for each pane, and I never really give them a container.  To test this theory, I added each newly created pane UserControl to my main form's 'Controls' collection.  Since they all are in the same collection, only one can have focus at a time.  Sure enough, all the events fired as expected!

Here's some basic sample code from a routine on a Main Form that could set up the panes:

// User Controls used as a panes
TestPane paneControl1 = new TestPane();
TestPane paneControl2 = new TestPane();
// Add controls to main form controls collection
this.Controls.Add(paneControl1);
this.Controls.Add(paneControl2);
// Create Panes
dockingPane.CreatePane(ID_PANE_1, 100, 100, DockingDirection.DockTopOf, null);
dockingPane.CreatePane(ID_PANE_2, 100, 100, DockingDirection.DockTopOf, null);
// Note: Assign Handles in AttachPane event

Back to Top
blazej View Drop Down
Groupie
Groupie


Joined: 09 February 2005
Location: Canada
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote blazej Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 12:12pm
You rock, man!

Thanks

Michal
Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 1:29pm

No problem!

I did find an issue with this approach that I need to warn you about.  Since the AttachPane event is only fired when a pane becomes visible, this means you're controls will be unattached until the pane is visible.  In the case of grouped panes, this means the controls aren't attached until the user actually selects the pane in the tabbed group.

If you use the approach I mentioned, the controls are visible when the are added to the controls collection.  That means that unattached controls will be visible until the pane is selected for the first time.  To avoid this, you should set the visible property to false when you create the control and then, in the AttachPane event, set the visible property back to true.

An alternative to the AttachPane event would be to use the OnHandleCreated event of the items you want to add to your panes.  At that point, you could assign the handle to the proper pane and not have to wait until the user selects a pane.

Back to Top
gshawn View Drop Down
Senior Member
Senior Member


Joined: 04 October 2004
Status: Offline
Points: 227
Post Options Post Options   Thanks (0) Thanks(0)   Quote gshawn Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 1:32pm

Boyd, I remember an old post of yours about not using multiple Forms in the VB version to host Docking Panes. However I am unable to find this post.

I am having some focus issues in the VB version at the moment, due to the exact problem you just mentioned. If I remember correctly, this issue has existed for a long time now. Do you have a simple VB sample that you could post, that uses your method of using PictureBoxes in a single form you are describing? Since all the CodeJock samples are based on the seemingly incorrect way of doing things (multiple forms), I think that would be very valuable resource.

Thanks in advance.

Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 3:20pm

Unfortunately, I don't have a sample VB app that uses this, but I'll repeat the basic concepts.

  1. Create a PictureBox control on the main form that will hold the content of every pane you wish to create.  I suggest making this a control array so that you can use a single event handler for all the controls (like for the Resize event).  This also helps be assigning the PictureBox the same index as the ID you use to identify a pane.
  2. Set the 'visible' property of the PictureBox to false so that it won't appear on the form prior to being attached in the 'AttachPane' event.
  3. Create your panes just as you would if they were on different forms.
  4. In the 'AttachPane' event of CommandBars, set the handle of each pane to the handle of the corresponding PictureBox control.

That's the basics.  I've been using C# so long that I don't recall any other tricky steps.  I hope that helps.

Back to Top
gshawn View Drop Down
Senior Member
Senior Member


Joined: 04 October 2004
Status: Offline
Points: 227
Post Options Post Options   Thanks (0) Thanks(0)   Quote gshawn Quote  Post ReplyReply Direct Link To This Post Posted: 10 February 2005 at 3:24pm
Thanks Boyd, I'm sure this will come in handy. I appreciate your taking the time to write this out.
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.188 seconds.