var   
     mes: string;
    response: integer;
begin
  
  mes := '确定删除 ' + adotable1.fieldvalues['轴承型号'] + '?';  response := application.messagebox(mes, '提示', MB_OKCANCEL)
总是提示messagebox中mes类型应该是pchar,而不是string
请问如何转换?
急。

解决方案 »

  1.   

    用强自转换不就行了吗。
    response := application.messagebox(pchar(mes), '提示', MB_OKCANCEL);
      

  2.   

    pchar(your_string)
    是一个好方法
    var   
         mes: string;
        response: integer;
    begin
      
      mes := '确定删除 ' + adotable1.fieldvalues['轴承型号'] + '?';  response := application.messagebox(pchar(mes), '提示', MB_OKCANCEL)
      

  3.   

    PChar(String) 强制类型转换即可.
      

  4.   

    var   
         mes: string;
        response: integer;
    begin
      
      mes := '确定删除 ' + adotable1.fieldvalues['轴承型号'] + '?';  response := application.messagebox(pChar(mes), '提示', MB_OKCANCEL)
      

  5.   

    string -> pchar: PChar(string);
    pchar -> string: 直接用,会自动转的。
      

  6.   

    application.messagebox(pchar(mes), '提示', MB_OKCANCEL)我原本不是一头猪
      

  7.   

    messagebox具体参数定义如下:int MessageBox(    HWND hWnd,  // handle of owner window
        LPCTSTR lpText, // address of text in message box
        LPCTSTR lpCaption, // address of title of message box  
        UINT uType  // style of message box
       );
     参数说明:hWndIdentifies the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window. lpTextPoints to a null-terminated string containing the message to be displayed. lpCaptionPoints to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title Error is used. uTypeSpecifies a set of bit flags that determine the contents and behavior of the dialog box. 
      

  8.   

    老版本的DELPHI还可以用strpcopy函数