The most difficult part of this task is difuring out how to trigger the dialog when the message is issued. Rolf gave an implementation that relies on setting the CellEpilog function for the notebook. I would like to show two other, possible more reliable ways that do not rely on Front End functionality.
The first one relies on a method invented by Todd Gayley and Robby Villegas to wrap built-in function, in this case Message. I learned about it from
here. The disadvantage of this method is that it does not honour Quiet[].
ClearAll[messageText]
SetAttributes[messageText, HoldAll]
messageText[msg : MessageName[sym_, name_]] := msg /. Messages[sym]
Unprotect[Message]
Message[first_, rest___] :=
Block[{$inMsg = True, result},
result = Message[first, rest];
If[Hold[first] === Hold[Power::infy],
MessageDialog[StringForm[messageText[Power::infy], rest]]];
result] /; ! TrueQ[$inMsg]
The second and more reliable one uses an undocumented "handler" interface that I
believe was meant to be used by the built-in debugger. Please see
here for how it works.
messageHandler[Hold[Message[Power::infy, arg_], True]] := MessageDialog[StringForm[messageText[Power::infy], arg]]
Internal`AddHandler["Message", messageHandler]
I left out the details of generalizing this to work with any message and wrapping it up in an OnDialog inteface, as that part is relatively easy to do.