Solved

Activating window from another application

Posted on 1998-12-21
4
207 Views
Last Modified: 2013-11-20
Can any one tell me, how can I actvivate (and set keyboard
input focus) to the top level window from one application to
another

Tahks beforehand
0
Comment
Question by:george_777
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 30 total points
ID: 1326545
Usually this is done by retreiving the handle of the window you want to activate ( by calling 'FindWindow()') and the activating it by calling 'BringWindowToTop()' supplying this window handle as the argument, e.g.

HWND hWnd = FindWindow ( NULL, "Title of window");

if ( hWnd)
     ::BringWindowToTop ( hWnd);
0
 

Author Comment

by:george_777
ID: 1326546
Thank you JKR.

Unfortunately this not work. I'll try to explain my problem more detail.
I wrote program which maintains list of minimized applications. User can select any window from this list and send message to top level window of this application SendMessage(m_hWnd,WM_SYSCOMMAND,SC_RESTORE,0); in order to restore its original position and size.
System wide hook which I implemented in Dll  looks at HCBT_MINMAX  SW_RESTORE  and SW_MAXIMIZE for that windows and brings up password dialog box.
If user enters wrong password, hook do not forwards message and application remains minimized.
Everything works OK but when dialog displayed  it is not active i. e. I have to click mouse on it.
Can you provide me any solution for this situation?



0
 
LVL 86

Expert Comment

by:jkr
ID: 1326547
Oh, i realize your problem..
There are several ways to cope with that situation. The IMHO best way would be to set thew 'DS_SETFOREGROUND' style bit for your password dialog, which causes the system to use the 'SetForegroundWindow()' function to bring the dialog box to the foreground (which i initially had in mind when answering your question). Even more forcibly to the user would be setting 'DS_SYSMODAL' which would cause your dialog to be system modal...
0
 

Author Comment

by:george_777
ID: 1326548
Thak you very much JKR!
Everithing works OK. Your suggestions always help me.
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 129
ffmpeg - "rtsp://...... Operation not permitted" 4 81
countEvens challenge 2 101
zeroFront challenge 7 99
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question