473,320 Members | 2,189 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Use MessageBox in Win32 pgm with STL - winuser.h n/g in this context

Hi,

I've got a progam which has a half-dozen STL headers and works fine.

I want to use a MessageBox type function. I'm not aware of any STL
thing like that. I tried to use it with the header MSDN says defines
it, winuser.h, but that wrecks things. (There's no winuser.)

I'm not surprised the .h content conflicted with STL, although I'm
using direct.h (for _getcwd) with no conflict.

Any advise would be most welcome.

TIA,
Richard

Mar 23 '06 #1
7 2393
Cat
Include <windows.h>

Mar 23 '06 #2
Hi Cat,

You were right on! That got past the comile hurdle.

Now comes the DLL hurdle. I got the linker message:
unresolved external symbol __imp__MessageBoxA@16

So I've got two problems:
1. What DLL has that import symbol?
2. How do reference that DLL in the cl command?

I doing command-line builds because Visual Studio.Net threw in a slew
of .Net stuff which I don't know much about while I just wanted to run
a vanilla Win32/STL application.

Any ideas?

Regards,
Richard

Mar 23 '06 #3
Richard Lionheart wrote:
Hi Cat,

You were right on! That got past the comile hurdle.

Now comes the DLL hurdle. I got the linker message:
unresolved external symbol __imp__MessageBoxA@16

So I've got two problems:
1. What DLL has that import symbol?
2. How do reference that DLL in the cl command?

I doing command-line builds because Visual Studio.Net threw in a slew
of .Net stuff which I don't know much about while I just wanted to run
a vanilla Win32/STL application.

Any ideas?

Regards,
Richard


Try link with user32.lib

Regards,
Ben
Mar 23 '06 #4

"Richard Lionheart" <RL******@USComputerGurus.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
| Hi,
|
| I've got a progam which has a half-dozen STL headers and works fine.
|
| I want to use a MessageBox type function. I'm not aware of any STL
| thing like that. I tried to use it with the header MSDN says defines
| it, winuser.h, but that wrecks things. (There's no winuser.)
|
| I'm not surprised the .h content conflicted with STL, although I'm
| using direct.h (for _getcwd) with no conflict.
|
| Any advise would be most welcome.
|
| TIA,
| Richard
|

You are off topic.

However, if you include windows.h then you can simply call ::MessageBox
see Exception::report() below.

#include "tchar.h"
#include <string>
#include <stdexcept>
#include "windows.h"

const int STATUS_FAILURE(-1);
const int STATUS_SUCCESS(0);

class Exception : public std::exception
{
std::string m_origin;
public:
Exception(std::string o, std::string s)
: std::exception(s.c_str()),
m_origin("Error in " + o) { }
virtual ~Exception() { }
/* member functions */
void report() const
{
std::string s(_T("info :\t"));
s += what();
s += "\t";
::MessageBox( 0,
s.data(),
m_origin.data(),
MB_OK | MB_ICONERROR );
} // report()
};

int main()
{
int result = STATUS_FAILURE;
bool condition = false; // false to see messagebox
try
{
if(!condition) // origin info
throw Exception(_T("main()"), _T("condition == false !"));
result = STATUS_SUCCESS;
}
catch (const Exception& e)
{
e.report();
}
return result;
}

Mar 23 '06 #5
Hi benben,
You are off topic.
Why? I'm writing a Win32/STL app. Unfortunately, the most convenient
way I found to do this with Visual Studio .NET throwing a lot of c#
etc. in my way is to use VS as my editor and then running command line
compiles. But that makes debugging more difficult. The easiest I
could think of is MessageBox. But I like your exceptions approach, so
I think I'll adopt it after looking at it more closely.
if you include windows.h then you can simply call ::MessageBox
Thanks for that. Peter Julian posted the library I needed to go along
with windows.h and ::MessageBox.
see Exception::report() below.


Thanks for a correct, working example. It's much appreciated.

Regards,
Richard

Mar 23 '06 #6
Thanks, that worked great!

BTW, what if anything did you reference to know that the user32
library would satisfy external reference in things declared in
windows.h (assuming that's the case)?

Regards,
Richard

Mar 23 '06 #7

Richard Lionheart wrote:
Hi benben,
You are off topic.


Why?


http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Gavin Deane

Mar 24 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sdeyoreo | last post by:
How do I display the integer in pt.x in a message box? I get a error on parameter 2 of MessageBox call: char str; sprintf(str,"point x is %d",pt.x); MessageBox(NULL,str,NULL,MB_OK);
0
by: Veli-Pekka Tätilä | last post by:
Hi, My first post here. I've found some serious accessibility flaws in the Python 2.4 docs and wish they could be rectified over time. I'm very new to Python and initially contacted docs at python...
8
by: Dennis C. Drumm | last post by:
I have ordered the book .NET Framework Solutions, In Search of the Lost Win32 API by John Paul Meuller which I think will help answer some of my questions I have regarding making custom...
2
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.)...
7
by: Bill | last post by:
For some reason, I have an errormessage popup that "blinks", but pops up BEHIND the applications, which is confusing to users. Is there any way to force it to the top?
3
by: Sin | last post by:
I'm currently evaluating VC.NET as the new platform for the company I work for and things are looking grim... We're up against another IDE which took me about 5 minutes to master and I've been...
0
by: Guy Mahieu | last post by:
Hi, I am trying to dynamically add menu items to external win32 applications from c# code. I have found some VB6 examples on the net that do just that, but when I rewrite them into c# they will...
0
by: peng.wu_cn | last post by:
I use MessageBox to show a command usage.I hope parameters and comments keep left alignment,so I insert space char to format them. But the result was not like I expected, it looks all space char...
3
by: neeraj pandey | last post by:
I wrote an application for Windows mobile 5.0 pocket pc . I want to port it on WIN 32 . I build it win32 it throwing the errors: WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.