Solved

How to make messagebox prompting on the top of window?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 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