This patch fixes some bugs in the OnClose event handler and updates the demo 
program to show how to use it.
As promissed I have also documented the component on the wiki.

Ciao
A.J.
-- 
"there's nothing as inspirational for a hacker as a cat obscuring a bug 
by sitting in front of the monitor" - Boudewijn Rempt
A.J. Venter
Chief Software Architect
OpenLab International
www.getopenlab.com
www.silentcoder.co.za
+27 82 726 5103
Index: components/popupnotifier/demo/unit1.lrs
===================================================================
--- components/popupnotifier/demo/unit1.lrs	(revision 9429)
+++ components/popupnotifier/demo/unit1.lrs	(working copy)
@@ -1,3 +1,5 @@
+{ This is an automatically generated lazarus resource file }
+
 LazarusResources.Add('TForm1','FORMDATA',[
   'TPF0'#6'TForm1'#5'Form1'#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'
   +#12'ClientHeight'#3#214#0#11'ClientWidth'#3#214#0#13'PixelsPerInch'#2'V'#18
@@ -3,13 +5,13 @@
   +'HorzScrollBar.Page'#3#213#0#18'VertScrollBar.Page'#3#213#0#4'Left'#3#251#1#6
   +'Height'#3#214#0#3'Top'#3#156#0#5'Width'#3#214#0#0#7'TButton'#7'Button1'#25
-  +'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#15'Show/Hide Popup'#7'OnClick'#7
-  +#12'Button1Click'#8'TabOrder'#2#0#4'Left'#2#24#6'Height'#2#25#3'Top'#2#8#5'W'
-  +'idth'#3#160#0#0#0#5'TMemo'#5'Memo1'#13'Lines.Strings'#1#6#22'This is a test'
-  +' message'#0#8'TabOrder'#2#1#4'Left'#2#24#6'Height'#2'Z'#3'Top'#2'P'#5'Width'
-  +#3#158#0#0#0#5'TEdit'#5'Edit1'#8'TabOrder'#2#2#4'Text'#6#10'Test Popup'#4'Le'
-  +'ft'#2#24#6'Height'#2#23#3'Top'#2'0'#5'Width'#3#155#0#0#0#7'TButton'#7'Butto'
-  +'n2'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#10'Edit Popup'#7'OnClick'
-  +#7#12'Button2Click'#8'TabOrder'#2#3#4'Left'#2#24#6'Height'#2#25#3'Top'#3#176
-  +#0#5'Width'#3#158#0#0#0#14'TPopupNotifier'#14'PopupNotifier1'#5'Color'#4#255
+  +'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#10'Show Popup'#7'OnClick'#7#12
+  +'Button1Click'#8'TabOrder'#2#0#4'Left'#2#24#6'Height'#2#25#3'Top'#2#8#5'Widt'
+  +'h'#3#160#0#0#0#5'TMemo'#5'Memo1'#13'Lines.Strings'#1#6#22'This is a test me'
+  +'ssage'#0#8'TabOrder'#2#1#4'Left'#2#24#6'Height'#2'Z'#3'Top'#2'P'#5'Width'#3
+  +#158#0#0#0#5'TEdit'#5'Edit1'#8'TabOrder'#2#2#4'Text'#6#10'Test Popup'#4'Left'
+  +#2#24#6'Height'#2#23#3'Top'#2'0'#5'Width'#3#155#0#0#0#7'TButton'#7'Button2'
+  +#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#10'Edit Popup'#7'OnClick'#7
+  +#12'Button2Click'#8'TabOrder'#2#3#4'Left'#2#24#6'Height'#2#25#3'Top'#3#176#0
+  +#5'Width'#3#158#0#0#0#14'TPopupNotifier'#14'PopupNotifier1'#5'Color'#4#255
   +#255#220#0#9'Icon.Data'#10#213'v'#0#0#7'TPixmap'#201'v'#0#0'/* XPM */'#10'st'
   +'atic char * mainicon_xpm[] = {'#10'"48 48 1597 2",'#10'"  '#9'c None",'#10
@@ -569,6 +571,6 @@
   +'                      ",'#10'"B!C!D!E!F!G!H!I!J!K!L!M!N!O!P!Q!R!S!T!U!V!W!X'
   +'!Y!Z!`! [EMAIL PROTECTED]                                ",'#10'"%~&~*~=~-~;~>~,~'
   +'g J>''~)~!~~~{~d.]~^~/~(~U!_~:~<~[~}~|~1~2~3~4~                            '
-  +'      "};'#10#4'Text'#6#22'This is a test Message'#5'Title'#6#9'TestPopup'#3
-  +'top'#3#187#0#0#0#0
+  +'      "};'#10#4'Text'#6#22'This is a test Message'#5'Title'#6#9'TestPopup'#7
+  +'OnClose'#7#19'PopupNotifier1Close'#3'top'#3#187#0#0#0#0
 ]);
