We help IT Professionals succeed at work.
Get Started

Universal MessageBox

khampton
khampton asked
on
1,843 Views
Last Modified: 2020-04-13
I would like to build a "universal" messagebox that will accept any type (and number) of args. This routine will convert the args (if necessary), concatinate them and then show them via the messagebox... I would like to use STL but I really don't have deep experiece with C++ and could use some help...

example:

//prototype:
void UMsgBox(...)

void UMsgBox(...)
{
   string s;
   string convArg;
   //loop thru each argument:

   for( int i = 0; i < nArgs; ++i )
   {
     //get an arg:
     ---
     //convert it to a string type:
     convArg = ---
     //concatenate the arg to the cumulative string:
     s=s+convArg;
    }
   messagebox(NULL,s,"",MB_OK);
}

Note: I would like the args to be of any type, including pointers (in which case you would be printing an adress).

the caller would just use UMsgbox like this:

UMsgbox(V1," Hi Mom! ",T2,s," pointer: ",pData);

Please help me by suppling or substituting the necessary code.

Thanks in advance!
       
   
   

   

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 163 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE