Пример #1
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        BackColor         = Color.Fuchsia;
        TransparencyKey   = Color.Fuchsia;
        AllowTransparency = true;
        Point screen = new Point(0, 0);

        screen = PointToScreen(screen);
        m_offX = screen.X - Location.X;
        m_offY = screen.Y - Location.Y;
        if (!DesignMode)
        {
            Point formLoc = Location;
            formLoc.X        += m_offX;
            formLoc.Y        += m_offY;
            m_layeredWnd.Text = "AlphaForm";
            m_initialised     = true;
            updateLayeredBackground(ClientSize.Width, ClientSize.Height, formLoc, true);
            m_layeredWnd.Show();
            m_layeredWnd.Enabled      = false;
            m_customLayeredWindowProc = new Win32.Win32WndProc(LayeredWindowWndProc);
            m_layeredWindowProc       = Win32.SetWindowLong(m_layeredWnd.Handle, (uint)Win32.Message.GWL_WNDPROC, m_customLayeredWindowProc);
        }
    }
Пример #2
0
        /// <summary>
        /// Initialise the Winamp class. Called from the constructor
        /// </summary>
        private void Init()
        {
            // Let's set up debugging, if we're in debug mode!
                        #if DEBUG
            string debugDir  = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string debugFile = Path.Combine(debugDir, "winamp-cs-debug.txt");
            Debug.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugFile, true)));
            Debug.AutoFlush = true;
            Debug.WriteLine("hWnd: " + _WinampWindow);
                        #endif

            // Start with a blank "currently playing" song
            CurrentSong = new Song();
            // Update the song data
            UpdateSongData();

            // And now, let's set up our subclassing. We can only do this if we're
            // "in process", so let's bail if we're not.
            if (!_InProcess)
            {
                // TODO: This should not be a messagebox. This is just for debugging.
                System.Windows.Forms.MessageBox.Show("Not running 'in process', certain features will not work!");
                return;
            }

            // Here's our delegate
            _WinampWndProc = new Win32.Win32WndProc(WinampWndProc);
            // Make sure it doesn't get garbage collected
            GC.KeepAlive(_WinampWndProc);
            // Let's go ahead and set the new one, saving the old one
            _OldWinampWndProc = Win32.SetWindowLong(_WinampWindow, Win32.GWL_WNDPROC, _WinampWndProc);
            Debug.WriteLine("Subclassed Winamp window (old proc = " + _OldWinampWndProc + ", new proc = " + _WinampWndProc + ")");
        }
Пример #3
0
        /// <summary>
        /// Initialise the Winamp class. Called from the constructor
        /// </summary>
        private void Init()
        {
            CurrentSong = new Song();

            UpdateSongData();

            _winampWndProc = new Win32.Win32WndProc(WinampWndProc);

            // Make sure it doesn't get garbage collected
            GC.KeepAlive(_winampWndProc);

            _oldWndProc = Win32.SetWindowLong(WinampHwnd, Win32.GWL_WNDPROC, _winampWndProc);
        }
Пример #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //Set the transparency key to make the back of the form transparent
            //INTERESTING NOTE: If you use Fuchsia as the transparent colour then
            // it will be not only visually transparent but also transparent to
            // mouse clicks. If you use any other colour then you will be able to
            // see through it, but you'll still get your mouse events
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            ////this.BackColor = Color.Black;
            ////this.TransparencyKey = Color.Black;
            this.AllowTransparency = true;

            //Work out any offset to position the background form, in the event that
            //the borders are still active
            Point screen = new Point(0, 0);

            screen = this.PointToScreen(screen);
            m_offX = screen.X - this.Location.X;
            m_offY = screen.Y - this.Location.Y;

            if (!this.DesignMode)
            {
                //Disable the form so that it cannot receive focus
                //We need to do this so that the form will not get focuse
                // by any means and then be positioned above our main form
                Point formLoc = this.Location;
                formLoc.X        += m_offX;
                formLoc.Y        += m_offY;
                m_layeredWnd.Text = "AlphaForm";
                m_initialised     = true;
                updateLayeredBackground(this.ClientSize.Width, this.ClientSize.Height, formLoc, true);
                m_layeredWnd.Show();

                m_layeredWnd.Enabled = false;

                //Subclass the background window so that we can intercept its messages
                m_customLayeredWindowProc = new Win32.Win32WndProc(this.LayeredWindowWndProc);
                m_layeredWindowProc       = Win32.SetWindowLong(m_layeredWnd.Handle, (uint)Win32.Message.GWL_WNDPROC, m_customLayeredWindowProc);
            }
        }
