Tienes razon amigo, este es el codigo en firebird en el triger donde llamo al evento ALTA si cumple la condicion
Código SQL
[-]
CREATE OR ALTER trigger evento_reg_internacion for registro_internacion
active after update position 0
AS
begin
if ((new.diagnostico_egreso<>'TRASLADO A OTRA CAMA Y SALA')and(new.tipo_alta is not null)) then
post_event 'ALTA';
end
Tengo un componente evento (tmdoevent) y un popup(msnpopup) en el formulario menu_caja y en el evento onshow tengo este codigo:
Código Delphi
[-]
procedure TF_Menu_Caja.FormShow(Sender: TObject);
begin
xpmenu1.Active:=true;
jvstatusbar1.Panels[1].Text:='Usuario: '+f_usuarios.loginn;
fd.UnLoad;
fd.AddFormClass(tf_pres_caja,true);
evento.Events.Add('ALTA');
evento.RegisterEvents;
end;
tambien probe en el evento oncreate pero tampoco pasaba nada, el siguiente codigo:
Código Delphi
[-]
evento.Events.Add('ALTA');
evento.RegisterEvents;
luego en el evento onevent del componente evento tengo el siguiente codigo:
Código Delphi
[-]
procedure TF_Menu_Caja.EventoEventAlert(Sender: TObject;
EventName: String; EventCount: Integer; var CancelAlerts: Boolean);
begin
If EventName = 'ALTA' then
BEGIN
popup.ShowPopUp;
END;
end;
ademas tengo una unidad donde personalizo mis mensajes en mi aplicacion el codigo es el siguiente:
Código Delphi
[-]
unit UnitShowMessage;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, LMDControl, LMDBaseControl, LMDBaseGraphicButton,
LMDCustomSpeedButton, LMDSpeedButton,Buttons, ExtCtrls,
LMDCustomButton, LMDButton, ImgList, JvGradient;
type
TFrmMessageBox = class(TForm)
LTitulo: TLabel;
LMensaje: TLabel;
BAceptar: TLMDButton;
BCancelar: TLMDButton;
PBMovible: TPaintBox;
BReintentar: TLMDButton;
PBIcono: TPaintBox;
ILIcono: TImageList;
JvGradient1: TJvGradient;
procedure FormShow(Sender: TObject);
procedure PBMovibleMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PBMovibleMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure PBMovibleMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PBIconoPaint(Sender: TObject);
private
RatonPulsado: Boolean;
Punto: TPoint;
public
end;
function Maximo (a,b:integer):integer;
FUNCTION MsgBox (Titulo, Mensaje: String; Flags: DWord):integer;
var
FrmMessageBox: TFrmMessageBox;
IndiceImagen:integer;
implementation
{$R *.dfm}
procedure TFrmMessageBox.FormShow(Sender: TObject);
begin
RatonPulsado := False;
end;
procedure TFrmMessageBox.PBMovibleMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
IF Button = mbLeft THEN
BEGIN
RatonPulsado := True;
Punto.x := x;
Punto.y := y;
END;
end;
function Maximo(a,b:integer):integer;
begin
if a>b then
Maximo:=a
else
Maximo:=b;
end;
FUNCTION MsgBox (Titulo, Mensaje: String; Flags: DWord): Integer;
CONST
PosLeft = 112;
PosWidth = 320;
LeftBotones = 25;
SepBotones = 7;
VAR
Botones, Icono: Word;
AlineacionDerecha: Boolean;
ResModal: TModalResult;
IdBotonPulsado: Integer;
BEGIN
Botones := Flags AND $F;
Icono := Flags AND $F0;
AlineacionDerecha := (Flags AND $F0000) = $80000;
IndiceImagen := 0;
WITH FrmMessageBox DO
BEGIN
Caption := Titulo;
LTitulo.AutoSize := False;
LMensaje.AutoSize := False;
LTitulo.Caption := Titulo;
LTitulo.Left := LeftBotones;
LTitulo.Width := 2 *(PosWidth DIV 3);
LTitulo.AutoSize := True;
LMensaje.Caption := Mensaje;
LMensaje.Left := PosLeft-15;
LMensaje.Width := PosWidth;
LMensaje.Alignment := taLeftJustify;
LMensaje.AutoSize := True;
LMensaje.Top := LTitulo.Top + LTitulo.Height + 15;
BAceptar.Top := LMensaje.Top + Maximo(LMensaje.Height, PBIcono.Height);
BCancelar.Top := BAceptar.Top;
BReintentar.Top := BAceptar.Top;
ClientHeight := BAceptar.Top + BAceptar.Height + 20;
CASE Botones OF
MB_OK:
BEGIN
BAceptar.Visible := True;
BCancelar.Visible := False;
BReintentar.Visible := False;
BAceptar.Caption := 'Aceptar';
BAceptar.Left := Width DIV 2 - BAceptar.Width DIV 3;
BAceptar.Width:=90;
END;
MB_OKCANCEL:
BEGIN
BAceptar.Visible := True;
BCancelar.Visible := True;
BReintentar.Visible := False;
BAceptar.Caption := ' Aceptar';
BCancelar.Caption := ' Cancelar';
BAceptar.Left := Width DIV 3 - BAceptar.Width DIV 3;
BCancelar.Left := BAceptar.Left + BAceptar.Width + SepBotones;
END;
MB_RETRYCANCEL:
BEGIN
BAceptar.Visible := False;
BCancelar.Visible := True;
BReintentar.Visible := True;
BCancelar.Caption := ' Cancelar';
BReintentar.Caption := ' Reintentar';
BReintentar.Left := Width DIV 3 - BReintentar.Width DIV 3;
BCancelar.Left := BReintentar.Left + BReintentar.Width + SepBotones;
END;
MB_YESNO:
BEGIN
BAceptar.Visible := True;
BCancelar.Visible := True;
BReintentar.Visible := False;
BAceptar.Caption := 'Si';
BCancelar.Caption := 'No';
BAceptar.Left := 112;
BAceptar.Width:=49;
BCancelar.Left := 232;
END;
MB_YESNOCANCEL:
BEGIN
BAceptar.Visible := True;
BCancelar.Visible := True;
BReintentar.Visible := True;
BAceptar.Caption := ' Sí';
BCancelar.Caption := ' No';
BReintentar.Caption := ' Cancelar';
BAceptar.Left := LeftBotones;
BCancelar.Left := BAceptar.Left + BAceptar.Width + SepBotones;
BReintentar.Left := BCancelar.Left + BCancelar.Width + SepBotones;
END;
END;
CASE Icono OF
MB_ICONINFORMATION:
IndiceImagen := 1;
MB_ICONERROR:
IndiceImagen := 2;
MB_ICONEXCLAMATION:
IndiceImagen := 3;
MB_ICONQUESTION:
IndiceImagen := 4;
END;
IF AlineacionDerecha THEN LMensaje.Alignment := taRightJustify;
END;
ResModal := FrmMessageBox.ShowModal;
IdBotonPulsado := 0;
CASE ResModal OF
mrOk: IdBotonPulsado := IDOK;
mrCancel: IdBotonPulsado := IDCANCEL;
mrAbort: IdBotonPulsado := IDABORT;
mrRetry: IdBotonPulsado := IDRETRY;
mrIgnore: IdBotonPulsado := IDIGNORE;
mrYes: IdBotonPulsado := IDYES;
mrNo : IdBotonPulsado := IDNO;
END;
MsgBox := IdBotonPulsado;
END;
procedure TFrmMessageBox.PBMovibleMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
IF RatonPulsado THEN
SetBounds(x - Punto.x + Left, y - Punto.y + Top, Width, Height);
end;
procedure TFrmMessageBox.PBMovibleMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
IF Button = mbLeft THEN RatonPulsado := False;
end;
procedure TFrmMessageBox.PBIconoPaint(Sender: TObject);
begin
ILIcono.Draw(PBIcono.Canvas, 0, 0, IndiceImagen);
end;
end.
que como veran solo llamo a la funcion MsgBox de esta unidad para mostrar mi mensaje personalizado.
El formulario asociado a esta unidad lo creo cuando se ejecuta la aplicacion,
Ahora me puse un boton en el formulario menu_caja para llamar al popup y me da bien.
El evento se genera en otro modulo(menu_enfermeria) que esta en otro ambiente que una vez que guarden los datos del paciente, quisiera que me muestre los datos de este paciente en el menu_caja con el popup pero no me muestra,probe con un showmessage y da bien , probe con la unidad q tengo para mis mensajes personalizados y da, pero como en el menu_caja tengo un boton para salir del sistema el cual llama a la funcion msgbox me da el error que anteriormente te comente.
Particularmente nose como hacer para que me muestre en el popup,creo q seria mas visual para el usuario,agradesco comentarios amigo o amigos