Ver Mensaje Individual
  #8  
Antiguo 18-08-2008
Avatar de Delphius
[Delphius] Delphius is offline
Miembro Premium
 
Registrado: jul 2004
Ubicación: Salta, Argentina
Posts: 5.582
Reputación: 25
Delphius Va camino a la fama
Cita:
Empezado por BuRtOn Ver Mensaje
Huy gracias...Delphius una pregunta, es que a mi me gusta entender las cosas, y mi pregunta es, para que utilizas el PChar, que funcion cumple..???, es que lo he visto en otra ocasion....por ejemplo cuandop trate de editar el binario en el registro, tu me pasaste un codigo y obtenia un PChar....gracias a todos por su grandioso tiempo..
Por empezar, TApplication.MessageBox() necesita de 2 parámetros PChar. Un PChar es un tipo un tanto especial... para hacerlo simple es un puntero a un conjunto de caracteres. De modo que cuando uno hace PChar(Algo), le está indicando que lea el contenido de la dirección de memoria de la variable algo.

Lo que sucede es que si uno pone un string cualquiera en dichos parámetros el compilador solito no reniega y se encarga de hacer la "conversión" necesaria. Pero si tu quieres mostrar el contenido de una variable string, el compilador te dirá que es incompatible el String con PChar. Necesitarás hacer uso de PChar.

Por otro lado, te tengo una sorpresita. Esto dice la ayuda sobre TApplication.MessageBox():

Cita:
Use MessageBox to display a generic dialog box a message and one or more buttons. Caption is the caption of the dialog box and is optional.

MessageBox is an encapsulation of the Windows API MessageBox function. TApplication’s encapsulation of MessageBox automatically supplies the missing window handle parameter needed for the Windows API function.

The value of the Text parameter is the message, which can be longer than 255 characters if necessary. Long messages are automatically wrapped in the message box.

The value of the Caption parameter is the caption that appears in the title bar of the dialog box. Captions can be longer than 255 characters, but don't wrap. A long caption results in a wide message box.

The Flags parameter specifies what buttons appear on the message box and the behavior (possible return values). The following table lists the possible values. These values can be combined to obtain the desired effect.
Presta atención a lo resaltado. Dice que los mensajes largos son cortados, para mostrarlos en otra linea. ¿Será?

Hagamos la prueba:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var texto: string;
begin
  texto := 'Este texto es lo suficientemente grande como para que tal vez no entre en un "dialogo normal"... hay que ver como se vé.... y continua.... y continua... ¿Tendrá fin esto? Veamos... che... ¿Se pasa a la segunda línea?';
  Application.MessageBox(PChar(texto),'titulo',MB_OK)
end;

¿Como se vé? ¿Lo corta? ¿Te gusta como queda?

No más te lo dejo como dato curioso Tu saca conclusiones. ¿Lo cortamos a mano?

Saludos,
__________________
Delphius
[Guia de estilo][Buscar]
Responder Con Cita