Posted 13 years ago by Kevin Blakeley
Avatar
I have an issue that I was trying to work through in my application and was able to duplicate the problem I was seeing in the c# test application as well. What I am trying to do is track the last clicked TabbedMdiWindow, regardless of if it was a tool window or a tabbed document. I track this myself using the WindowFocused event, so that when each window is clicked I save off the last one that was clicked. All of this works okay. Here is where it breaks down.

- document1.txt is a tabbed document
- Toolwindow properties and events are dockable windows that are NOT docked
- when I click the document1.txt window it is the active TabbedMdiWindow
- when I click the toolwindow properties window, its the active TabbedMdiWindow
- When I click the "Window" menu item, the active TabbedMdiWindow goes back to document1.txt

What I would expect to see, is to see it work like visual studio such that I would be able to click on the window menu item and the window properties such as "floating", "dockable", "tabbed document", etc would be available for the toolwindows properties window since that was the last one I had clicked. This is not the case since focus is changed back to the document1.txt window.

Is this by design? Is there a way around this behavior?
Thanks
Kevin

Comments (10)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kevin,

This is a problem with the standard Windows menus. By clicking on a main menu, you restore focus to the parent Form, thereby restoring focus to the document.

Our DockForm sample uses standard (yet owner drawn) menus so this problem does appear there.

However, in our UIStudio bar controls, I believe we built in functionality so that if focus is on an undocked tool window and you click on a main menu item on the main Form, it will not steal focus and should work as you expected.


Actipro Software Support

Posted 13 years ago by Kevin Blakeley
Avatar
I got around this issue, but have a new one. I am trying to come up with a way to track the last window that recieved focus, regardless of its type. If the window is a tabbed document or a docked toolwindow the onenter method works great to track this, but once the window becomes floating it seems I dont' get any events anymore. How can I go about doing this?

thanks
Kevin
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Have you checked out the WindowFocused event off DockManager? That might be what you want to use.

The problem with the Control.Enter event is this (and it's a Microsoft design issue)... Enter event only fires if the focus changes into the control from another control in the same form. Therefore if you have a floating form that only has one control in it (which is what a floating tool window is), the Enter event will not fire for that control other than maybe the first time it is displayed. This is part of the reason why we made the DockManager.WindowFocused event, which should yield better more accurate results than Control.Enter.


Actipro Software Support

Posted 13 years ago by Kevin Blakeley
Avatar
I was originally using the windowfocused event but that does not fire if you just were to click on the title bar of the form, you actually have to click inside the form for it to fire. So for example, most people may click on the title bar to move the form around and that brings that form into focus, but the windowfocused event does NOT fire.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I just tested it in the sample project and it does fire when you click on title bars. Please ensure that you have the latest build.

If you see the problem happening with that, please tell us how to reproduce it in our sample project or send us a small project of your own that shows the issue. Thanks!


Actipro Software Support

Posted 13 years ago by Kevin Blakeley
Avatar
I don't have the code with me right now so I will get it when I get home tonight, but I think I was running into a problem when I was using floating or undocked windows.
Posted 13 years ago by Kevin Blakeley
Avatar
First, version info:
UI Studio v2.0.0062 using shared 1.0.0077.
XP Pro SP2
.Net 2.0

After further testing I have been able to reproduce the error pretty easily using one of the demo forms, specifically the Bar Controls Sample. Here are the steps:

1. First I added the WindowFocused event to the BarForm.cs by using the following code:

private void dockManager_WindowFocused(object sender, ActiproSoftware.UIStudio.Dock.TabbedMdiWindowEventArgs e)
        {
            eventsListBox.SelectedIndex = eventsListBox.Items.Add(String.Format("WindowFocused: FullName={0}", e.TabbedMdiWindow.Name));
        }
2. When running the sample, the initial form comes up with the BarManager properties and Toolbar properties windows as docked on the right. While those are docked, when I click them the event is written out to the event window.

3. Change the document type on each of these two windows by setting them to floating windows. Make sure you don't click inside either form yet, just click on the toolbars. Notice that no event gets written to the event window.

4. Now, click inside each of the floating windows. This will trigger the event to be written out to the event window.

5. Now by clicking on the title bars of the windows, the windowfocused event now fires all the time like I would expect it to.

So it appears that the windowfocused event won't fire until the form has received focused by clicking within the form. Whats also strange is that the WindowFocused event does not fire until both windows have recieved their focus by clicking within the form. This doesn't seem right. I hope you are able to reproduce what I am seeing and explain why this is happening.

Thanks for all your help on this issue.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kevin,

The floating tool window should be getting focus in that scenario. It appears to be a bug and I've just written some code to fix the problem for the next maintenance release. Thanks for the posting!


Actipro Software Support

Posted 13 years ago by Kevin Blakeley
Avatar
thanks for following up on that. When is the next maintence release scheduled for?
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Probably in the next several days. We've been adding some tweaks here and there. If you'd like to try a preview of it (it might still change slightly before final release) to try out the changes, you can send us an email.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.