Search code examples
delphidelphi-10.2-tokyo

ShowMessage works but application.messagebox dont


ShowMessage('MAC  - (Client: '
        + DM.qTmp.FieldByName('CL_NR').AsString + ' , Place: ' + DM.qTmp.FieldByName('CL_DESC').AsString);

This code works fine, but how i can do that with

Application.MessageBox('MAC  - (Client: '
            + DM.qTmp.FieldByName('CL_NR').AsString + ' , Place: ' + DM.qTmp.FieldByName('CL_DESC').AsString' , 'Error', 16);

Got various errors [dcc32 Error] untPCName.pas(79): E2010 Incompatible types: 'PWideChar' and 'string' DELPHI version is 10.2.


Solution

  • To fix the "Incompatible types" errors you have to cast. Notice the PChar(...):

    Application.MessageBox(PChar('Whatever'), 'Error', MB_ICONHAND);
    

    I also replaced the magic number 16 with something sensible.