开发者

Button Notifications In Delphi 7

I have searched many forums and many web sites but i didn't find the required solution.I had a requirement to show the number of notifications to buttons .When the form Loads.If the notifications are hundred there should be 1开发者_开发知识库00 beside the button.if nothing then no notification should be visible.

Please suggest me the required solution..

Thanks In advance.

They are asking the similar functionality as in Icons of IOS4.


If you don't mind using a component for this instead of making your own, there is one that does what you need. It will display a status and looks just like what you have shown in your image link.

Button Notifications In Delphi 7

You can see this page here

It is not free though.


In iOS 4 there are icons with notifications (for programm-startup) and no buttons (I think), so this is not really the same,... but maybe you can create a custom button (inherit from TButton) and use something like an onPaint Event (sorry this is too much dotnet-style,... don't know how it is called in delphi) to draw this "notification" to the button like you do it in TCanvas.


I think you can use TBalloonHint component. For example, To show the notification,

procedure TForm1.FormCreate(Sender: TObject);
var
  point : TPoint;
begin
  point.X := sb1.Left;
  point.Y := sb1.Top;
  BalloonHint1.Delay := 100;
  //BalloonHint1.Description := 'This is your Notification!';
  BalloonHint1.HideAfter := -1;
  BalloonHint1.Style := bhsBalloon;
  BalloonHint1.Title := '2';
  sb1.ParentShowHint := False;
  BalloonHint1.ShowHint(point);
end;

To Hide the notification

procedure TForm1.sb1Click(Sender: TObject);
begin
  BalloonHint1.HideHint;
end;

It would be see like the above image

Button Notifications In Delphi 7

If you want to show images, you can use the BalloonHint1.Images property.


You could use a TPaintBox and draw directly to its Canvas property. TCanvas has a number of methods that would make this a fairly simple task, in my opinion. Just store the background image separately (maybe in a TImage), copy it to the canvas (using the Draw method in the OnPaint event), and then paint the circle (Ellipse method) and the number last (TextOut or TextRect). You can also use the OnClick event of the TPaintBox to manage the "button clicking" operations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