Solved

How to make messagebox prompting on the top of window?

Posted on 2002-05-06
2
374 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 create frequencies of a variable from SAS dataset? 10 137
has22 challenge 11 107
lucky13 challenge 11 158
moto 4g phone enable finger print 4 44
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

740 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