|
Great project
Here are some changes that I made:
user is able to set the position of the Notifier
Able to set the transparency
Able to set the display time.
|
|
|
|
|
hi I am looking for the message fade out functionality. If you could publish your source that would be great.
thanks
|
|
|
|
|
Here is my code:
// C# TaskbarNotifier Class v1.0
// by John O'Byrne - 02 december 2002
// 01 april 2003 : Small fix in the OnMouseUp handler
// 11 january 2003 : Patrick Vanden Driessche <pvdd@devbrains.be> added a few enhancements
// Small Enhancements/Bugfix
// Small bugfix: When Content text measures larger than the corresponding ContentRectangle
// the focus rectangle was not correctly drawn. This has been solved.
// Added KeepVisibleOnMouseOver
// Added ReShowOnMouseOver
// Added If the Title or Content are too long to fit in the corresponding Rectangles,
// the text is truncateed and the ellipses are appended (StringTrimming).
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace CustomUIControls
{
/// <summary>
/// TaskbarNotifier allows to display MSN style/Skinned instant messaging popups
/// </summary>
public class TaskbarNotifier : System.Windows.Forms.Form
{
#region TaskbarNotifier Protected Members
protected Bitmap BackgroundBitmap = null;
protected Bitmap CloseBitmap = null;
protected Point CloseBitmapLocation;
protected Size CloseBitmapSize;
protected Rectangle RealTitleRectangle;
protected Rectangle RealContentRectangle;
protected Rectangle WorkAreaRectangle;
protected Timer timer = new Timer();
protected TaskbarStates taskbarState = TaskbarStates.hidden;
protected string titleText;
protected string contentText;
protected Color normalTitleColor = Color.FromArgb(0,0,255);
protected Color hoverTitleColor = Color.FromArgb(0,0,192);
protected Color normalContentColor = Color.FromArgb(0,0,0);
//protected Color hoverContentColor = Color.FromArgb(0,0,0x66);
//protected Color hoverContentColor = Color.FromArgb(0,0,255);
protected Color hoverContentColor = Color.FromArgb(0,0,192);
protected Font normalTitleFont = new Font("Arial",11,FontStyle.Regular,GraphicsUnit.Pixel);
protected Font hoverTitleFont = new Font("Arial",11,FontStyle.Regular|FontStyle.Underline,GraphicsUnit.Pixel);
protected Font normalContentFont = new Font("Arial",11,FontStyle.Bold,GraphicsUnit.Pixel);
protected Font hoverContentFont = new Font("Arial",11,FontStyle.Bold|FontStyle.Underline,GraphicsUnit.Pixel);
protected int nShowEvents;
protected int nHideEvents;
protected int nVisibleEvents;
protected int nIncrementShow;
protected int nIncrementHide;
protected bool bIsMouseOverPopup = false;
protected bool bIsMouseOverClose = false;
protected bool bIsMouseOverContent = false;
protected bool bIsMouseOverTitle = false;
protected bool bIsMouseDown = false;
protected bool bKeepVisibleOnMouseOver = true; // Added Rev 002
protected bool bReShowOnMouseOver = false; // Added Rev 002
#endregion
#region TaskbarNotifier Public Members
public Rectangle TitleRectangle;
public Rectangle ContentRectangle;
public bool TitleClickable = true;
public bool ContentClickable = true;
public bool CloseClickable = true;
public bool EnableSelectionRectangle = true;
public event EventHandler CloseClick = null;
public event EventHandler TitleClick = null;
public event EventHandler ContentClick = null;
public event EventHandler Disappearing = null;
#endregion
#region TaskbarNotifier Enums
/// <summary>
/// List of the different popup animation status
/// </summary>
public enum TaskbarStates
{
hidden = 0,
appearing = 1,
visible = 2,
disappearing = 3
}
#endregion
#region TaskbarNotifier Constructor
/// <summary>
/// The Constructor for TaskbarNotifier
/// </summary>
public TaskbarNotifier()
{
// Window Style
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Minimized;
base.Show();
base.Hide();
WindowState = FormWindowState.Normal;
ShowInTaskbar = false;
TopMost = true;
MaximizeBox = false;
MinimizeBox = false;
ControlBox = false;
timer.Enabled = true;
timer.Tick += new EventHandler(OnTimer);
}
#endregion
#region TaskbarNotifier Properties
/// <summary>
/// Get the current TaskbarState (hidden, showing, visible, hiding)
/// </summary>
public TaskbarStates TaskbarState
{
get
{
return taskbarState;
}
}
/// <summary>
/// Get/Set the popup Title Text
/// </summary>
public string TitleText
{
get
{
return titleText;
}
set
{
titleText=value;
Refresh();
}
}
/// <summary>
/// Get/Set the popup Content Text
/// </summary>
public string ContentText
{
get
{
return contentText;
}
set
{
contentText=value;
Refresh();
}
}
/// <summary>
/// Get/Set the Normal Title Color
/// </summary>
public Color NormalTitleColor
{
get
{
return normalTitleColor;
}
set
{
normalTitleColor = value;
Refresh();
}
}
/// <summary>
/// Get/Set the Hover Title Color
/// </summary>
public Color HoverTitleColor
{
get
{
return hoverTitleColor;
}
set
{
hoverTitleColor = value;
Refresh();
}
}
/// <summary>
/// Get/Set the Normal Content Color
/// </summary>
public Color NormalContentColor
{
get
{
return normalContentColor;
}
set
{
normalContentColor = value;
Refresh();
}
}
/// <summary>
/// Get/Set the Hover Content Color
/// </summary>
public Color HoverContentColor
{
get
{
return hoverContentColor;
}
set
{
hoverContentColor = value;
Refresh();
}
}
/// <summary>
/// Get/Set the Normal Title Font
/// </summary>
public Font NormalTitleFont
{
get
{
return normalTitleFont;
}
set
{
normalTitleFont = value;
Refresh();
}
}
/// <summary>
/// Get/Set the Hover Title Font
/// </summary>
public Font HoverTitleFont
{
get
{
return hoverTitleFont;
}
set
{
hoverTitleFont = value;
Refresh();
}
}
/// <summary>
/// Get/Set the Normal Content Font
/// </summary>
public Font NormalContentFont
{
get
{
return normalContentFont;
}
set
{
normalContentFont = value;
Refresh();
}
}
/// <summary>
/// Get/Set the Hover Content Font
/// </summary>
public Font HoverContentFont
{
get
{
return hoverContentFont;
}
set
{
hoverContentFont = value;
Refresh();
}
}
/// <summary>
/// Indicates if the popup should remain visible when the mouse pointer is over it.
/// Added Rev 002
/// </summary>
public bool KeepVisibleOnMousOver
{
get
{
return bKeepVisibleOnMouseOver;
}
set
{
bKeepVisibleOnMouseOver=value;
}
}
/// <summary>
/// Indicates if the popup should appear again when mouse moves over it while it's disappearing.
/// Added Rev 002
/// </summary>
public bool ReShowOnMouseOver
{
get
{
return bReShowOnMouseOver;
}
set
{
bReShowOnMouseOver=value;
}
}
#endregion
#region TaskbarNotifier Public Methods
[DllImport("user32.dll")]
private static extern Boolean ShowWindow(IntPtr hWnd,Int32 nCmdShow);
/// <summary>
/// Displays the popup for a certain amount of time
/// </summary>
/// <param name="strTitle">The string which will be shown as the title of the popup</param>
/// <param name="strContent">The string which will be shown as the content of the popup</param>
/// <param name="nTimeToShow">Duration of the showing animation (in milliseconds)</param>
/// <param name="nTimeToStay">Duration of the visible state before collapsing (in milliseconds)</param>
/// <param name="nTimeToHide">Duration of the hiding animation (in milliseconds)</param>
/// <returns>Nothing</returns>
public void Show(string strTitle, string strContent, int nTimeToShow, int nTimeToStay, int nTimeToHide)
{
Show(strTitle,strContent,nTimeToShow,nTimeToStay,nTimeToHide,0,2);
}
/// <summary>
/// Displays the popup for a certain amount of time
/// </summary>
/// <param name="strTitle">The string which will be shown as the title of the popup</param>
/// <param name="strContent">The string which will be shown as the content of the popup</param>
/// <param name="nTimeToShow">Duration of the showing animation (in milliseconds)</param>
/// <param name="nTimeToStay">Duration of the visible state before collapsing (in milliseconds)</param>
/// <param name="nTimeToHide">Duration of the hiding animation (in milliseconds)</param>
/// <param name="iContentInflateWidth"/>Number of pixels by which to inflate the Content rectangle's width.</param>
/// <param name="iContentInflateHeight"/>Number of pixels by which to inflate the Content rectangle's height.</param>
/// <returns>Nothing</returns>
public void Show(string strTitle, string strContent, int nTimeToShow, int nTimeToStay, int nTimeToHide, int iContentInflateWidth, int iContentInflateHeight)
{
WorkAreaRectangle = Screen.GetWorkingArea(WorkAreaRectangle);
titleText = strTitle;
contentText = strContent;
nVisibleEvents = nTimeToStay;
CalculateMouseRectangles(iContentInflateWidth, iContentInflateHeight);
// We calculate the pixel increment and the timer value for the showing animation
int nEvents;
if (nTimeToShow > 10)
{
nEvents = Math.Min((nTimeToShow / 10), BackgroundBitmap.Height);
nShowEvents = nTimeToShow / nEvents;
nIncrementShow = BackgroundBitmap.Height / nEvents;
}
else
{
nShowEvents = 10;
nIncrementShow = BackgroundBitmap.Height;
}
// We calculate the pixel increment and the timer value for the hiding animation
if( nTimeToHide > 10)
{
nEvents = Math.Min((nTimeToHide / 10), BackgroundBitmap.Height);
nHideEvents = nTimeToHide / nEvents;
nIncrementHide = BackgroundBitmap.Height / nEvents;
}
else
{
nHideEvents = 10;
nIncrementHide = BackgroundBitmap.Height;
}
switch (taskbarState)
{
case TaskbarStates.hidden:
taskbarState = TaskbarStates.appearing;
SetBounds(WorkAreaRectangle.Right-BackgroundBitmap.Width-17, WorkAreaRectangle.Bottom-1, BackgroundBitmap.Width, 0);
timer.Interval = nShowEvents;
timer.Start();
// We Show the popup without stealing focus
ShowWindow(this.Handle, 4);
break;
case TaskbarStates.appearing:
Refresh();
break;
case TaskbarStates.visible:
timer.Stop();
timer.Interval = nVisibleEvents;
timer.Start();
Refresh();
break;
case TaskbarStates.disappearing:
timer.Stop();
taskbarState = TaskbarStates.visible;
SetBounds(WorkAreaRectangle.Right-BackgroundBitmap.Width-17, WorkAreaRectangle.Bottom-BackgroundBitmap.Height-1, BackgroundBitmap.Width, BackgroundBitmap.Height);
timer.Interval = nVisibleEvents;
timer.Start();
Refresh();
break;
}
MMM.Update.WAVSounds.Play();
}
/// <summary>
/// Hides the popup
/// </summary>
/// <returns>Nothing</returns>
public new void Hide()
{
if (taskbarState != TaskbarStates.hidden)
{
timer.Stop();
taskbarState = TaskbarStates.hidden;
base.Hide();
base.Opacity = 1.0;
}
}
/// <summary>
/// Sets the background bitmap and its transparency color
/// </summary>
/// <param name="strFilename">Path of the Background Bitmap on the disk</param>
/// <param name="transparencyColor">Color of the Bitmap which won't be visible</param>
/// <returns>Nothing</returns>
public void SetBackgroundBitmap(string strFilename, Color transparencyColor)
{
BackgroundBitmap = new Bitmap(strFilename);
Width = BackgroundBitmap.Width;
Height = BackgroundBitmap.Height;
Region = BitmapToRegion(BackgroundBitmap, transparencyColor);
}
/// <summary>
/// Sets the background bitmap and its transparency color
/// </summary>
/// <param name="image">Image/Bitmap object which represents the Background Bitmap</param>
/// <param name="transparencyColor">Color of the Bitmap which won't be visible</param>
/// <returns>Nothing</returns>
public void SetBackgroundBitmap(Image image, Color transparencyColor)
{
BackgroundBitmap = new Bitmap(image);
Width = BackgroundBitmap.Width;
Height = BackgroundBitmap.Height;
Region = BitmapToRegion(BackgroundBitmap, transparencyColor);
}
/// <summary>
/// Sets the 3-State Close Button bitmap, its transparency color and its coordinates
/// </summary>
/// <param name="strFilename">Path of the 3-state Close button Bitmap on the disk (width must a multiple of 3)</param>
/// <param name="transparencyColor">Color of the Bitmap which won't be visible</param>
/// <param name="position">Location of the close button on the popup</param>
/// <returns>Nothing</returns>
public void SetCloseBitmap(string strFilename, Color transparencyColor, Point position)
{
CloseBitmap = new Bitmap(strFilename);
CloseBitmap.MakeTransparent(transparencyColor);
//CloseBitmapSize = new Size(CloseBitmap.Width, CloseBitmap.Height);
CloseBitmapSize = new Size(CloseBitmap.Width/3, CloseBitmap.Height);
CloseBitmapLocation = position;
}
/// <summary>
/// Sets the 3-State Close Button bitmap, its transparency color and its coordinates
/// </summary>
/// <param name="image">Image/Bitmap object which represents the 3-state Close button Bitmap (width must be a multiple of 3)</param>
/// <param name="transparencyColor">Color of the Bitmap which won't be visible</param>
/// /// <param name="position">Location of the close button on the popup</param>
/// <returns>Nothing</returns>
public void SetCloseBitmap(Image image, Color transparencyColor, Point position)
{
CloseBitmap = new Bitmap(image);
CloseBitmap.MakeTransparent(transparencyColor);
//CloseBitmapSize = new Size(CloseBitmap.Width, CloseBitmap.Height);
CloseBitmapSize = new Size(CloseBitmap.Width/3, CloseBitmap.Height);
CloseBitmapLocation = position;
}
#endregion
#region TaskbarNotifier Protected Methods
protected void DrawCloseButton(Graphics grfx)
{
if (CloseBitmap != null)
{
Rectangle rectDest = new Rectangle(CloseBitmapLocation, CloseBitmapSize);
Rectangle rectSrc;
if (bIsMouseOverClose)
{
if (bIsMouseDown)
rectSrc = new Rectangle(new Point(CloseBitmapSize.Width*2, 0), CloseBitmapSize);
else
rectSrc = new Rectangle(new Point(CloseBitmapSize.Width, 0), CloseBitmapSize);
}
else
rectSrc = new Rectangle(new Point(0, 0), CloseBitmapSize);
grfx.DrawImage(CloseBitmap, rectDest, rectSrc, GraphicsUnit.Pixel);
}
}
protected void DrawText(Graphics grfx)
{
if (titleText != null && titleText.Length != 0)
{
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Near;
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.NoWrap;
sf.Trimming = StringTrimming.EllipsisCharacter; // Added Rev 002
if (bIsMouseOverTitle)
grfx.DrawString(titleText, hoverTitleFont, new SolidBrush(hoverTitleColor), TitleRectangle, sf);
else
grfx.DrawString(titleText, normalTitleFont, new SolidBrush(normalTitleColor), TitleRectangle, sf);
}
if (contentText != null && contentText.Length != 0)
{
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;
sf.Trimming = StringTrimming.Word; // Added Rev 002
if (bIsMouseOverContent)
{
grfx.DrawString(contentText, hoverContentFont, new SolidBrush(hoverContentColor), ContentRectangle, sf);
if (EnableSelectionRectangle)
ControlPaint.DrawBorder3D(grfx, RealContentRectangle, Border3DStyle.Etched, Border3DSide.Top | Border3DSide.Bottom | Border3DSide.Left | Border3DSide.Right);
}
else
grfx.DrawString(contentText, normalContentFont, new SolidBrush(normalContentColor), ContentRectangle, sf);
}
}
protected void CalculateMouseRectangles(int iContentInflateWidth, int iContentInflateHeight)
{
Graphics grfx = CreateGraphics();
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;
SizeF sizefTitle = grfx.MeasureString(titleText, hoverTitleFont, TitleRectangle.Width, sf);
SizeF sizefContent = grfx.MeasureString(contentText, hoverContentFont, ContentRectangle.Width, sf);
grfx.Dispose();
// Added Rev 002
//We should check if the title size really fits inside the pre-defined title rectangle
if (sizefTitle.Height > TitleRectangle.Height)
{
RealTitleRectangle = new Rectangle(TitleRectangle.Left, TitleRectangle.Top, TitleRectangle.Width , TitleRectangle.Height );
}
else
{
RealTitleRectangle = new Rectangle(TitleRectangle.Left, TitleRectangle.Top, (int)sizefTitle.Width, (int)sizefTitle.Height);
}
RealTitleRectangle.Inflate(iContentInflateWidth,iContentInflateHeight);
// Added Rev 002
//We should check if the Content size really fits inside the pre-defined Content rectangle
if (sizefContent.Height > ContentRectangle.Height)
{
RealContentRectangle = new Rectangle((ContentRectangle.Width-(int)sizefContent.Width)/2+ContentRectangle.Left, ContentRectangle.Top, (int)sizefContent.Width, ContentRectangle.Height );
}
else
{
RealContentRectangle = new Rectangle((ContentRectangle.Width-(int)sizefContent.Width)/2+ContentRectangle.Left, (ContentRectangle.Height-(int)sizefContent.Height)/2+ContentRectangle.Top, (int)sizefContent.Width, (int)sizefContent.Height);
}
RealContentRectangle.Inflate(iContentInflateWidth,iContentInflateHeight);
}
protected Region BitmapToRegion(Bitmap bitmap, Color transparencyColor)
{
if (bitmap == null)
throw new ArgumentNullException("Bitmap", "Bitmap cannot be null!");
int height = bitmap.Height;
int width = bitmap.Width;
GraphicsPath path = new GraphicsPath();
for (int j=0; j<height; j++ )
for (int i=0; i<width; i++)
{
if (bitmap.GetPixel(i, j) == transparencyColor)
continue;
int x0 = i;
while ((i < width) && (bitmap.GetPixel(i, j) != transparencyColor))
i++;
path.AddRectangle(new Rectangle(x0, j, i-x0, 1));
}
Region region = new Region(path);
path.Dispose();
return region;
}
#endregion
#region TaskbarNotifier Events Overrides
protected void OnTimer(Object obj, EventArgs ea)
{
switch (taskbarState)
{
case TaskbarStates.appearing:
if (Height < BackgroundBitmap.Height)
{
SetBounds(Left, Top-nIncrementShow ,Width, Height + nIncrementShow);
}
else
{
timer.Stop();
Height = BackgroundBitmap.Height;
timer.Interval = nVisibleEvents;
taskbarState = TaskbarStates.visible;
timer.Start();
}
break;
case TaskbarStates.visible:
timer.Stop();
timer.Interval = nHideEvents;
// Added Rev 002
if ((bKeepVisibleOnMouseOver && !bIsMouseOverPopup ) || (!bKeepVisibleOnMouseOver))
{
taskbarState = TaskbarStates.disappearing;
}
//taskbarState = TaskbarStates.disappearing; // Rev 002
timer.Start();
break;
case TaskbarStates.disappearing:
// Added Rev 002
if (bReShowOnMouseOver && bIsMouseOverPopup)
{
taskbarState = TaskbarStates.appearing;
}
else
{
// if (Top < WorkAreaRectangle.Bottom)
// SetBounds(Left, Top + nIncrementHide, Width, Height - nIncrementHide);
// else
if(base.Opacity >0.0)
{
base.Opacity -= .02;
}
else
{
Hide();
Disappearing(this, new EventArgs());
}
}
break;
}
}
protected override void OnMouseEnter(EventArgs ea)
{
base.OnMouseEnter(ea);
bIsMouseOverPopup = true;
Refresh();
}
protected override void OnMouseLeave(EventArgs ea)
{
base.OnMouseLeave(ea);
bIsMouseOverPopup = false;
bIsMouseOverClose = false;
bIsMouseOverTitle = false;
bIsMouseOverContent = false;
Refresh();
}
protected override void OnMouseMove(MouseEventArgs mea)
{
base.OnMouseMove(mea);
bool bContentModified = false;
if ( (mea.X > CloseBitmapLocation.X) && (mea.X < CloseBitmapLocation.X + CloseBitmapSize.Width) && (mea.Y > CloseBitmapLocation.Y) && (mea.Y < CloseBitmapLocation.Y + CloseBitmapSize.Height) && CloseClickable )
{
if (!bIsMouseOverClose)
{
bIsMouseOverClose = true;
bIsMouseOverTitle = false;
bIsMouseOverContent = false;
Cursor = Cursors.Hand;
bContentModified = true;
}
}
else if (RealContentRectangle.Contains(new Point(mea.X, mea.Y)) && ContentClickable)
{
if (!bIsMouseOverContent)
{
bIsMouseOverClose = false;
bIsMouseOverTitle = false;
bIsMouseOverContent = true;
Cursor = Cursors.Hand;
bContentModified = true;
}
}
else if (RealTitleRectangle.Contains(new Point(mea.X, mea.Y)) && TitleClickable)
{
if (!bIsMouseOverTitle)
{
bIsMouseOverClose = false;
bIsMouseOverTitle = true;
bIsMouseOverContent = false;
Cursor = Cursors.Hand;
bContentModified = true;
}
}
else
{
if (bIsMouseOverClose || bIsMouseOverTitle || bIsMouseOverContent)
bContentModified = true;
bIsMouseOverClose = false;
bIsMouseOverTitle = false;
bIsMouseOverContent = false;
Cursor = Cursors.Default;
}
if (bContentModified)
Refresh();
}
protected override void OnMouseDown(MouseEventArgs mea)
{
base.OnMouseDown(mea);
bIsMouseDown = true;
if (bIsMouseOverClose)
Refresh();
}
protected override void OnMouseUp(MouseEventArgs mea)
{
base.OnMouseUp(mea);
bIsMouseDown = false;
if (bIsMouseOverClose)
{
while(base.Opacity >0.0)
{
base.Opacity -= .005;
}
Hide();
if (CloseClick != null)
CloseClick(this, new EventArgs());
}
else if (bIsMouseOverTitle)
{
if (TitleClick != null)
TitleClick(this, new EventArgs());
}
else if (bIsMouseOverContent)
{
if (ContentClick != null)
ContentClick(this, new EventArgs());
}
}
protected override void OnPaintBackground(PaintEventArgs pea)
{
Graphics grfx = pea.Graphics;
grfx.PageUnit = GraphicsUnit.Pixel;
Graphics offScreenGraphics;
Bitmap offscreenBitmap;
offscreenBitmap = new Bitmap(BackgroundBitmap.Width, BackgroundBitmap.Height);
offScreenGraphics = Graphics.FromImage(offscreenBitmap);
if (BackgroundBitmap != null)
{
offScreenGraphics.DrawImage(BackgroundBitmap, 0, 0, BackgroundBitmap.Width, BackgroundBitmap.Height);
}
DrawCloseButton(offScreenGraphics);
DrawText(offScreenGraphics);
grfx.DrawImage(offscreenBitmap, 0, 0);
}
#endregion
}
}
|
|
|
|
|
Nice code, however something seems to be missing with this line :
MMM.Update.WAVSounds.Play();
Could you please post the code corresponding to the MMM object ?
Thanks by advance,
Jeff
|
|
|
|
|
Hi Jeff, its been more than a year since I orchestrated that notifier.. I say orchestrated because even though I modified the code I didn't write the original base. Regardless, that reference was an attempt to make the notifier play a sound when the notifier showed a notificiation.
Its been such a while now I can't remember if I ever got it to work properly.. so my suggestion, remove it.
James
|
|
|
|
|
Hi John,
Im trying to loop through a list of names and for each one I want to show a popup baloon.
I am gettikng only one notification for the last person.
Can you help me? Thanks
noren
|
|
|
|
|
Hi John,
I get this error:
An unhandled exception of type 'System.NullReferenceException' occurred in Reminder.exe
Additional information: Object reference not set to an instance of an object.
for this line:
nEvents = CType(Math.Min((nTimeToShow / 10), Me._bmpBackground.Height), Integer)
how can I fix this? thanks!
|
|
|
|
|
This was my FIRST error in working with this cool class...Fortunately, I figured it out. My error occured when I was attempting to create an instance of the class within my button's OnClick event:
Dim tbnNotify as new TaskBarNotifier
This doesn't work, however. Add this after the Windows Form Designer Generated Code region
Private WithEvents taskbarNotifier1 As TaskBarNotifier
Then, I checked out the Public Sub New() INSIDE the collapsed region. After adding that to my project, it worked. Well, aside from the graphics error.
The graphics error was a bit squirrly to me, not being overly familiar with using graphics in apps (I usually work with ASP.NET). I found that by viewing the property sheet for the bitmaps I plan on including in the project (right clicked in the Solution Explorer), changing the BUILD ACTION to COMPILED RESOURCE cleared up my issue, and the popup worked like a charm.
modified 3-Sep-19 21:02pm.
|
|
|
|
|
hi, i use standard visual basic 6.0 (mainly because i cant afford an upgrade) is there any chance of a vb6 version of this control, or does anyone know how to use these downloads in vb6 that im overlooking?
cheers
|
|
|
|
|
Alter image property in property panel to content for Embedded Resource
is that solution ok
Good lucky
I'm sorry my english is more lass
|
|
|
|
|
Hi,
I am having this problem which when I try to run the application it says, "skin.bmp" not found. Can you please tell me where I should make changes to see this example application running.
Thanks,
Andy
|
|
|
|
|
Hi,
I obtained to decide the problem selecting the image skin.bmp and modifying the property build action of content for embedded resource functioned in the hour.
Other doubts call me
Ricardo B.
|
|
|
|
|
Thanks a lot. I got it working.
Andy.
|
|
|
|
|
I'm at work right now, so I can't open the code and look how you handle clicking the close button, but how hard would it be to implement more than one clickable area? I'd like about 5 options, each of which would do different things. If this is incredibly obvious in the code, sorry about that, but I figured I'd ask now so I can mess with it sooner. Thanks!
|
|
|
|
|
Clickable areas are done using pixel coordinates of the clicked zone. As a result it should be very easy to add more clickable zones.
Sincerely,
John
|
|
|
|
|
Hi!
The TaskbarNotifier is very good,I have used it in my projects successfully,
and I find one problem,it does not work in my call-back method.
exp:
private void ReceiveCallBack(IAsyncResult ar)
{......
//the properties have been set
taskbarNotifier.Show("haha!","content",100,2000,100);
}
}
how to do with it?
|
|
|
|
|
This is a great app. Saved me many nights of hard work.
The problem with threads and call backs is that the TaskbarNotifier uses the windows form timer class. If you changed it to use system.threading.timer class everything works fine. The callbacks etc.
In the code change the stop and start to use change() method in system.threading.timer class.
I hope this helps you guys out or should i say point you in the right direction for this problem.
Once again great project
|
|
|
|
|
Can you post the updated code in VB.NET for it ?
Thanks in advance and regards
Navin
|
|
|
|
|
I noticed you mentioned there is a win32 API call that makes it not steal focus..If I wanted to use this call instead of managed code (in my own version), how would I do this (I'm horrible with API interaction...not even gonna try)..My second question has to do with showing the form that called the taskbar notifier. I have an MP3 player that uses taskbar notifiers to show when a new song plays, and I'd like to be able to show the main form when the content is clicked...this.show() won't work obviously, and I can't think of any other method. Thanks in advance.
|
|
|
|
|
Hi,
In my class, I already make use of the Win32 API for showing the popup and not stealing the focus
for your second question, just catch the Clicked event of the popup in your main window, and when the event is fired, just call the show method of your main window
|
|
|
|
|
Oh, okay...I just noticed that it only steals focus if the Mp3 player is the active app, not if anything else is.
|
|
|
|
|
This is great, and was exactly what I was looking for, thank you. One question though is that I find the notifier window is stealing focus on occasion. The program I am using it on generally has all forms closed or hidden, and most user interaction is done through a notifyicon. I find that if I am typing in another program, such as Word or Outlook, and a notifier window comes up, it steals the focus. This hasn't happened every time, but has been happening quite a bit (the program displays a notifier window roughly once per hour). Any ideas?
Robert
|
|
|
|
|
John, Excellent Example!!! It helps a lot!!!
|
|
|
|
|
Hi there - LOVE IT! Only thing that bums me out is that (at least from what I can tell), you can not have more than one event causing the notifier to fire at a time. For instance, if you fire a second one, while the first is still displaying, it merely changes the information in the first event.
What be be super cool would be to extend this to allow N events to take place (up to the height of the screen or something) such that if event two comes in as event 1 is still displaying, it would raise one on top of it.
Of course, I see why it is the way it is, as you only have a single event defined and each time that event is raised, you are merely changing the details of that event, but this could be a super cool version 2!
Thanks!
Derek
|
|
|
|
|
I made the stacking work ok. I created a static class that tracks all instances of open toast windows. The TaskbarNotifier registers each instance its creating and gets the window position back. The controller increments the positions required based on the size of the currently instantiated toast windows. When the Toast is hidden the controller disposes of that instance and decrements the positions. This will stack up to max window size and then start a new column to the left and on and on...
|
|
|
|
|