Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

MSN Floating Personal Message

0.00/5 (No votes)
31 Aug 2005 1  
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

[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

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here