Пример #5
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //Set the transparency key to make the back of the form transparent
            //INTERESTING NOTE: If you use Fuchsia as the transparent colour then
            // it will be not only visually transparent but also transparent to
            // mouse clicks. If you use any other colour then you will be able to
            // see through it, but you'll still get your mouse events
            this.BackColor = Color.Fuchsia;
            this.TransparencyKey = Color.Fuchsia;
            this.AllowTransparency = true;

            //Work out any offset to position the background form, in the event that
            //the borders are still active
            Point screen = new Point(0, 0);
            screen = this.PointToScreen(screen);
            m_offX = screen.X - this.Location.X;
            m_offY = screen.Y - this.Location.Y;

            if (!this.DesignMode)
            {
                //Disable the form so that it cannot receive focus
                //We need to do this so that the form will not get focuse
                // by any means and then be positioned above our main form
                Point formLoc = this.Location;
                formLoc.X += m_offX;
                formLoc.Y += m_offY;
                m_layeredWnd.Text = "AlphaForm";
                m_initialised = true;
                updateLayeredBackground(this.ClientSize.Width, this.ClientSize.Height, formLoc, true);
                m_layeredWnd.Show();

                m_layeredWnd.Enabled = false;

                //Subclass the background window so that we can intercept its messages
                m_customLayeredWindowProc = new Win32.Win32WndProc(this.LayeredWindowWndProc);
                m_layeredWindowProc = Win32.SetWindowLong(m_layeredWnd.Handle, (uint)Win32.Message.GWL_WNDPROC, m_customLayeredWindowProc);
            }
        }
Пример #6
0
        /// <summary>
        /// Initialise the Winamp class. Called from the constructor
        /// </summary>
        private void Init()
        {
            Logger.WriteEmptyLine();
            Logger.LogMessage("hWnd: " + _WinampWindow);

            // Start with a blank "currently playing" song
            CurrentTrack = new TrackInfo("", "");
            // Update the song data
            //Logger.Instance.LogMessage("init updateSongData");
            //UpdateSongData();

            // And now, let's set up our subclassing. We can only do this if we're
            // "in process", so let's bail if we're not.
            if (!_InProcess)
            {
                // TODO: This should not be a messagebox. This is just for debugging.
                System.Windows.Forms.MessageBox.Show("Not running 'in process', certain features will not work!");
                return;
            }

            // Here's our delegate
            _WinampWndProc = new Win32.Win32WndProc(WinampWndProc);
            // Make sure it doesn't get garbage collected
            GC.KeepAlive(_WinampWndProc);
            // Let's go ahead and set the new one, saving the old one
            _OldWinampWndProc = Win32.SetWindowLong(_WinampWindow, Win32.GWL_WNDPROC, _WinampWndProc);
            Logger.LogMessage("Subclassed Winamp window (old proc = " + _OldWinampWndProc + ", new proc = " + _WinampWndProc + ")");
        }
Пример #7
0
		/// <summary>
		/// Initialise the Winamp class. Called from the constructor
		/// </summary>
		private void Init()
		{
			// Let's set up debugging, if we're in debug mode!
			#if DEBUG
				string debugDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
				string debugFile = Path.Combine(debugDir, "winamp-cs-debug.txt");
				Debug.Listeners.Add(new TextWriterTraceListener(new StreamWriter(debugFile, true)));
				Debug.AutoFlush = true;
				Debug.WriteLine("hWnd: " + _WinampWindow);
			#endif

			// Start with a blank "currently playing" song
			CurrentSong = new Song();
			// Update the song data
			UpdateSongData();

			// And now, let's set up our subclassing. We can only do this if we're
			// "in process", so let's bail if we're not.
			if (!_InProcess)
			{
				// TODO: This should not be a messagebox. This is just for debugging.
				System.Windows.Forms.MessageBox.Show("Not running 'in process', certain features will not work!");
				return;
			}

			// Here's our delegate
			_WinampWndProc = new Win32.Win32WndProc(WinampWndProc);
			// Make sure it doesn't get garbage collected
			GC.KeepAlive(_WinampWndProc);
			// Let's go ahead and set the new one, saving the old one
			_OldWinampWndProc = Win32.SetWindowLong(_WinampWindow, Win32.GWL_WNDPROC, _WinampWndProc);
			Debug.WriteLine("Subclassed Winamp window (old proc = " + _OldWinampWndProc + ", new proc = " + _WinampWndProc +")");
		}