Solved

How to make messagebox prompting on the top of window?

Posted on 2002-05-06
2
370 Views
Last Modified: 2013-11-20
Hi! experts,
When focus is on Internet explorer or other application, my messagebox prompts at the back of the current screen.  So, I don't know the message box is prompting out.
How can I make a messagebox being on the top of windows when everytime it prompts user?
0
Comment
Question by:superleo
2 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 50 total points
ID: 6992860
Starting in Win98 sp2, Windows began making it difficult for one program to grab control (keyboard/visual focus) from another program.  It makes a lot of sense:  If you are working in a wordprocessor, you don't want some program to jump up and start eating your keystrokes (especially if it is one of thos banner ads!).  There is also a security consideration:  A program could lurk in the background waiting for a password prompt to appear, take the focus, save the keystroeks, then disappear.

So, unless your program owns the 'Foreground Window' any MessageBox that it pops up will be behind whatever program is currently in front.  

You can try calling SetForegroundWindow just before popping up the MessageBox.  That will cause your taskbar button to flash (indicating 'hot' activity) and if the user clicks your taskbar button, the Messagebox will appear in front.

-- Dan
0
 

Expert Comment

by:1cand01t
ID: 6993491

with ur own dialog box or message window u can use following function to place ur window at the topmost position without disturbing or changing ur focus from other applications.
(like MSN Messenger popup messages):

BOOL SetWindowPos (
const CWnd* pWndInsertAfter,
int x,
int y,
int cx,
int cy,
UINT nFlags );

for example:

SetWindowPos(&wndTopMost,0,0,200,100,SWP_NOACTIVATE);

'wndTopMost' will place ur dialog box or Window at the topmost level, and 'SWP_NOACTIVATE' will prevent shifting ur focus from any other application.

i hope this will help u.

good luck
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

24 Experts available now in Live!

Get 1:1 Help Now