Fokus on C# Dialog

Hello,

I have a c# addon dialog. I like to have an event, if the dialog changes to active (dialog has blue title), or if the mouse is doing something else inside the MicroStation and the dialog changes to deactive (dialog has grey title).

The frame-class is inherited from Bentley.MicroStation.WinForms.Adapter.
But none of these events (Focus deactivate, Focus activate, Focus enter, Focus leave, Mouse enter, mouse leave) show up, if the were defined for the frame itself. The work fine on items

Any idea?

Thanks a lot

Volker

  • Another way to capture mouse activation events on your form is to override WndProc like this. Not sure if there's an equivalent for deactivation:

    protected override void WndProc (ref Message message)
        {
        const int WM_MOUSEACTIVATE = 0x0021;
        if (WM_MOUSEACTIVATE == message.Msg)
            ...
        }

     

  • Jeff,

    Interesting idea, but unfortunately this is only half of a possible solution.

    Just to test it, I have added this to my class:

    protected override void WndProc(ref Message inMessage)
    {
    System.Diagnostics.Debug.WriteLine(inMessage.ToString());
    base.WndProc(ref inMessage);
    }

    If I re-enter the dialog I got every time:

    msg=0x7 (WM_SETFOCUS) hwnd=0x61498 wparam=0x2166c lparam=0x0 result=0x0
    msg=0x8 (WM_KILLFOCUS) hwnd=0x61498 wparam=0x414ba lparam=0x0 result=0x0
    msg=0x281 (WM_IME_SETCONTEXT) hwnd=0x61498 wparam=0x0 lparam=0xffffffffc000000f result=0x0

    This is more then enough for me.

    But I did not receive any message, when I am leaving the dialog. And this is the more important part for me.

    Thanks!

    Volker

    Mit freundlichen Grüßen / Best regards
    Volker Hüfner

    |  AB_DATE Engineering  Software   |  ab-date.de  |

  • I haven't run across any 'good' reliable ways to detect focus in/out at the Form level within MicroStation. If you only care about mouse motion within your Form, you can rig up a timer function to test the mouse position (Control.MousePosition) against the dialog's bounds. Since WinForms doesn't have event bubbling, this problem is tricky.
  • Jeff

    I am not really interested in the mouse position; I was just looking also for the mouse as another kind of indicator for my problem.

    I have to decide, if the user is actually working with my dialog, or if he is doing some "normal" MicroStation work in the meantime.

    The workflow should/could be:

    • Calculating something with my dialog,
    • Changing something (e.g. copying, moving, whatever) in the drawing
    • Recalculating in my dialog, without closing the dialog during this workflow.
    • And so on

    I need to provide the user with different information during these steps.

    TXS Volker

    Mit freundlichen Grüßen / Best regards
    Volker Hüfner

    |  AB_DATE Engineering  Software   |  ab-date.de  |