Results 1 to 13 of 13

Thread: inheriting picturebox's events

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    inheriting picturebox's events

    i want to inherit a class from PictureBox control and that when the event mouseEnter and mouseHover happens it makes something...how do i do that?

    pay attention that i dont want to make that the user that uses the class has to write that code..what im questioning is how i make that the class implements that so the user has to write none in the final code

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    you cant. If you inherit a class, you have to write your own code if you want to change anything. So if you inherit from the picturebox class and want to change the implementation of the mouseEnter and mouseHover, you have to override them.
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yea i know but how do i make that?

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    PHP Code:
    protected override OnMouseEnter(MouseEventArgs e)
    {
       
    //code here

    When I get home I try to see if I can do an example.
    Dont gain the world and lose your soul

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah is it that easy? i though i'd have to make delegates and blablabla lolol

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    didnt work..it overrided as function:
    PHP Code:

            
    public override void MouseHover(object senderSystem.EventArgs e)
            {
                
    MessageBox.Show("...");
            } 

  7. #7

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah putting the OnMouseHover worked like a sharm

  8. #8

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    C:\Documents and Settings\JBRANCO\My Documents\Visual Studio Projects\WindowsApplication10\Form1.cs(174): 'WindowsApplication10.extraPictureBox.OnMouseHover(object, System.EventArgs)': no suitable method found to override


    bah!

  9. #9

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    did it

    i had to take away the sender object

  10. #10

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    its strange when i put the mouse over the image it takes about 1sec to raise the event..and it only raises the event on the class..if i try to use the class' event it just won't execute

  11. #11
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    The reason for the 1 sec wait is because of the hover. If you over override the OnMouseEnter, its much faster.

    and it only raises the event on the class..if i try to use the class' event it just won't execute
    What do you mean by this?
    Dont gain the world and lose your soul

  12. #12

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i mean it raises the override i made...but when make

    myClass class = new myClass();
    class.MouseHover += new blablabla

    private void class_MouseHover(blablabla)
    code


    this part won't be executed..!

  13. #13
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Post the code and I'll take a look at it.
    Dont gain the world and lose your soul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width