SetForegroundWindow API not working-VBForums
Results 1 to 9 of 9

Thread: SetForegroundWindow API not working

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    SetForegroundWindow API not working

    Hey, i know there have been a lot of posts on this topic but i can't seem to find the answer to this question. I have an excel spreadsheet with cells full of visio shapes. When a double click is made on a cell, the shape is found and set to blink in visio. However, i am having trouble getting the visio window to pop up infront of the excel window

    I am using SetForegroundWindow API by calling this:
    VB Code:
    1. 'g_ovAppVisio is the Visio Application object
    2. SetForegroundWindow g_ovAppVisio.WindowHandle32

    this however, only causes the visio window to flash 3 times in the task bar, and not pop up. What else do I need to do to make it pop up in front of the excel window? Thanks!

  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: SetForegroundWindow API not working

    Is this VB6 or VB.NET?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: SetForegroundWindow API not working

    I'm developing in VB6

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Other side of town from si_the_geek
    Posts
    7,171

    Re: SetForegroundWindow API not working

    Find the handle yourself with the FindWindow API? Just a thought...


    Has someone helped you? Then you can Rate their helpful post.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: SetForegroundWindow API not working

    It's the right handle, the window reacts, it just doesn't pop up. I think i need to use SetWindowPos but i'm not sure how to set the flags, or if there is a better procedure for doing that.

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Other side of town from si_the_geek
    Posts
    7,171

    Re: SetForegroundWindow API not working

    Is it maybe minimized?


    Has someone helped you? Then you can Rate their helpful post.

  7. #7
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: SetForegroundWindow API not working

    Quote Originally Posted by Vhati
    It's the right handle, the window reacts, it just doesn't pop up. I think i need to use SetWindowPos but i'm not sure how to set the flags, or if there is a better procedure for doing that.
    same case as mine. What I did is use the IsIconic function,setforeground and showwindow.

    IsIconic use to check if the window is minimize or not if it's not minimize then use the setforeground then if it's minimize then use the showwindow.

  8. #8
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Other side of town from si_the_geek
    Posts
    7,171

    Re: SetForegroundWindow API not working



    Has someone helped you? Then you can Rate their helpful post.

  9. #9
    Addicted Member
    Join Date
    May 2004
    Location
    Nagpur, India
    Posts
    228

    Re: SetForegroundWindow API not working

    Windows 98/Me, Windows 2000/XP: The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:

    The process is the foreground process.
    The process was started by the foreground process.
    The process received the last input event.
    There is no foreground process.
    The foreground process is being debugged.
    The foreground is not locked (see LockSetForegroundWindow).
    The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
    Windows 2000/XP: No menus are active.

    Check MSDN for more

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.