Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2005, 02:22 AM
dorjvar dorjvar is offline
Member
 
Join Date: May 2005
Posts: 38
Default about balloon

hello
I made a ballon but ite in back of all windows
I want that it be on top of all windows like windows balloons
thanks

my unit is this

unit MainUn;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

const
NIF_INFO = $10;
NIF_MESSAGE = 1;
NIF_ICON = 2;
NOTIFYICON_VERSION = 3;
NIF_TIP = 4;
NIM_SETVERSION = $00000004;
NIM_SETFOCUS = $00000003;
NIIF_INFO = $00000001;
NIIF_WARNING = $00000002;
NIIF_ERROR = $00000003;
NIN_BALLOONSHOW = WM_USER+2;
NIN_BALLOONHIDE = WM_USER+3;
NIN_BALLOONTIMEOUT = WM_USER+4;
NIN_BALLOONUSERCLICK = WM_USER+5;
NIN_SELECT = WM_USER+0;
NINF_KEY = $1;
NIN_KEYSELECT = NIN_SELECT OR NINF_KEY;
TRAY_CALLBACK=WM_USER+$7258;

TYPE
PnewNotifyIconData = ^TNewNotifyIconData;
TDUMMYUNIONNAME= record
case integer of
0utimeout:uint);
1uversion:uint);
end;

TNewNotifyIconData = record
cbsize:dword;
Wnd:HWND;
uID:UINT;
uFlags:UINT;
uCallbackMessage:uint;
hIcon:HICON;
szTip:array [0..127] of char;
dwstateWORD;
dwstatemaskWORD;
szinfo:array [0..255]of char;
DUMMYUNIONNAME:TDUMMYUNIONNAME;
szInfoTitle: array [0..63] of char;
dwInfoFlagsWORD;
end;

type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }

IconData:TNewNotifyIconData;
Procedure SysTrayIconMsgHandler(var Msg:Tmessage);Message Tray_CALLBACK;
Procedure AddSysTrayIcon;
Procedure ShowBaloonTip;
Procedure DeleteSysTrayIcon;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
uses shellAPI;

Procedure TForm1.SysTrayIconMsgHandler(var Msg:Tmessage);
begin
case msg.LParam of
WM_MOUSEMOVE:;
WM_LBUTTONDOWN:;
WM_LBUTTONUP:;
WM_LBUTTONDBLCLK:;
WM_RBUTTONDOWN:;
WM_RBUTTONUP:;
WM_RBUTTONDBLCLK:;
NIN_BALLOONSHOW:
ShowMessage('NIN_BALOONSHOW');
NIN_BALLOONHIDE:
ShowMessage('NIN_BALOONHIDE');
NIN_BALLOONTIMEOUT:
ShowMessage('NIN_BALOONTIMEOUT');
NIN_BALLOONUSERCLICK:
ShowMessage('NIN_BALOONUSERCLICK');
end;
end;

Procedure Tform1.AddSysTrayIcon;
begin
IconData.cbsize:= Sizeof(IconData);
IconData.Wnd:= AllocateHWnd(SysTrayIconMsgHandler);
IconData.uID:= 0;
IconData.uFlags:= NIF_ICON or NIF_MESSAGE or NIF_TIP;
IconData.uCallbackMessage:= TRAY_CALLBACK;
IconData.hIcon:= Application.Icon.Handle;
IconData.szTip:= 'test tray';

if not Shell_NotifyIcon(NIM_ADD,@IconData) then
ShowMessage('add fail');
end;

procedure TForm1.ShowBaloonTip;
var
TipInfo,TipTitle:string;
begin
IconData.cbsize:= SIZEOF(IconData);
IconData.uFlags:=NIF_INFO;
TipInfo:=' this is a test for info ';
StrPLCopy(IconData.szinfo,TipInfo,SIZEOF(IconData. szinfo)+1);
IconData.DUMMYUNIONNAME.utimeout:=3000;
TipTitle:=' baloon Title';
StrPLCopy(IconData.szInfoTitle,TipTitle,SIZEOF(Ico nData.szInfoTitle)+1);
IconData.dwInfoFlags:=NIIF_INFO;
Shell_NotifyIcon(NIM_MODIFY,@icondata);
IconData.DUMMYUNIONNAME.uversion:=NOTIFYICON_VERSI ON;
if not Shell_NotifyIcon(NIM_SETVERSION,@Icondata) then
ShowMessage('setversion fail');
end;

procedure TForm1.DeleteSysTrayIcon;
begin
DeallocateHWnd(IconData.Wnd);
if not Shell_NotifyIcon(NIM_DELETE,@Icondata) then
ShowMessage('Delete fail');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
AddSysTrayIcon;
ShowBaloonTip;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
DeleteSysTrayIcon;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowBaloonTip;
end;

end.
Reply With Quote
  #2  
Old 05-09-2005, 03:08 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,333
Default RE: about balloon

Hi ...

I tested your code and it works ... It will popup the balloon as you requested ...

MvG
Peter

Objective reality is a delirium caused by lack of alcohol in blood.
24 hous in a day, 24 beers in a case. Coincidence ???
There are 10 kinds of people: Those who understand binary and those who don't
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 09:20 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.