| | |
Calling MessageBox in Borland C++Builder
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Solved Threads: 0
Hello everyone,
I don't often use forums for getting answers, but I simply cannot seem to find how to fire a MessageBox under Borland Builder...I could use MessageDlg which works, but I only want an OK button, so I would rather go with MessageBox...code sample:
With MessageDlg:
NOTE: I know it defines mbOK as a variable for TMsgDlgButtons, but it fires an error that it's NOT a recognized variable...I may be overlooking something, but it's late and I've been coding for hours now just getting my ActiveX control to function without causing access violations at memory address 0x000000 (WideString function is your friend.) Next issue will be writing the code to open a file which is like an ini file, but has a different structure (ie: no "[]" but uses "=" as an assignment operator...I *think* I have the groundwork set, but am unfamiliar with C++ file manipulation, I had created a similar program in VB6 and the styles of coding are mixing in my head =)
Thanks in advance for any information.
I don't often use forums for getting answers, but I simply cannot seem to find how to fire a MessageBox under Borland Builder...I could use MessageDlg which works, but I only want an OK button, so I would rather go with MessageBox...code sample:
C++ Syntax (Toggle Plain Text)
void __fastcall TForm1::cmdPlayClick(TObject *Sender) { if (TForm1::txtLogin->Text=="") { ::MessageBox("Invalid Login Name!", "Error!", MB_OK, 0); return; }
C++ Syntax (Toggle Plain Text)
if (TForm1::txtPass->Text=="") { MessageDlg("Invalid Password!", mtError, mbOKCancel, 0); return; } TForm1::LoadLauncher(); }
Thanks in advance for any information.
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Solved Threads: 0
*sigh*
I found my error, in Borland's help files, it gives an example of:
My error was using it in my Unit1.cpp file. Since all my declarations and main code is in the header file, it gave mystery errors and I tried various implementations like TApplication::MessageBox(blah) and stopped getting errors with plain ::MessageBox(blah) I moved the code into my header file and it now works. snippet for future reference:
Like I said previously, it was late and I had the too-many-hours-coding-brain-lock syndrome to recognize that issue. Figured I would reply with my fix. Thanks for your help...off to build my file handling routines =)
I found my error, in Borland's help files, it gives an example of:
C++ Syntax (Toggle Plain Text)
Application->MessageBox(const WideString Text, const WideString Caption, TMessageButtons Buttons = TMessageButtons() << smbOK, TMessageStyle Style smsInformation, TMessageButton Default = smbOK, TMessageButton Escape = smbCancel);
C++ Syntax (Toggle Plain Text)
Application->MessageBox("Message", "Title", Buttons() << btnValue); //btnValue is MB_OK, etc. for the various button styles.
•
•
Join Date: Jun 2005
Posts: 9
Reputation:
Solved Threads: 1
Hi,
Try this
if( MessageBox(0, (LPSTR) "testing", "Error",
MB_ICONWARNING | MB_OK ) ==MB_OK) //do whatever
regards
Bob
Try this
if( MessageBox(0, (LPSTR) "testing", "Error",
MB_ICONWARNING | MB_OK ) ==MB_OK) //do whatever
regards
Bob
•
•
•
•
Hello everyone,
I don't often use forums for getting answers, but I simply cannot seem to find how to fire a MessageBox under Borland Builder...I could use MessageDlg which works, but I only want an OK button, so I would rather go with MessageBox...code sample:
With MessageDlg:C++ Syntax (Toggle Plain Text)
void __fastcall TForm1::cmdPlayClick(TObject *Sender) { if (TForm1::txtLogin->Text=="") { ::MessageBox("Invalid Login Name!", "Error!", MB_OK, 0); return; }
NOTE: I know it defines mbOK as a variable for TMsgDlgButtons, but it fires an error that it's NOT a recognized variable...I may be overlooking something, but it's late and I've been coding for hours now just getting my ActiveX control to function without causing access violations at memory address 0x000000 (WideString function is your friend.) Next issue will be writing the code to open a file which is like an ini file, but has a different structure (ie: no "[]" but uses "=" as an assignment operator...I *think* I have the groundwork set, but am unfamiliar with C++ file manipulation, I had created a similar program in VB6 and the styles of coding are mixing in my head =)C++ Syntax (Toggle Plain Text)
if (TForm1::txtPass->Text=="") { MessageDlg("Invalid Password!", mtError, mbOKCancel, 0); return; } TForm1::LoadLauncher(); }
Thanks in advance for any information.
![]() |
Similar Threads
- Borland C++ Builder 6 Errors (C++)
- MapPoint - how to install component in Borland C++ Builder (C++)
- Borland c++ builder question (C++)
- Drawing a circle in Borland C++ builder (was: Help Me!!!!!) (C++)
- Borland C++ builder - how to save in .CPP format (C++)
Other Threads in the C++ Forum
- Previous Thread: numbering code lines
- Next Thread: software
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelp homeworkhelper iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings template text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






