Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Modal Dialog Loosing focus

Modal Dialog Loosing focus

Scheduled Pinned Locked Moved C#
jsonquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rikkemus
    wrote on last edited by
    #1

    Hi i made a Modal DIalog Box( showdialog() ) Its on top and everything, but the application who calls it( another enviroment ) steals back the focus, but with my modal dialog box on top still. This annoys me! meaning i cannot just press enter to move along, but need to get focus back to my dialog form, before i press enter. How can i make sure that it(dialogbox) always have focus over other applications, that nothing takes it away. is there some windows api i can call or something, i have been looking but with no luck. Thx in advance

    S 1 Reply Last reply
    0
    • R rikkemus

      Hi i made a Modal DIalog Box( showdialog() ) Its on top and everything, but the application who calls it( another enviroment ) steals back the focus, but with my modal dialog box on top still. This annoys me! meaning i cannot just press enter to move along, but need to get focus back to my dialog form, before i press enter. How can i make sure that it(dialogbox) always have focus over other applications, that nothing takes it away. is there some windows api i can call or something, i have been looking but with no luck. Thx in advance

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Well, you can try setting Form.TopMost[^] to true. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      R 1 Reply Last reply
      0
      • S S Senthil Kumar

        Well, you can try setting Form.TopMost[^] to true. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        R Offline
        R Offline
        rikkemus
        wrote on last edited by
        #3

        I have tried that, bu the application that called my Dialog window snatched focus back, and was hiding behind my dialog. But i found a working solution through the User32.dll call. [DllImport("user32.dll", SetLastError=true)] static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab); SwitchToThisWindow(this.Handle, false); It activates my window/dialog. Thx though for the answer :-)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups