We help IT Professionals succeed at work.

Inserting ComboBox text into a MessageBox

LordDamein asked
I have created a program where the user selects a time limit radio button, a skill from a ComboBox, then clicks a start button to start the timer.  When the timer has ran down the start button is re-enabled, the timer reset and a messagebox pops up to announce the ending of the time limit.

My problem is:
I want to add into the MessageBox the skill chosen from the ComboBox.  (i.e. "Your timer for "[ComboBox choice]" has expired.")  I want this feature since the user has the option of running multiple timers for multiple ComboBox choices and it would be nice if they knew which timer had expired.

I have tried everything that I can think of, looked through the search here, and other places.  The closest I get to my goal is getting the error:

[C++ Error] Main.cpp(558): E2034 Cannot convert 'AnsiString' to 'char *'.

(Borland C++ Builder 4.0)

Once I get my messageboxes working properly my program is done.  Please help me....
Watch Question

Using type cast

Example :

AnsiString str = "hello";
char *p = (char *) str.c_str();

Note : you can use  const_cast if you want

char *p = const_cast<char *>(str.c_str());


That was perfect, Thanks.

Going off of your example I was able to create a function to handle all possible timers and end them with a functional messagebox.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.