Solved

Activating window from another application

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Named range not carried over 10 65
countEvens challenge 2 112
wordmultiple challenge 12 142
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 900
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 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