Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to make messagebox prompting on the top of window?

Posted on 2002-05-06
2
Medium Priority
?
377 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 150 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

722 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