application.messagebox lazarus / 12-Debugger ---------------------------------------------------------------------- nocuttree · 2014-10-06 10:43 I have problem with this code s:='hello'; application.messagebox(s,'!!!',0); How to fix it? Thanks! ---------------------------------------------------------------------- Mike.Cornflake · 2014-10-06 10:49 How to fix what?  Give us at least a small clue as to what's going wrong... The following is guess that you're just trying to display text to the user... Code: [Select]Uses   Dialogs ... ... Var   s: String; Begin   s:='hello';   ShowMessage(s); End; ---------------------------------------------------------------------- ChrisF · 2014-10-06 11:34 I guess nocuttree is complaining about the error message when compiling: Code: [Select]unit1.pas(xx,xx) Error: Incompatible type for arg no. 1: Got "AnsiString", expected "PChar" So, an immediate quick and dirty fix would be: Code: [Select]application.messagebox(pchar(s),'!!!',0); or to use ShowMessage, as already proposed by Mike.Cornflake. ---------------------------------------------------------------------- nocuttree · 2014-10-06 15:53 Quote from: ChrisF on October 06, 2014, 01:34:34 pmI guess nocuttree is complaining about the error message when compiling: Code: [Select]unit1.pas(xx,xx) Error: Incompatible type for arg no. 1: Got "AnsiString", expected "PChar" So, an immediate quick and dirty fix would be: Code: [Select]application.messagebox(pchar(s),'!!!',0); or to use ShowMessage, as already proposed by Mike.Cornflake. Quote from: Mike.Cornflake on October 06, 2014, 12:49:50 pmHow to fix what?  Give us at least a small clue as to what's going wrong... The following is guess that you're just trying to display text to the user... Code: [Select]Uses   Dialogs ... ... Var   s: String; Begin   s:='hello';   ShowMessage(s); End;Thanks you very much! ---------------------------------------------------------------------- Edson · 2014-10-06 23:06 Also, you can use my library: https://github.com/t-edson/MisUtils and use: * MsgBox() -> for showing messages * MsgExc() -> for showing messages with the Exclamation Icon * MsgErr() -> for showing messages with the Error Icon Moreover, these procedures admit translation for other languages. ---------------------------------------------------------------------- CM630 · 2014-10-07 05:32 As I always do- I recommend using QuestionDlg than anything else. Because one day you decide to make a multi-language app and you start replacing all Application.MessageBox and ShowMsg with  QuestionDlg. Edit: Since *Edson mentioned MsgErr, IMHO using whatever print only dialogue for displaying errors is a mistake. Text printed on an error dialogue shall be copyable, so users could easily post/write somewhere "I got the following error message..... What to do?" ---------------------------------------------------------------------- nocuttree · 2014-10-07 13:08 Quote from: paskal on October 07, 2014, 07:32:57 amAs I always do- I recommend using QuestionDlg than anything else. Because one day you decide to make a multi-language app and you start replacing all Application.MessageBox and ShowMsg with  QuestionDlg. Edit: Since *Edson mentioned MsgErr, IMHO using whatever print only dialogue for displaying errors is a mistake. Text printed on an error dialogue shall be copyable, so users could easily post/write somewhere "I got the following error message..... What to do?" Quote from: Edson on October 07, 2014, 01:06:30 amAlso, you can use my library: https://github.com/t-edson/MisUtils and use: * MsgBox() -> for showing messages * MsgExc() -> for showing messages with the Exclamation Icon * MsgErr() -> for showing messages with the Error Icon Moreover, these procedures admit translation for other languages. Thanks you!