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
  1. Home
  2. General Programming
  3. C#
  4. In Windows 7 I can't get a window to be shown in foreground (Win32 API)

In Windows 7 I can't get a window to be shown in foreground (Win32 API)

Scheduled Pinned Locked Moved C#
csharpvisual-studiowindows-adminjsontutorial
2 Posts 1 Posters 2 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.
  • A Offline
    A Offline
    Axonn Echysttas
    wrote on last edited by
    #1

    Hello ::- ). I've recently upgraded to Windows 7 and, naturally, some of my apps have run into a black, merciless wall of changed behaviors. One of the things which stopped working are my applications to bring stuff out of SysTray. Some applications don't have good methods to bring them out of SysTray via hotkey. Total Commander for example sometimes fails and you have to press Enter. So I made an application which worked fine on XP. But now, instead of bringing it back from SysTray and popping it in my face, it just blinks it on the Taskbar. Before you say "ForegroundLockTimeout", know that I already set this to 0 across the registry. What I'm trying to do is to make Total Commander come out from SysTray via a hotkey. The hotkey actually launches my C# application. In my C# application I do this:

    int hwndTC = Win32API.FindWindow("TTOTAL_CMD", null); //Try to find the Total Commander window.
    Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.Show);
    Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.ShowMaximized);
    Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.Maximize);
    Win32API.SetForegroundWindow(hwndTC);

    But the result is that instead of TC showing itself in my face, I see it blinking on the TaskBar. One very strange thing is that when Visual Studio is running (and thus, the .vshost.exe is running), everything works fine. As soon as I shut down VS, the blinking stuff happens again.

    I thank you for helping me... by contributing! Axonn @ SourceForge ^

    A 1 Reply Last reply
    0
    • A Axonn Echysttas

      Hello ::- ). I've recently upgraded to Windows 7 and, naturally, some of my apps have run into a black, merciless wall of changed behaviors. One of the things which stopped working are my applications to bring stuff out of SysTray. Some applications don't have good methods to bring them out of SysTray via hotkey. Total Commander for example sometimes fails and you have to press Enter. So I made an application which worked fine on XP. But now, instead of bringing it back from SysTray and popping it in my face, it just blinks it on the Taskbar. Before you say "ForegroundLockTimeout", know that I already set this to 0 across the registry. What I'm trying to do is to make Total Commander come out from SysTray via a hotkey. The hotkey actually launches my C# application. In my C# application I do this:

      int hwndTC = Win32API.FindWindow("TTOTAL_CMD", null); //Try to find the Total Commander window.
      Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.Show);
      Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.ShowMaximized);
      Win32API.ShowWindow((IntPtr)hwndTC, Win32API.ShowWindowCommand.Maximize);
      Win32API.SetForegroundWindow(hwndTC);

      But the result is that instead of TC showing itself in my face, I see it blinking on the TaskBar. One very strange thing is that when Visual Studio is running (and thus, the .vshost.exe is running), everything works fine. As soon as I shut down VS, the blinking stuff happens again.

      I thank you for helping me... by contributing! Axonn @ SourceForge ^

      A Offline
      A Offline
      Axonn Echysttas
      wrote on last edited by
      #2

      Anybody? ::- (

      I thank you for helping me... by contributing! Axonn @ SourceForge ^

      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