Bring app window to front

This is a discussion on Bring app window to front within the C# Programming forums, part of the General Programming Boards category; I have a dialog app that starts Autocad (another app) through COM (if it is not already running) and I'd ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    10

    Bring app window to front

    I have a dialog app that starts Autocad (another app) through COM (if it is not already running) and I'd like to bring the Autocad app to the front (z order) ready to work with then bring my dialog to the top also as a modeless dialog to perform operations on the open document.
    Any tips or directions to some help on this much appreciated.
    Mick

  2. #2
    Registered User
    Join Date
    May 2004
    Posts
    10
    I solved the problem by importing a win32 function and implementing it, works fine.

    Code:
    		//imported win32 function
    		[DllImport("User32.dll")] 
    		private static extern bool SetForegroundWindow(IntPtr hWnd);
    		private IntPtr _hWnd;
    then use something like
    Code:
    _hWnd = (IntPtr)oApp.HWND;//needs a cast! 
    SetForegroundWindow(_hWnd);
    Cheers.MickD

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 07:57 PM
  2. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 08:23 AM
  3. Window always in front
    By Magos in forum Windows Programming
    Replies: 2
    Last Post: 02-02-2003, 09:28 AM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 11:14 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21