Mytherin / Tibialyzer

Tibialyzer is an extension made for the MMORPG Tibia. It automatically scans the server log and messages from the Tibia client by reading its memory, and gathers various statistics, such as loot found from creatures, damage dealt by party members and experience gained every hour.
Other
182 stars 60 forks source link

Make notifications draggable #201

Closed dnlopes closed 2 years ago

dnlopes commented 7 years ago

Hi, I think it would be nice if notification forms could be draggable.

I have never worked with C#, but I've been digging around your code and was able to almost recreate this behavior.

Just add this code in NotificationForm.cs (similar to MainForm):

    public const int WM_NCLBUTTONDOWN = 0xA1;

    public const int HT_CAPTION = 0x2;

    [DllImportAttribute("user32.dll")]

    public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

    [DllImportAttribute("user32.dll")]

    public static extern bool ReleaseCapture();

    public void draggable_MouseDown(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            ReleaseCapture();
            SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
        }
    }

And then, in the NotificationInitialize() method, bind the method to the event:

this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.draggable_MouseDown);

The only thing missing is the autosave of the new location, which probably will be harder to implement.

Thanks

dnlopes commented 7 years ago

I noticed that my solution breaks the 'click' and 'double click' functionality to close the notification form. Either way, I hope you find a way to implement this feature, it would be awsome.