TPopupStyle=Set of (Left_Click,Right_Click,Left_DbClick,Right_DbClick); TWhoButton=(b_Left,b_Right); TMouseEvent= procedure(Sender:TObject;x,y:Word;WhoButton:TWhoButton) of Object;
procedure Register; begin RegisterComponents(''''MyControl'''', [TNotifyIcon]); end;
procedure TNotifyIcon.ShowIt(Accept:boolean); begin if Accept=true then ShowIcon else HideIcon; end;
procedure TNotifyIcon.Paint; begin if (csDesigning in ComponentState) then begin Width:=33; Height:=33; With Canvas do begin Brush.Color:=clInfoBk; Ellipse(0,0,Self.Width,Self.Height); Font.Color:=clBlue; Brush.Style:=bsClear; FloodFill(5,5,clInfoBk,fsBorder); Brush.Color:=clInfoBk; TextOut(3,Self.Height div 2-6,''''Notify''''); end end; end;
procedure TNotifyIcon.NotifyIconClick(var msg : TMessage); var p:TPoint; begin try case msg.LParam of WM_LBUTTONDOWN: begin GetCursorPos(p); if Left_Click in FPopupStyle then begin SetForegroundWindow(ParentWindow); FPopupMenu.Popup(p.x,p.y); end; if Assigned(FOnIconMouseDown) then begin FOnIconMouseDown(Self,p.x,p.y,b_Left); end; end; WM_RBUTTONDOWN: begin GetCursorPos(p); if Right_Click in FPopupStyle then begin SetForegroundWindow(ParentWindow); FPopupMenu.Popup(p.x,p.y); end; if Assigned(FOnIconMouseDown) then begin FOnIconMouseDown(Self,p.x,p.y,b_Right); end; end; WM_LBUTTONDBLCLK: begin GetCursorPos(p); if Left_DbClick in FPopupStyle then begin SetForegroundWindow(ParentWindow); FPopupMenu.Popup(p.x,p.y); end; if Assigned(FOnIconDoubleClick) then begin FOnIconDoubleClick(Self,p.x,p.y,b_Left); end; end; WM_RBUTTONDBLCLk: begin GetCursorPos(p); if Right_Click in FPopupStyle then begin SetForegroundWindow(ParentWindow); FPopupMenu.Popup(p.x,p.y); end; if Assigned(FOnIconDoubleClick) then begin FOnIconDoubleClick(Self,p.x,p.y,b_Right); end; end; end; except end; end;
function MAKELANGID(p, s:word):Cardinal; begin result:= (((s)shl 10) or(p)); end;