Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re-defining MessageBox

1 view
Skip to first unread message

Mark Weston

unread,
Aug 7, 2008, 4:23:52 AM8/7/08
to
Hello

I program in Borland C++ 5.02.

I have a large program with many calls to TWindow::MessageBox (and also
MessageBox(HWindow,...) )
It would be useful to log each message shown to the user.

This could be done by deriving from TWindow & re-writing the inherited
TWindow::MessageBox.
However, this could be long-winded as so many classes are derived from
TWindow, esp. TDialog.

Anyway, I'd like to update MessageBox(HWindow,...) similarly, & since
TWindow::MessageBox must call MessageBox(HWindow,...),
it makes more sense to just update MessageBox(HWindow,...).

But is there a way to re-define MessageBox(HWindow,...)?

Thanks,
Regards Mark


Ed Mulroy [TeamB]

unread,
Aug 7, 2008, 7:02:04 AM8/7/08
to
::MessageBox is a function supplied by Windows itself. You cannot get into
the middle of it like you can by writing a descendent class for one which
puts up a message box.

. Ed

> Mark Weston wrote in message
> news:489a...@newsgroups.borland.com...

Bob Gonder

unread,
Aug 7, 2008, 10:13:09 AM8/7/08
to
Mark Weston wrote:

>But is there a way to re-define MessageBox(HWindow,...)?

I think you would need to recompile the libraries with...

#include <windows.h>
#undefine MessageBox
WINUSERAPI
int
WINAPI
MessageBox(
IN HWND hWnd,
IN LPCSTR lpText,
IN LPCSTR lpCaption,
IN UINT uType);


Then in one of the libs...

WINUSERAPI int WINAPI MessageBox(
HWND hWnd,
LPCSTR lpText,
LPCSTR lpCaption,
UINT uType)
{
{Log code}
#ifdef UNICODE
return MessageBoxW(hWnd,l[Text,lpCaption,uType);
#else
return MessageBoxA(hWnd,l[Text,lpCaption,uType);
#endif // !UNICODE
}

0 new messages