-
February 5th, 2014, 05:42 PM
#1
[RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way :(
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?
-
February 6th, 2014, 01:45 PM
#2
Re: [win32] - strange effect with mouse leave and mouse enter in cyle way :(
Originally Posted by Cambalinho
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
-
February 6th, 2014, 01:51 PM
#3
Re: [win32] - strange effect with mouse leave and mouse enter in cyle way :(
Originally Posted by Paul McKenzie
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
-
February 6th, 2014, 02:01 PM
#4
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
February 6th, 2014, 02:13 PM
#5
Re: [RESOLVED] [win32] - strange effect with mouse leave and mouse enter in cyle way
Originally Posted by 2kaud
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
-
February 6th, 2014, 03:20 PM
#6
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|