WinForms: C# i Flash

0

Witam, mam następujący problem. Mam Formę, w której przesłaniam metodę WndProc, obsługuję zdarzenie WM_NCHITTEST abym mógł w nie defaultowy sposób zmieniać rozmiar okna, dziedziczę po AxShockwaveFlash kontrolkę Flashową. Docelowe działanie jest takie, aby po najechaniu na obszar odległy o 16 pixeli od którejkolwiek krawędzi, pojawi się odpowiedni systemowy kursor i było możliwe rozciągnięcie Formy. Zaznaczam, że Flash zajmuje cały obszar Formy. Próbowałem wysyłać z odziedziczonej klasy kontrolki komunikaty, lecz kursor i tak się nie pojawia i nie ma możliwości zmiany rozmiaru.

Byłbym wdzięczny za wskazówki i odpowiedź czy to w ogóle wykonalne.

Pozdrawiam.

0

masz błąd w 35 linijce.

1

Kompilator Azarien jest zniesmaczony Twoim błędem w 35 linijce. Proszę natychmiast poprawić i przeprosić.

0

Form1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.None;
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.ResizeRedraw, true);

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private const int cGrip = 16;      // Grip size
        private const int cCaption = 25;   // Caption bar height;



        protected override void WndProc(ref Message m)
        {
            const int wmNcHitTest = 0x84;
            const int htLeft = 10;
            const int htRight = 11;
            const int htTop = 12;
            const int htTopLeft = 13;
            const int htTopRight = 14;
            const int htBottom = 15;
            const int htBottomLeft = 16;
            const int htBottomRight = 17;
            
            if (m.Msg == wmNcHitTest)
            {
                int x = (int)(m.LParam.ToInt64() & 0xFFFF);
                int y = (int)((m.LParam.ToInt64() & 0xFFFF0000) >> 16);
                Point pt = PointToClient(new Point(x, y));
                Size clientSize = ClientSize;
                ///allow resize on the lower right corner
                if (pt.X >= clientSize.Width - 16 && pt.Y >= clientSize.Height - 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(IsMirrored ? htBottomLeft : htBottomRight);
                    return;
                }
                ///allow resize on the lower left corner
                if (pt.X <= 16 && pt.Y >= clientSize.Height - 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(IsMirrored ? htBottomRight : htBottomLeft);
                    return;
                }
                ///allow resize on the upper right corner
                if (pt.X <= 16 && pt.Y <= 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(IsMirrored ? htTopRight : htTopLeft);
                    return;
                }
                ///allow resize on the upper left corner
                if (pt.X >= clientSize.Width - 16 && pt.Y <= 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(IsMirrored ? htTopLeft : htTopRight);
                    return;
                }
                ///allow resize on the top border
                if (pt.Y <= 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(htTop);
                    return;
                }
                ///allow resize on the bottom border
                if (pt.Y >= clientSize.Height - 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(htBottom);
                    return;
                }
                ///allow resize on the left border
                if (pt.X <= 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(htLeft);
                    return;
                }
                ///allow resize on the right border
                if (pt.X >= clientSize.Width - 16 && clientSize.Height >= 16)
                {
                    m.Result = (IntPtr)(htRight);
                    return;
                }
            }
            
            base.WndProc(ref m);
        }       
    }
}
 

MyFlash

using System;
using System.Runtime.InteropServices;
using AxShockwaveFlashObjects;

namespace WindowsFormsApplication1
{
    public class MyFlash : AxShockwaveFlash
    {
        [DllImport("user32.dll")]
        static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

        Form1 form;
        public MyFlash(Form1 form)
        {
            this.form = form;            
        }
        private int MakeLParam(int loWord, int hiWord)
        {
            return (int)((hiWord << 16) | (loWord & 0xffff));
        }
        protected override void WndProc(ref System.Windows.Forms.Message m)
        {
            const int wmNcHitTest = 0x84;

            if (m.Msg == wmNcHitTest)
            {
                PostMessage(form.Handle, (uint)m.Msg, m.WParam.ToInt32(), m.LParam.ToInt32());
                return;
            }
            base.WndProc(ref m);
        }
    }

}
 

1 użytkowników online, w tym zalogowanych: 0, gości: 1