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. Visual Basic
  4. Two problems with a thread project

Two problems with a thread project

Scheduled Pinned Locked Moved Visual Basic
questionhtmlhelp
5 Posts 4 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.
  • Z Offline
    Z Offline
    Zero G
    wrote on last edited by
    #1

    Hey I have two big problems with my project. I will post the whole code down under my question What you will need to reproduce this code is a UserControl, on this usercontrol has to be a PictureBox and a Label The problems are: 1) The mouseLeave Event is fired, even if I don't leave the usercontrol 2) After finishing the Animation, the picture box pops up to full size. Maybe somone can help me? Here ist the code (VB2005) Imports System.ComponentModel Imports System.Reflection Imports System.Threading Public Class ISHilfe #Region "Properties des Eigenschaftsfensters" Dim _Bild As Image < _ Description("Bild für Animation"), _ Category("Misc")> _ Public Property Bild() As Image Get Return (_Bild) End Get Set(ByVal value As Image) Try _Bild = value pctBox.Image = value pctBox.SizeMode = PictureBoxSizeMode.StretchImage Catch End Try End Set End Property Dim _Labeltext As String < _ Description("Text des Hilfelabels mit Mini Markup"), _ Category("Misc")> _ Public Property LabelText() As String Get Return _Labeltext End Get Set(ByVal value As String) _Labeltext = value End Set End Property #End Region Dim pctAusblenden As New ThreadStart(AddressOf pctBoxVerkleinern) Dim pctEinblenden As New ThreadStart(AddressOf pctBoxVergrößern) Dim lblAusblenden As New ThreadStart(AddressOf lblVerkleinern) Dim lblEinblenden As New ThreadStart(AddressOf lblVergrößern) Dim pctFadeOut As New Thread(pctAusblenden) Dim pctFadeIn As New Thread(pctEinblenden) Dim lblFadeOut As New Thread(lblAusblenden) Dim lblFadeIn As New Thread(lblEinblenden) Private Sub ISHilfe_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load _ControlLabel = Me.lblInfo _ControlPctBox = Me.pctBox End Sub Private Sub ISHilfe_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter lblOriginalSchrift = lblInfo.ForeColor If pctFadeIn.ThreadState = ThreadState.Running Then pctFadeIn.Abort() End If If lblFadeOut.ThreadState = ThreadState.Running Then lblFadeOut.Abort() End If pctFadeOut.Start() lblFadeIn.Start() End Sub Private Sub ISHilfe_MouseLea

    C T 2 Replies Last reply
    0
    • Z Zero G

      Hey I have two big problems with my project. I will post the whole code down under my question What you will need to reproduce this code is a UserControl, on this usercontrol has to be a PictureBox and a Label The problems are: 1) The mouseLeave Event is fired, even if I don't leave the usercontrol 2) After finishing the Animation, the picture box pops up to full size. Maybe somone can help me? Here ist the code (VB2005) Imports System.ComponentModel Imports System.Reflection Imports System.Threading Public Class ISHilfe #Region "Properties des Eigenschaftsfensters" Dim _Bild As Image < _ Description("Bild für Animation"), _ Category("Misc")> _ Public Property Bild() As Image Get Return (_Bild) End Get Set(ByVal value As Image) Try _Bild = value pctBox.Image = value pctBox.SizeMode = PictureBoxSizeMode.StretchImage Catch End Try End Set End Property Dim _Labeltext As String < _ Description("Text des Hilfelabels mit Mini Markup"), _ Category("Misc")> _ Public Property LabelText() As String Get Return _Labeltext End Get Set(ByVal value As String) _Labeltext = value End Set End Property #End Region Dim pctAusblenden As New ThreadStart(AddressOf pctBoxVerkleinern) Dim pctEinblenden As New ThreadStart(AddressOf pctBoxVergrößern) Dim lblAusblenden As New ThreadStart(AddressOf lblVerkleinern) Dim lblEinblenden As New ThreadStart(AddressOf lblVergrößern) Dim pctFadeOut As New Thread(pctAusblenden) Dim pctFadeIn As New Thread(pctEinblenden) Dim lblFadeOut As New Thread(lblAusblenden) Dim lblFadeIn As New Thread(lblEinblenden) Private Sub ISHilfe_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load _ControlLabel = Me.lblInfo _ControlPctBox = Me.pctBox End Sub Private Sub ISHilfe_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter lblOriginalSchrift = lblInfo.ForeColor If pctFadeIn.ThreadState = ThreadState.Running Then pctFadeIn.Abort() End If If lblFadeOut.ThreadState = ThreadState.Running Then lblFadeOut.Abort() End If pctFadeOut.Start() lblFadeIn.Start() End Sub Private Sub ISHilfe_MouseLea

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Zero-G. wrote:

      I will post the whole code down under my question

      Just the relevant parts will do. I don't think most people actually have the time to read it all.


      Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

      P 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Zero-G. wrote:

        I will post the whole code down under my question

        Just the relevant parts will do. I don't think most people actually have the time to read it all.


        Upcoming events: * Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ... "I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless." Ready to Give up - Your help will be much appreciated. My website

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Colin Angus Mackay wrote:

        I don't think most people actually have the time to read it all.

        I just did a quick glance, and now I will just walk away for awhile :rolleyes:

        "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        1 Reply Last reply
        0
        • Z Zero G

          Hey I have two big problems with my project. I will post the whole code down under my question What you will need to reproduce this code is a UserControl, on this usercontrol has to be a PictureBox and a Label The problems are: 1) The mouseLeave Event is fired, even if I don't leave the usercontrol 2) After finishing the Animation, the picture box pops up to full size. Maybe somone can help me? Here ist the code (VB2005) Imports System.ComponentModel Imports System.Reflection Imports System.Threading Public Class ISHilfe #Region "Properties des Eigenschaftsfensters" Dim _Bild As Image < _ Description("Bild für Animation"), _ Category("Misc")> _ Public Property Bild() As Image Get Return (_Bild) End Get Set(ByVal value As Image) Try _Bild = value pctBox.Image = value pctBox.SizeMode = PictureBoxSizeMode.StretchImage Catch End Try End Set End Property Dim _Labeltext As String < _ Description("Text des Hilfelabels mit Mini Markup"), _ Category("Misc")> _ Public Property LabelText() As String Get Return _Labeltext End Get Set(ByVal value As String) _Labeltext = value End Set End Property #End Region Dim pctAusblenden As New ThreadStart(AddressOf pctBoxVerkleinern) Dim pctEinblenden As New ThreadStart(AddressOf pctBoxVergrößern) Dim lblAusblenden As New ThreadStart(AddressOf lblVerkleinern) Dim lblEinblenden As New ThreadStart(AddressOf lblVergrößern) Dim pctFadeOut As New Thread(pctAusblenden) Dim pctFadeIn As New Thread(pctEinblenden) Dim lblFadeOut As New Thread(lblAusblenden) Dim lblFadeIn As New Thread(lblEinblenden) Private Sub ISHilfe_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load _ControlLabel = Me.lblInfo _ControlPctBox = Me.pctBox End Sub Private Sub ISHilfe_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter lblOriginalSchrift = lblInfo.ForeColor If pctFadeIn.ThreadState = ThreadState.Running Then pctFadeIn.Abort() End If If lblFadeOut.ThreadState = ThreadState.Running Then lblFadeOut.Abort() End If pctFadeOut.Start() lblFadeIn.Start() End Sub Private Sub ISHilfe_MouseLea

          T Offline
          T Offline
          TwoFaced
          wrote on last edited by
          #4

          I believe the UserControl is firing it's mouseleave event when the mouse goes over the label or picturebox. This is normal. When the event fires you might be able to just check the mouselocation and if it's within the bounds of your control, exit the method. You could also try to get around the problem by doing all the drawing yourself instead of using a picturebox and label. **EDIT** The reason it pops up is because of the second loop in this method 'pctBoxVerkleinern'. Also I believe your going to have some threading issues because you can't start a thread once it's been aborted. In the mouseenter and leave events you need to create a new instance of the thread and then start it.

          Z 1 Reply Last reply
          0
          • T TwoFaced

            I believe the UserControl is firing it's mouseleave event when the mouse goes over the label or picturebox. This is normal. When the event fires you might be able to just check the mouselocation and if it's within the bounds of your control, exit the method. You could also try to get around the problem by doing all the drawing yourself instead of using a picturebox and label. **EDIT** The reason it pops up is because of the second loop in this method 'pctBoxVerkleinern'. Also I believe your going to have some threading issues because you can't start a thread once it's been aborted. In the mouseenter and leave events you need to create a new instance of the thread and then start it.

            Z Offline
            Z Offline
            Zero G
            wrote on last edited by
            #5

            Hey Thanks for taking the time, and take a look to the code. I will try to change the code, like you told me. - I will answer my progress. THX

            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