Click here to Skip to main content
15,881,859 members
Articles / Programming Languages / C#
Article

MSN Floating Personal Message

Rate me:
Please Sign up or sign in to vote.
2.90/5 (10 votes)
31 Aug 2005CPOL 87.5K   1.2K   33   12
Showing floating text message on the MSN Messenger as a personal message
Sample Image - MSNFloatingText.jpg

Introduction

This application gives the ability of writing floating text messages to the Personal Message of the MSN Messenger.

The application has speed, direction, and icon options. The user can select the speed of float as a value of milliseconds. Moreover, the user can select the direction of the movement, Left to Right or Right to Left. There are three icon options: Office, Games, and Music. When the Music icon option is selected, the text became as a textlink.

The application must be open during the making of the floating text message. When the application is minimized, it is shown as a trayicon. It will not be seen on the taskbar.

MSN Object Declarations

C#
[DllImport("user32", EntryPoint="SendMessageA")]
private static extern int SendMessage(int Hwnd, int wMsg, int wParam, int lParam);

[DllImport("user32", EntryPoint="FindWindowExA")]
private static extern int FindWindowEx(int hWnd1, int hWnd2, string lpsz1, string lpsz2);
private const short WM_COPYDATA = 74;

public struct COPYDATASTRUCT
{
  public int dwData;
  public int cbData;
  public int lpData;
}
public COPYDATASTRUCT data;

Function that Makes Interop to MSN Messenger

C#
public int VarPtr(object e)
{
  GCHandle GC = GCHandle.Alloc(e, GCHandleType.Pinned);
  int gc = GC.AddrOfPinnedObject().ToInt32();
  GC.Free();
  return gc;
}

private void SendMSNMessage(bool enable, string category, string message)
{
  string buffer = "\\0" + category + "\\0" + (enable ? "1" : "0") + 
				"\\0{0}\\0" + message + "\\0\\0\\0\\0\0";
  int handle = 0;

    data.dwData = 0x0547;
    data.lpData = VarPtr(buffer);
    data.cbData = buffer.Length * 2;

    handle = FindWindowEx(0, handle, "MsnMsgrUIManager", null);
    if (handle > 0) 
        SendMessage(handle, WM_COPYDATA, 0, VarPtr(data));
}

History

  • 31st August, 2005: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 2 Pin
egothic31-Mar-10 10:43
professionalegothic31-Mar-10 10:43 
Generalbad word filter to protect my kids. with [***********] 's Pin
ZUPERKOOL7-Feb-10 7:55
ZUPERKOOL7-Feb-10 7:55 
GeneralVarPtr Pin
Mikael Svenson26-Nov-09 21:08
Mikael Svenson26-Nov-09 21:08 
GeneralLive Messenger 2009 Pin
Alain Raza4-Mar-09 8:48
Alain Raza4-Mar-09 8:48 
GeneralMore icons Pin
Jhonmiller@qatar.net.qa6-Sep-07 8:22
Jhonmiller@qatar.net.qa6-Sep-07 8:22 
QuestionHELP Pin
young geek26-Jul-07 5:23
young geek26-Jul-07 5:23 
GeneralTranslation Pin
LegionFX11-Jun-07 1:22
LegionFX11-Jun-07 1:22 
GeneralRe: Translation Pin
LegionFX11-Jun-07 1:29
LegionFX11-Jun-07 1:29 
GeneralRe: Translation Pin
LegionFX13-Jun-07 0:20
LegionFX13-Jun-07 0:20 
GeneralGrr Pin
MatijaSakoman21-Feb-07 10:10
MatijaSakoman21-Feb-07 10:10 
GeneralTo make it run in 64 bit system Pin
treeleung28-Jun-06 14:46
treeleung28-Jun-06 14:46 
GeneralRe: To make it run in 64 bit system Pin
Zonakusu.NET3-Mar-09 8:17
Zonakusu.NET3-Mar-09 8:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.