Jump to content


Stacking TNxAlertWindow instances


  • Please log in to reply
No replies to this topic

#1 nevel

nevel
  • Members
  • 8 posts

Posted 05 August 2011 - 05:14 PM

If you're interested in stacking TNxAlertWindow windows instead of them waiting for their turn, it looks like you'll have to create a new instance for each message.
At least, that was my conclusion after fiddling around, please correct me if I'm wrong,

So my initial solution was as follows:

procedure TRollupManager.ShowRollup(const AText: String; const AGlyphName: String; const ACheckedIn: Boolean; ABgColor: TColor = clDefault);
begin
  FRollup := TNxAlertwindow.Create(nil);
  PreparePopup(AText, AGlyphName, ACheckedIn, ABgColor);
  FRollup.Popup;
end;

Naturally, this will cause memory leaks, since earlielrTNxAlertWindow instances will loose their reference after others have been instantiated.
However, this can easily be solved by cleaning up each instance using the OnClose event:

FRollup.OnClose := DoRollupClose;

My DoRollupClose event handler looks like this:

procedure TRollupManager.DoRollupClose(Sender: TObject);
begin
  TNxAlertWindow(Sender).LargeGlyph.NormalGlyph.FreeImage;
  TNxAlertWindow(Sender).SmallGlyph.NormalGlyph.FreeImage;
  TNxAlertWindow(Sender).CloseGlyph.NormalGlyph.FreeImage;
  TNxAlertWindow(Sender).CloseGlyph.HoverGlyph.FreeImage;
  TNxAlertWindow(Sender).Free;
end;

This way, you don't need to maintain a collection of TNxAlertWindow instances or anything similar.
Please note I deliberately don't use the "with" notation, since I'm not a big fan of doing so.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users