Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Incompatible types: 'PWideChar' and 'string' (https://www.clubdelphi.com/foros/showthread.php?t=88218)

JuanOrtega 30-04-2015 19:40:25

Incompatible types: 'PWideChar' and 'string'
 
Hola tengo un problema con el siguiente codigo :

Código Delphi [-]
var test:string;
begin
test := 'test';    
MessageBox(0, 'test : ' + Pchar(test), 'test',MB_ICONINFORMATION);
end;

El problema es que siempre me devuelve el clasico error : "Incompatible types: 'PWideChar' and 'string'" intente usando Pchar() y PWideChar() pero el error siempre es el mismo.

¿ Como soluciono esto ?

ElKurgan 30-04-2015 19:57:24

Como siempre, ayudaría saber con que versión de Delphi estás trabajando.

A partir de Delphi 2009 los string originales han pasado a ser AnsiString, mientras que el nuevo string equivale al antiguo WideString, para soportar caracteres Unicode.

Así, a ciegas, poco más podemos ayudar

Nota: Con la ayuda Intsight de Delphi te debería mostrar los parámetros que espera la función MessageBox; solo tienes que ceñirte a lo que espera recibir y poner el tipo correcto

Saludos

JuanOrtega 30-04-2015 20:00:44

perdon me olvide decir que uso Delphi XE2 , gracias por responder.

JuanOrtega 30-04-2015 21:26:48

perdon por el doble post pero ya lo solucione ...

Código Delphi [-]
var test:string;
begin
test := 'test';    
MessageBox(0, Pchar('test : ' + test), 'test',MB_ICONINFORMATION);
end;


La franja horaria es GMT +2. Ahora son las 01:06:57.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi