Solved

Activating window from another application

Posted on 1998-12-21
4
204 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now