Solved

Activating window from another application

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to know only "File created" with EventLog 3 32
matchUp  challenge 6 52
Problem to event 3 74
how to use laptop or pad camera in vb.net windows application 2 45
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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

11 Experts available now in Live!

Get 1:1 Help Now