PDA

View Full Version : Need help to find a MessageBox() replacemend for *nix



Chebmaster
24-03-2007, 08:52 PM
You can see how poor the Linux part of this proc below looks.
No matter how hard I search (it's several years now! :evil:), I am unable to find a *simple* solution to replace the WinAPI's MessageBox function.

The problem is complicated by the fact that my program is written in pure FreePascal, no Lazarus involved.

procedure DisplayDyingYells;
var
tit, DyingYell: WideString;
titA: AnsiString;
begin
DyingYell:=ExtractDyingYell();
AddLog(MI_ERROR_MESSAGE_IS, [DyingYell]);
{$ifdef win32}
tit:=MessageContainer[MI_CGE_TITLE] + #0;
titA:=WideToAnsi(tit);
MessageBeep($FFFFFFFF);
if RunningInWindows9x()
//Windows 9x may not have Unicode support installed,
// so we convert the text ourselves and call the ANSI function,
// while assuming that the locale is Russian (cp1251).
then MessageBoxA(0, PChar(WideToAnsi(DyingYell)), @(titA[1]), MB_ICONERROR + MB_OK)
else begin
DyingYell:=DyingYell + #0;
MessageBoxW(0, @(DyingYell[1]), @(tit[1]), MB_ICONERROR + MB_OK);
end;
{$else}
WriteLn(#10#13#10#13#10#13 + ExtractFileName(ParamStr(0) + ' crashed!'));
Writeln(#10#13 + WideToAnsi(DyingYell) + #10#13);
{$endif}
end;

As you can see, to see wghat went wrong the Linux user should run my program from a console and see its output. :(

Legolas
24-03-2007, 09:58 PM
Mabe you could use xmessage (http://groups.google.it/group/comp.os.linux.development.apps/browse_frm/thread/f26578a2fce67cde/0f84d2ef1629c019)
:think:

Chebmaster
24-03-2007, 11:51 PM
Thank you! :D It helps (at least partially: the bugger cannot display Russian text :x)