Solved

Displaying a MessageBox 'On Top'

Posted on 2002-05-09
5
924 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
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 100 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now