Solved

Displaying a MessageBox 'On Top'

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Building cUrl in Windows v7.43.0 4 36
Need some help with listview limit text 20 110
how to understand recursion 12 229
operator overload: incompatible type and too many params 5 83
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

839 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