Solved

How to make messagebox prompting on the top of window?

Posted on 2002-05-06
2
373 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 monitor remote shell execution on linux 9 104
mapBully challenge 6 152
wordappend challenge 8 200
Work with App store 7 67
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

840 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