How to make a window an active window(focussed window)

Discussion in 'Software' started by ravinderreddy, Aug 9, 2005.

  1. ravinderreddy

    ravinderreddy Private E-2

    On windows operating system How can we make a window an active window (focussed window) using c/c++ programming.
    I tried using SetForegroundWindow() but it is not working.
    AllowSetForegroundWindow() will work on Windows XP?

    Any how please give me an idea regaurding this.
     
  2. buddingb

    buddingb Private E-2

    Not too sure about some of this stuff, and I can't test this because I don't have a compiler in front of me, but perhaps:

    AttachThreadInput() (attach to thread whose window you want to activate)
    SetActiveWindow()
    SetFocus() (not sure if SetActiveWindow gives focus; if not, call this)
    AttachThreadInput() (detach from other thread)

    That may work... *shrug* :eek: Of course you'll need to get your current thread ID with GetCurrentThreadId() and the thread that owns the window you want to activate's ID w/ GetWindowThreadProcessId().

    Like I said, I can't test this so I have no idea if this will work or not... but just something I came up with from MSDN.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds