MDI Style focus without using MDI forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oscWork
    New Member
    • Feb 2007
    • 4

    MDI Style focus without using MDI forms

    Does anyone know of any way to switch focus between a main form and a child form without the usual flickering you get while changing focus between windows?

    This works fine if the main form is an MDI container and the child form is within that container, but MDI is not appropriate for this application. I would like to be able to interact with a form without losing focus on the main form.

    Obvious workarounds such as setting focus on the main form each time the mouse exits the child form produce a lot of flickering and simply arent acceptable.

    Any ideas?

    Thanks in advance for any help with this one,

    Daniel.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Flickering?
    My windows don't flicker when I switch between them?

    EDIT:
    I would like to be able to interact with a form without losing focus on the main form.
    Oh ok, hmm. Have you tried the TopMost setting?
    Although I mean by definition, if you are interacting with a window it should have the focus

    Comment

    • oscWork
      New Member
      • Feb 2007
      • 4

      #3
      I mean the general flicker if you actually switch focus between two windows, for example, if you do it fast you get a flicker - perhaps it wasnt the best way to describe it!

      Basically if you create a standard MDI app with the main form as an MDI Container and then add a child form, when you actually "select it" i.e. it gets focus you do not loose focus on the main window.

      For example, if I were to open a new window from a main window without it being an MDI application I would lose focus on the main window when entering the new one. If i were then to click on the main windows file menu I would have to click twice, once to gain focus, a second time to perform the action I was expecting. Within an MDI situation you do not have to do this.

      Is there any way of replicating this behaviour without it being an MDI application?

      The main reason I ask is that I need a semi-transparent tool window within an MDI application, if you create a form and set its opacity all's well - but as soon as you set it to be a child form of an MDI parent you loose that opacity because the window layering utilized by Windows to deal with opacity isnt supported on non-top level forms.

      As for TopMost, yes I have tried that and it didn't help much.

      Thanks for the reply and I hope this clears up my question.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        What OS are you running?
        I only have to click once to open up file menus on a non-focused window.

        As a thought, what if you made the main window NEVER have focus? I think that's how a lot of programs with floating toolbars do it (like gimp)

        Comment

        • oscWork
          New Member
          • Feb 2007
          • 4

          #5
          Vista at the moment, it does appear to only happen within "my" program and not if I do it between two windows.. odd.

          I'll have a look into that one, cheers.

          Comment

          • oscWork
            New Member
            • Feb 2007
            • 4

            #6
            Managed to solve this, if anyone is interested I disabled the "flickering " (read: visual focus change) by overriding WndProc and on WM_NCACTIVATE and WParam == 0 send a message to the window:

            SendMessage(thi s.Handle, WM_NCACTIVATE, 1, IntPtr.Zero);

            This re-activates the window, causing it to "appear" in focus every time.

            Comment

            Working...