Solved

Activating window from another application

Posted on 1998-12-21
4
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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