[RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way :(
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: [RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way :(

  1. #1
    Join Date
    Apr 2009
    Posts
    636

    [RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way :(

    Name:  mouse leave and mouse enter in cyle.gif
Views: 98
Size:  74.8 KB
    see the image... more or less where is that arrow(pixel less pixel... sorry i can't print screen with the mouse cursor ) the Mouse Enter and Mouse Leave are executed in infinite cycle until i move to another place. can anyone explain how these is possible?

  2. #2
    Join Date
    Apr 1999
    Posts
    27,427

    Re: [win32] - strange effect with mouse leave and mouse enter in cyle way :(

    Quote Originally Posted by Cambalinho View Post
    Name:  mouse leave and mouse enter in cyle.gif
Views: 98
Size:  74.8 KB
    see the image... more or less where is that arrow(pixel less pixel... sorry i can't print screen with the mouse cursor ) the Mouse Enter and Mouse Leave are executed in infinite cycle until i move to another place. can anyone explain how these is possible?
    Let's talk code, and not pictures.

    The reason why an infinite loop occurs is if you process a message, and that message triggers another message, and eventually those messages leads to one or more of the previous messages being sent. Thus you have an infinite loop.

    So debug your code to figure out which message starts this chain of events.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Apr 2009
    Posts
    636

    Re: [win32] - strange effect with mouse leave and mouse enter in cyle way :(

    Quote Originally Posted by Paul McKenzie View Post
    Let's talk code, and not pictures.

    The reason why an infinite loop occurs is if you process a message, and that message triggers another message, and eventually those messages leads to one or more of the previous messages being sent. Thus you have an infinite loop.

    So debug your code to figure out which message starts this chain of events.

    Regards,

    Paul McKenzie
    when i move the mouse(enter) the text is changed and if the autosize is true resize the control. depending on control size and if we don't move the mouse, these effect will happen in cyle.
    thanks for all

  4. #4
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,360

    Re: [RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way

    So debug the code. Find out what messages are being received in what order and trace through how you are handling these. As Paul stated in his post #2, in processing a particular message you may cause the same message to be generated, which causes the same message to be generated ad-infinitum - an infinite loop. Once you have determined what part of your code is causing this then you will need to consider how you want to deal with it. Note that this may not be as simple as Message A generating another Message A. In complex windows code you might find something like this
    Message A -> Message B -> Message C -> Message D -> Message A

    Oh the fun to be had!
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  5. #5
    Join Date
    Apr 2009
    Posts
    636

    Re: [RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way

    Quote Originally Posted by 2kaud View Post
    So debug the code. Find out what messages are being received in what order and trace through how you are handling these. As Paul stated in his post #2, in processing a particular message you may cause the same message to be generated, which causes the same message to be generated ad-infinitum - an infinite loop. Once you have determined what part of your code is causing this then you will need to consider how you want to deal with it. Note that this may not be as simple as Message A generating another Message A. In complex windows code you might find something like this
    Message A -> Message B -> Message C -> Message D -> Message A

    Oh the fun to be had!
    these type of loop can't be resolved, unless i avoid use mouse leave or mouse enter when autosize is true

  6. #6
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,360

    Re: [RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way

    these type of loop can't be resolved,
    Yes it can but it isn't nice. First find out which message corresponds to Message A - ie the first message in the loop. For each window define a state flag and set to false. Then at the start of the code for Message A test the flag and if set to true, just break out of message processing. If false then set to true, perform the rest of the message code and before normal exit reset the state back to false. Thus when Message A gets called again before Message A has completed it just exits and does nothing so breaks the loop. If you have multiple threads use the interlockxxx set of functions to set/reset and test the state flag.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center