Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Properties does not change in custom MouseEnter event incomplete implementation.

Properties does not change in custom MouseEnter event incomplete implementation.

Scheduled Pinned Locked Moved C#
graphicscsharplinqquestion
27 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Q12_
    wrote on last edited by
    #1

    "female.Name" does not change in Form1 MouseEnter event. How can be implemented a simple event like this, into my "Human" class ? I must take the mouse coordinates XY and "put" them somewhere, when the event is fired. But how and where?

    //class Human:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;

    namespace WindowsFormsApplication5
    {
    class Human
    {
    public string Name = "none";
    public Point location = new Point();

        public void Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), location.X - 5, location.Y - 15);
            e.Graphics.FillRectangle(new SolidBrush(Color.Red), new Rectangle(location.X, location.Y, 20, 20));
        }
    
        public event EventHandler MouseEnter;
    
    }
    

    }

    //Form1:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsFormsApplication5
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    female.Name = "Alina";
    female.location = new Point(30, 30);
    female.MouseEnter += new EventHandler(female_MouseEnter);
    }

        Human female = new Human();
        private void Form1\_Paint(object sender, PaintEventArgs e)
        {
            female.Paint(sender, e);
        }
    
        void female\_MouseEnter(object sender, EventArgs e)
        {
            female.Name = "Olina";
        }
    }
    

    }

    OriginalGriffO 1 Reply Last reply
    0
    • _ _Q12_

      "female.Name" does not change in Form1 MouseEnter event. How can be implemented a simple event like this, into my "Human" class ? I must take the mouse coordinates XY and "put" them somewhere, when the event is fired. But how and where?

      //class Human:
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Drawing;

      namespace WindowsFormsApplication5
      {
      class Human
      {
      public string Name = "none";
      public Point location = new Point();

          public void Paint(object sender, System.Windows.Forms.PaintEventArgs e)
          {
              e.Graphics.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), location.X - 5, location.Y - 15);
              e.Graphics.FillRectangle(new SolidBrush(Color.Red), new Rectangle(location.X, location.Y, 20, 20));
          }
      
          public event EventHandler MouseEnter;
      
      }
      

      }

      //Form1:
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;

      namespace WindowsFormsApplication5
      {
      public partial class Form1 : Form
      {
      public Form1()
      {
      InitializeComponent();
      female.Name = "Alina";
      female.location = new Point(30, 30);
      female.MouseEnter += new EventHandler(female_MouseEnter);
      }

          Human female = new Human();
          private void Form1\_Paint(object sender, PaintEventArgs e)
          {
              female.Paint(sender, e);
          }
      
          void female\_MouseEnter(object sender, EventArgs e)
          {
              female.Name = "Olina";
          }
      }
      

      }

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      For starters, don't make fields public - use properties instead, and keep fields private. Public fields mean that the interior workings of your class are exposed to the outside world, and you have to think long and hard before you make any changes at all which might affect them. Properties don't. (And they have other advantages when it comes to being used as a DataSource, serialization, and so forth.) Secondly, Point is a struct not a class, so you only need to use the new keyword if the constructor needs to be called - it doesn't for Point.

      class Human
      {
          private string \_Name = "none";
          public string Name { get { return \_Name; } set { \_Name = value; }}
          public Point Location { get; set;}
      

      It's also a bad idea to "mock" events in your class:

      public void Paint(object sender, System.Windows.Forms.PaintEventArgs e)

      Is not an event handler, so don't make it look like one! )or someone will try to attach a handler, and get confused. Instead, just pass the data it needs: the graphics context:

          public void Paint(Graphics g)
          {
              g.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), location.X - 5, location.Y - 15);
              g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(location.X, location.Y, 20, 20));
          }
      
          private void Form1\_Paint(object sender, PaintEventArgs e)
          {
              female.Paint(e.Graphics);
          }
      

      That way, it's also easier to call it when you want to draw the name when you enter the control. Finally - and I think I've mentioned this before recently, but I'm not sure if it's to you: Human is a class, but it isn't derived from Control. Which means it doesn't have any interaction directly with the user, and that includes Mouse events. Adding the line

      public event EventHandler MouseEnter;

      doesn;t "hook" your class into the "Mouse events" system, it just creates an event called "MouseEnter" which is never raised by anything. If you want a MouseEnter that actually does something then the class which processes it MUST be based on Control: A Form, a Panel, or a UserControl perhaps. You can't just add a handler and hope the system will sort it all out for you!

      Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter:

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      _ 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        For starters, don't make fields public - use properties instead, and keep fields private. Public fields mean that the interior workings of your class are exposed to the outside world, and you have to think long and hard before you make any changes at all which might affect them. Properties don't. (And they have other advantages when it comes to being used as a DataSource, serialization, and so forth.) Secondly, Point is a struct not a class, so you only need to use the new keyword if the constructor needs to be called - it doesn't for Point.

        class Human
        {
            private string \_Name = "none";
            public string Name { get { return \_Name; } set { \_Name = value; }}
            public Point Location { get; set;}
        

        It's also a bad idea to "mock" events in your class:

        public void Paint(object sender, System.Windows.Forms.PaintEventArgs e)

        Is not an event handler, so don't make it look like one! )or someone will try to attach a handler, and get confused. Instead, just pass the data it needs: the graphics context:

            public void Paint(Graphics g)
            {
                g.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), location.X - 5, location.Y - 15);
                g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(location.X, location.Y, 20, 20));
            }
        
            private void Form1\_Paint(object sender, PaintEventArgs e)
            {
                female.Paint(e.Graphics);
            }
        

        That way, it's also easier to call it when you want to draw the name when you enter the control. Finally - and I think I've mentioned this before recently, but I'm not sure if it's to you: Human is a class, but it isn't derived from Control. Which means it doesn't have any interaction directly with the user, and that includes Mouse events. Adding the line

        public event EventHandler MouseEnter;

        doesn;t "hook" your class into the "Mouse events" system, it just creates an event called "MouseEnter" which is never raised by anything. If you want a MouseEnter that actually does something then the class which processes it MUST be based on Control: A Form, a Panel, or a UserControl perhaps. You can't just add a handler and hope the system will sort it all out for you!

        Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter:

        _ Offline
        _ Offline
        _Q12_
        wrote on last edited by
        #3

        Thank you mister OriginalGriff, Now I made the suggested rectifications:

        public class Human : UserControl
        {
            //Name      is from Usercontrol inheritance, 
            //Location  is from Usercontrol inheritance, 
            public void hPaint(Graphics g)
            {
                g.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), Location.X - 5, Location.Y - 15);
                g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(Location.X, Location.Y, 20, 20));
            }
        
            public override event EventHandler MouseEnter; //???
            //Probably i must override the mouse event somehow...
        }
        
        OriginalGriffO 1 Reply Last reply
        0
        • _ _Q12_

          Thank you mister OriginalGriff, Now I made the suggested rectifications:

          public class Human : UserControl
          {
              //Name      is from Usercontrol inheritance, 
              //Location  is from Usercontrol inheritance, 
              public void hPaint(Graphics g)
              {
                  g.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), Location.X - 5, Location.Y - 15);
                  g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(Location.X, Location.Y, 20, 20));
              }
          
              public override event EventHandler MouseEnter; //???
              //Probably i must override the mouse event somehow...
          }
          
          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Just add a handler, and add the instance to the form's Controls collection.

          Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          _ 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Just add a handler, and add the instance to the form's Controls collection.

            Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

            _ Offline
            _ Offline
            _Q12_
            wrote on last edited by
            #5

            Make an example for me, Please. I think in Form1 i must do this? >> Controls.Add(female);

            OriginalGriffO 1 Reply Last reply
            0
            • _ _Q12_

              Make an example for me, Please. I think in Form1 i must do this? >> Controls.Add(female);

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              Try this: remove the line

              public override event EventHandler MouseEnter;

              And drag your Human class from the toolbox onto your form. Try it!

              Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              _ 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Try this: remove the line

                public override event EventHandler MouseEnter;

                And drag your Human class from the toolbox onto your form. Try it!

                Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                _ Offline
                _ Offline
                _Q12_
                wrote on last edited by
                #7

                i've made a red square there in the paint event. It is not showing at all. Only the text from the same paint event is visible. When i drag the control from toolbox into my form, a very large grey square appear, but not my red square and its text. I want the area to be as large as that red square (20,20). When I move my mouse over this red square area, I want the text to change. All this graphics must "float" over other controls. In this way, I can intersect many other controls like these between them.

                OriginalGriffO 2 Replies Last reply
                0
                • _ _Q12_

                  i've made a red square there in the paint event. It is not showing at all. Only the text from the same paint event is visible. When i drag the control from toolbox into my form, a very large grey square appear, but not my red square and its text. I want the area to be as large as that red square (20,20). When I move my mouse over this red square area, I want the text to change. All this graphics must "float" over other controls. In this way, I can intersect many other controls like these between them.

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  Did you add the Paint event handler to your UserControl? Check in the designer!

                  Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  _ 1 Reply Last reply
                  0
                  • _ _Q12_

                    i've made a red square there in the paint event. It is not showing at all. Only the text from the same paint event is visible. When i drag the control from toolbox into my form, a very large grey square appear, but not my red square and its text. I want the area to be as large as that red square (20,20). When I move my mouse over this red square area, I want the text to change. All this graphics must "float" over other controls. In this way, I can intersect many other controls like these between them.

                    OriginalGriffO Offline
                    OriginalGriffO Offline
                    OriginalGriff
                    wrote on last edited by
                    #9

                    I tell you what: stop what you are doing. Create a new solution, WinForms, call it "HumanDemo" Add a UserControl to the project, call it Human. In the designer, add event handlers to the Human control: MouseEnter, MouseLeave, Paint. In the Human code, add a field and a property:

                        private bool isIn = false;
                        public string Name { get; set; }
                    

                    In the Human Constructor, add a line, so it looks like this:

                        public Human()
                            {
                            InitializeComponent();
                            Name = "A name";
                            }
                    

                    Then edit the three handlers so they look like this:

                        private void Human\_MouseEnter(object sender, EventArgs e)
                            {
                            isIn = true;
                            Invalidate();
                            }
                    
                        private void Human\_MouseLeave(object sender, EventArgs e)
                            {
                            isIn = false;
                            Invalidate();
                            }
                    
                        private void Human\_Paint(object sender, PaintEventArgs e)
                            {
                            Graphics g = e.Graphics;
                            Rectangle rect = e.ClipRectangle;
                            rect.Inflate(-1, -1);
                            g.DrawRectangle(Pens.Red, rect);
                            if (isIn)
                                {
                                g.DrawString(Name, Font, Brushes.Black, new Point(10, 10));
                                }
                            }
                    

                    Compile your project. Go to the main form in teh designer, and drag a Human control from your toolbox and drop it on the form. Run your application. Move the mouse into and out of the red rectangle. That's how simple it is!

                    Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                    _ 2 Replies Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      Did you add the Paint event handler to your UserControl? Check in the designer!

                      Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                      _ Offline
                      _ Offline
                      _Q12_
                      wrote on last edited by
                      #10

                      alright, now is showing in Form1 after I add this class object to Controls. I also get rid of the custom paint event i made earlier. If its not good what i did here, please correct me.

                      public class Human : UserControl
                      {
                      public Human()
                      {
                      Paint += new PaintEventHandler(Human_Paint);
                      }

                          void Human\_Paint(object sender, PaintEventArgs e)
                          {
                              e.Graphics.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), Location.X - 5, Location.Y - 15);
                              e.Graphics.FillRectangle(new SolidBrush(Color.Red), new Rectangle(Location.X, Location.Y, 20, 20));
                          }
                      }
                      
                      OriginalGriffO 1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        I tell you what: stop what you are doing. Create a new solution, WinForms, call it "HumanDemo" Add a UserControl to the project, call it Human. In the designer, add event handlers to the Human control: MouseEnter, MouseLeave, Paint. In the Human code, add a field and a property:

                            private bool isIn = false;
                            public string Name { get; set; }
                        

                        In the Human Constructor, add a line, so it looks like this:

                            public Human()
                                {
                                InitializeComponent();
                                Name = "A name";
                                }
                        

                        Then edit the three handlers so they look like this:

                            private void Human\_MouseEnter(object sender, EventArgs e)
                                {
                                isIn = true;
                                Invalidate();
                                }
                        
                            private void Human\_MouseLeave(object sender, EventArgs e)
                                {
                                isIn = false;
                                Invalidate();
                                }
                        
                            private void Human\_Paint(object sender, PaintEventArgs e)
                                {
                                Graphics g = e.Graphics;
                                Rectangle rect = e.ClipRectangle;
                                rect.Inflate(-1, -1);
                                g.DrawRectangle(Pens.Red, rect);
                                if (isIn)
                                    {
                                    g.DrawString(Name, Font, Brushes.Black, new Point(10, 10));
                                    }
                                }
                        

                        Compile your project. Go to the main form in teh designer, and drag a Human control from your toolbox and drop it on the form. Run your application. Move the mouse into and out of the red rectangle. That's how simple it is!

                        Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                        _ Offline
                        _ Offline
                        _Q12_
                        wrote on last edited by
                        #11

                        i made it work now.

                        OriginalGriffO 1 Reply Last reply
                        0
                        • _ _Q12_

                          i made it work now.

                          OriginalGriffO Offline
                          OriginalGriffO Offline
                          OriginalGriff
                          wrote on last edited by
                          #12

                          See how easy it is? :-D

                          Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                          1 Reply Last reply
                          0
                          • _ _Q12_

                            alright, now is showing in Form1 after I add this class object to Controls. I also get rid of the custom paint event i made earlier. If its not good what i did here, please correct me.

                            public class Human : UserControl
                            {
                            public Human()
                            {
                            Paint += new PaintEventHandler(Human_Paint);
                            }

                                void Human\_Paint(object sender, PaintEventArgs e)
                                {
                                    e.Graphics.DrawString(Name, new Font("Arial", 9), new SolidBrush(Color.Black), Location.X - 5, Location.Y - 15);
                                    e.Graphics.FillRectangle(new SolidBrush(Color.Red), new Rectangle(Location.X, Location.Y, 20, 20));
                                }
                            }
                            
                            OriginalGriffO Offline
                            OriginalGriffO Offline
                            OriginalGriff
                            wrote on last edited by
                            #13

                            Just as an aside: dont; create Font and Brush (or any graphics items) willy nilly - they all use something called Handles which are in short supply. If you create a graphics item, it needs a fresh handle, so unless you specifically Dispose of it when you are finished, you will crash your app with an "out of memory" exception pretty quickly because the whole system will run out of Handles and become unstable. It's a very good idea to create a static class level Font and Brush item, and use them, or use a using block around the item construction so that it is automatically Disposed when it goes out of scope.

                            Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                            1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              I tell you what: stop what you are doing. Create a new solution, WinForms, call it "HumanDemo" Add a UserControl to the project, call it Human. In the designer, add event handlers to the Human control: MouseEnter, MouseLeave, Paint. In the Human code, add a field and a property:

                                  private bool isIn = false;
                                  public string Name { get; set; }
                              

                              In the Human Constructor, add a line, so it looks like this:

                                  public Human()
                                      {
                                      InitializeComponent();
                                      Name = "A name";
                                      }
                              

                              Then edit the three handlers so they look like this:

                                  private void Human\_MouseEnter(object sender, EventArgs e)
                                      {
                                      isIn = true;
                                      Invalidate();
                                      }
                              
                                  private void Human\_MouseLeave(object sender, EventArgs e)
                                      {
                                      isIn = false;
                                      Invalidate();
                                      }
                              
                                  private void Human\_Paint(object sender, PaintEventArgs e)
                                      {
                                      Graphics g = e.Graphics;
                                      Rectangle rect = e.ClipRectangle;
                                      rect.Inflate(-1, -1);
                                      g.DrawRectangle(Pens.Red, rect);
                                      if (isIn)
                                          {
                                          g.DrawString(Name, Font, Brushes.Black, new Point(10, 10));
                                          }
                                      }
                              

                              Compile your project. Go to the main form in teh designer, and drag a Human control from your toolbox and drop it on the form. Run your application. Move the mouse into and out of the red rectangle. That's how simple it is!

                              Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                              _ Offline
                              _ Offline
                              _Q12_
                              wrote on last edited by
                              #14

                              Your code is not good at all. Look here in my screenshot: http://i64.tinypic.com/29dijx3.jpg[^] The first red square must be visible under the second square control ! With my code, I can make it show one beneath the other one.

                              OriginalGriffO 1 Reply Last reply
                              0
                              • _ _Q12_

                                Your code is not good at all. Look here in my screenshot: http://i64.tinypic.com/29dijx3.jpg[^] The first red square must be visible under the second square control ! With my code, I can make it show one beneath the other one.

                                OriginalGriffO Offline
                                OriginalGriffO Offline
                                OriginalGriff
                                wrote on last edited by
                                #15

                                Two things: 1) no image. 2) You didn't think it might have something to do with the order in which you added the controls? Google "Z-order" and start thinking about what you are doing instead of guessing ... :sigh:

                                Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                _ 1 Reply Last reply
                                0
                                • OriginalGriffO OriginalGriff

                                  Two things: 1) no image. 2) You didn't think it might have something to do with the order in which you added the controls? Google "Z-order" and start thinking about what you are doing instead of guessing ... :sigh:

                                  Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                  _ Offline
                                  _ Offline
                                  _Q12_
                                  wrote on last edited by
                                  #16

                                  now? https://i106.fastpic.ru/thumb/2018/1222/4e/7ac3a88bb3620fe04738211836c8234e.jpeg[^]

                                  OriginalGriffO 1 Reply Last reply
                                  0
                                  • _ _Q12_

                                    now? https://i106.fastpic.ru/thumb/2018/1222/4e/7ac3a88bb3620fe04738211836c8234e.jpeg[^]

                                    OriginalGriffO Offline
                                    OriginalGriffO Offline
                                    OriginalGriff
                                    wrote on last edited by
                                    #17

                                    And did you google "Z-order"?

                                    Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                    _ 1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      And did you google "Z-order"?

                                      Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                      _ Offline
                                      _ Offline
                                      _Q12_
                                      wrote on last edited by
                                      #18

                                      i know what z-order is - its not that. I intersect the 2 squares, not putting one on top of the other. Both are z-order dependent but with diferent meanings... you will get my point very easy from my screenshot.

                                      _ 1 Reply Last reply
                                      0
                                      • _ _Q12_

                                        i know what z-order is - its not that. I intersect the 2 squares, not putting one on top of the other. Both are z-order dependent but with diferent meanings... you will get my point very easy from my screenshot.

                                        _ Offline
                                        _ Offline
                                        _Q12_
                                        wrote on last edited by
                                        #19

                                        Imgur: The magic of the Internet[^]

                                        OriginalGriffO 1 Reply Last reply
                                        0
                                        • _ _Q12_

                                          Imgur: The magic of the Internet[^]

                                          OriginalGriffO Offline
                                          OriginalGriffO Offline
                                          OriginalGriff
                                          wrote on last edited by
                                          #20

                                          Right - you can't do that with controls at all; you have to use Paint and draw yyour rectancgles your self. Which means that you have to do the "entry" and "exit" code yourself, by handling MouseMove in your Parent container, and manually checking which of your rectangles the mouse is currently in:you cannot use MouseEnter and MouseLeave on your own rectangles because - unless they are Controls and in which case transparent backgrounds don't work - only Controls can react to mouse events. Remove UserControl, and go back to drawing them yourself - but you will have to work out where the mouse is yourself, the system will not help you!

                                          Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                          _ 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups