Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Displaying a MessageBox 'On Top'

Posted on 2002-05-09
5
Medium Priority
?
942 Views
Last Modified: 2008-03-06
I am using Borland C++ Builder 4.0

Could someone please show me a code example that will make a MessageBox display on top of all other applications that may be running?

(ie.  My program will be running in the background while an on-line game runs in the foreground in Windows, though it does not directly interact with the game.  I want to give the user an option in the menu to have a messagebox appear on top of running applications when a timer runs out.  So far all I can get is the messagebox to appear behind other applications, though in front of my program.)

Thanks.
0
Comment
Question by:LordDamein
[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
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6999563
MessageBox ( GetForegroundWindow(), "On Top", "Title", MB_OK | MB_ICONINFORMATION);

should do it - if not, add MB_SYSTEMMODAL to the flags, though I would not recommend using that too often...
0
 
LVL 4

Accepted Solution

by:
pagladasu earned 400 total points
ID: 6999597
Try:
 MessageBoxEx(NULL,"Hello","Message",MB_OK|MB_TOPMOST, NULL);

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7000124
If you are talking about an online game such as QUAKE Deathmatch or HALFLIFE, you need to realize that they use DirectX.  In fullscreen mode, you will not be able to popup a messagebox in front of such screens.

-- Dan
0
 

Author Comment

by:LordDamein
ID: 7000231
The game is Ultima Online.  Popups will work fine with it.  Actually, my program works as is, but I would like to add the 'on top' option.  I am testing out the MB_TOPMOST right now and it works sort of.  (I already tried the MB_SYSTEMMODAL and that didn't.  Also, the GetForegroundWindow() brings up errors.  :(
0
 

Author Comment

by:LordDamein
ID: 7018513
The MB_TOPMOST seems to be the only thing that works for me and does what I need.  I tried all of the other suggestions without success.
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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

610 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