You are here: Home » Builder » [ En ] » Reporting formatted errors

Reporting formatted errors

14 June |

So, you want to report errors in a printf / sprintf way? Check this out…


    //—–blah blah

    void __fastcall TForm1::Button1Click(TObject *Sender)
    AnsiString filename=”c:\\mytestfile.txt”;

    if (!FileExists(filename))
    ShowError(“Cannot open file %s”,filename.c_str());

    void __cdecl TForm1::ShowError(const char *format, …)
    va_list args;


    AnsiString Buf=”";

    Application->MessageBoxA(Buf.c_str(),”ERROR”,MB_OK | MB_ICONERROR);

ps: don’t forget to declare void __cdecl TForm1::ShowError(const char *format, …) in your TForm class ;)

You like this post? Be the first of my friends to give me a beer! click here. Thanks!
Filed under

Builder, [ En ]

| Tags:

Comments are closed.