PDA

Ver la Versión Completa : messagebox con botones en español


ingmichel
01-04-2011, 22:49:10
hola a todos, mi pregunta es sencilla, como puedo hacer que cuando haga un messagebox o dialog me aparezcan las opciones "yesno" en español o sea "si - no"

he intentado con esto pero no me sale:

MessageBoxEx(0,'desea continuar con la operacion ?', 'Advertencia',MB_YESNO + MB_ICONQUESTION,LANG_SPANISH );

gracias de antemano.

oscarac
01-04-2011, 22:54:05
yo tengo esta function donde tu mismo puedes crear tus botones y ponerle el texto que desees


function _Alert(const Msg: string; AType: TMsgDlgType; AButtons: TMsgDlgButtons; Captions: array of string): Integer;
var
unMsgDlg: TForm;
i: Integer;
dlgButton: TButton;
captionIndex: Integer;
begin
unMsgDlg := CreateMessageDialog(Msg,AType,AButtons);
captionIndex := 0;
for i := 0 to unMsgDlg.ComponentCount - 1 do
begin
if (unMsgDlg.Components[i] is TButton) then
begin
dlgButton := TButton(unMsgDlg.Components[i]);
if CaptionIndex > High(Captions) then Break;
dlgButton.Caption := Captions[CaptionIndex];
Inc(CaptionIndex);
end;
end;
Result := unMsgDlg.ShowModal;
end;



y lo llamas asi


_Alert('No existen Vouchers Descuadrados',mtWarning,[mbOK, mbRetry],['Aceptar','Intentar de nuevo']);

roman
01-04-2011, 23:03:46
También puedes usar Application.MessageBox, que pone los textos de los botones en el mismo idioma que tenga el S.O.

// Saludos

ingmichel
01-04-2011, 23:06:59
muchisimas gracias, acabo de probar tu funcion y funciona perfecto, gracias nuevamente, bendiciones.

oscarac
01-04-2011, 23:07:53
muchisimas gracias, acabo de probar tu funcion y funciona perfecto, gracias nuevamente, bendiciones.


de nada
estamos para apoyarnos....

ingmichel
01-04-2011, 23:08:39
También puedes usar Application.MessageBox, que pone los textos de los botones en el mismo idioma que tenga el S.O.

// Saludos

el problema es que el sistema operativo esta en ingles, la solucion que dio oscarac (http://www.clubdelphi.com/foros/member.php?u=12187) es la mas conveniente en mi caso, gracias de todas maneras.

Chris
01-04-2011, 23:45:56
Una solución más nativa es la que he proporcionado en mi blog, utilizando la misma API de Windows. Puedes leer sobre ella en este enlace (http://waodelphi.wordpress.com/2010/08/17/messagebox-con-etiquetas-personalizadas/).

Saludos,
Chris

marcopinero
27-06-2011, 18:36:05
Con tu permiso oscarac, quisiera mostrar tu función modificada por mí, pra que me funcionara:


function _Alert(const Msg: string; msgCaption: string; AType: TMsgDlgType;
AButtons: TMsgDlgButtons; Captions: array of string): Integer;
var
unMsgDlg: TForm;
i: Integer;
dlgButton: TButton;
captionIndex: Integer;
begin
captionIndex := 0;
try
unMsgDlg := CreateMessageDialog(Msg,AType,AButtons);
unMsgDlg.Caption:= msgCaption;
for i := 0 to unMsgDlg.ComponentCount - 1 do
begin
if (unMsgDlg.Components[i] is TBitBtn) then
begin
dlgButton := TButton(unMsgDlg.Components[i]);
if CaptionIndex > High(Captions) then Break;
dlgButton.Caption := Captions[CaptionIndex];
Inc(CaptionIndex);
end;
end;
Result := unMsgDlg.ShowModal;
finally
unMsgDlg.Free;
end;
end;


La uso así:


if _Alert('¿Desea salir del sistema Zeus4Linux 1.0?','Responda',mtConfirmation,
[mbYes, mbNo],['Sí','No']) = mrYes then...

oscarac
27-06-2011, 18:49:25
cualquier mejora es bienvenida