?
Solved

Displaying a MessageBox 'On Top'

Posted on 2002-05-09
5
Medium Priority
?
934 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

771 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