Index: components/popupnotifier/demo/unit1.pas
===================================================================
--- components/popupnotifier/demo/unit1.pas	(revision 9429)
+++ components/popupnotifier/demo/unit1.pas	(working copy)
@@ -20,6 +20,8 @@
     PopupNotifier1: TPopupNotifier;
     procedure Button1Click(Sender: TObject);
     procedure Button2Click(Sender: TObject);
+    procedure PopupNotifier1Close(Sender: TObject; var CloseAction: TCloseAction
+      );
   private
     { private declarations }
   public
@@ -38,9 +40,11 @@
   If PopupNotifier1.Visible then
    Begin
         PopupNotifier1.Hide;
+        Button1.Caption := 'Show Popup';
    end else
    begin
         PopupNotifier1.ShowAtPos(100,100);
+        Button1.Caption := 'Hide Popup';
    end;
 end;
 
@@ -57,9 +61,15 @@
   end;
 end;
 
+procedure TForm1.PopupNotifier1Close(Sender: TObject;
+  var CloseAction: TCloseAction);
+begin
+  Button1.Caption := 'Show Popup';
+end;
 
 
 
+
 initialization
   {$I unit1.lrs}
 
Index: components/popupnotifier/demo/unit1.lfm
===================================================================
--- components/popupnotifier/demo/unit1.lfm	(revision 9429)
+++ components/popupnotifier/demo/unit1.lfm	(working copy)
@@ -12,7 +12,7 @@
   Width = 214
   object Button1: TButton
     BorderSpacing.InnerBorder = 4
-    Caption = 'Show/Hide Popup'
+    Caption = 'Show Popup'
     OnClick = Button1Click
     TabOrder = 0
     Left = 24
@@ -1005,6 +1005,7 @@
     }
     Text = 'This is a test Message'
     Title = 'TestPopup'
+    OnClose = PopupNotifier1Close
     top = 187
   end
 end
Index: components/popupnotifier/popupnotifier.pas
===================================================================
--- components/popupnotifier/popupnotifier.pas	(revision 9429)
+++ components/popupnotifier/popupnotifier.pas	(working copy)
@@ -75,6 +75,7 @@
     function GetVisible: Boolean;
     procedure SetVisible(const Value: Boolean);
     procedure SetOnClose(const Value: TCloseEvent);
+    function  GetOnClose:TCloseEvent;
   public
     vNotifierForm: TNotifierForm;
     constructor Create(AOwner: TComponent); override;
@@ -88,7 +89,7 @@
     property Text: string read GetText write SetText;
     property Title: string read GetTitle write SetTitle;
     property Visible: Boolean read GetVisible write SetVisible;
-    property OnClose: TCloseEvent write SetOnClose;
+    property OnClose: TCloseEvent  read GetOnClose write SetOnClose;
   end;
 
 const
@@ -229,12 +230,12 @@
 *  Releases associated resources of the notifier form
 *******************************************************************}
 destructor TNotifierForm.Destroy;
+
 begin
   ImgIcon.Free;
   lblTitle.Free;
   lblText.Free;
   BtnX.Free;
-
   inherited Destroy;
 end;
 
@@ -244,7 +245,10 @@
 *  Utilized for events that hide the form, such as clicking on it
 *******************************************************************}
 procedure TNotifierForm.HideForm(Sender: TObject);
+Var NoValue :TCloseAction;
 begin
+if Assigned(OnClose) then
+   OnClose(Self,NoValue);
   Hide;
 end;
 
@@ -322,9 +326,15 @@
 
 procedure TPopupNotifier.SetOnClose(const Value: TCloseEvent);
 begin
-  vNotifierForm.OnClose := Value;
+  VNotifierForm.Onclose := Value;
 end;
 
+function TPopupNotifier.GetOnClose:TCloseEvent;
+begin
+  Result := VNotifierForm.Onclose;
+end;
+
+
 function TPopupNotifier.GetVisible: Boolean;
 begin
   Result := vNotifierForm.Visible;

Reply via email to