DocAElstein wrote: ↑15 Nov 2024, 07:14
.....Getting the rest clear in my mind is going unusually much easier and quicker than I expected, I will probably be finished by dinnertime ...
I didn’t die in the snow, or get food poisoning from my dinner either, .. but it took a while longer.
I didn’t quite have the full story….
….My thoughts so far had been, (which a quick bit of internet research seemed initially to confirm was OK) , .. I needed to set my pair of decimal numbers up in a binary form like this, (
I know actual numbers would be longer – I am just showing shorter ones for clarity )
and if those last two numbers where negative, it might look like
Then I would just need to look for any position where both numbers have a 1, and then that is the True situation
To get it clear in my mind I thought I would try to make a function/ functions to mimic the VBA
And working in the situation / code line that sparked this all off
I thought I had a simple job to do, _just two fairly simple things:
_(a) a function to convert big decimal numbers to binary ,
_(b) a function to find if at any position in the two binary number representation both numbers had a 1, which would then be the True situation
I did it quite quick
_ The decimal to binary even I could figure out from my school maths memory, - the exact details of the decimal to binary conversion function I did will bore the socks off all the smart people here, but it’s basically all based on the school maths way of converting a decimal to binary….
….Take the decimal number and divide it by a number got from a high power of 2;
___
If that division comes out >= 1 , then you have your first binary digit, starting from the left of 1; then you subtract that number got from a high power of 2 from the decimal number , so the decimal number under consideration is now smaller
___
Else when that division comes out < 1 , then you have your first binary digit of 0 starting from the left. You leave the decimal number at the size it is.
Now you do the same again using the next power of 2 down as the denominator to get the next binary digit to the right. Eventually you are down to (2 ^0) to get the last binary digit at the right
_A function to check for the true situation was very simple. Go left to right, and consider the corresponding same digit in each binary number. At any first find of both having a 1, and you are true.
Hmm…. I thought it was too easy to be True,- pun intended there. It ‘aint that easy to be getting True in the VBA
And situation that we have been considering.
It came down to my binary representation not always being correct, even though my first function was OK, or rather it was doing what I intended it to do. (In the second function there was not much that could be wrong).
( Its Chris Greaves fault. ( he is innocent, but as he is in this thread, I take the opportunity to blame him as , a) he knows I love him really, and b) he sometimes telly me stories related to important things in the development of computing and he forgot to tell me the story of why some bored computer mathematician came up one day with the crazy idea of the
2s compliment binary representation of negative numbers ) )
The problem was: As everyone except me knows, in most computer binary stuff, to show the binary representation of any negative decimal number, you take what the binary would be if the same decimal number was positive, then invert all numbers , then finally do a binary add of 1 to the inverted number.
So I
thought about that , and then
modified my decimal to binary function to allow for the 2s Compliment codswallop , and all was well, :)
It was not all wasted effort. I think looking at the ( correct ) binary numbers used / found in codings like
that one , might reveal something interesting about that API
Hwnd handle number thingy:
I already got the point that the
Hwnd is a temporary number , semi - randomly generated to give any running software an identification number to find a window.
I think I also figured it won’t help someone knowing it to find a window in another running software, as that running software will get given a new set of
Hwnds – ( this is a point that some tutorials I recently seen seem to have missed )
But the number is possibly generated in such a way that looking at the (correct) binary representation, allows you to know something, for example, what type of window, or what level, or whatever. I am guessing that knowing that sort of thing is what the author of
that coding was exploiting in that code line, whose workings was the main subject/ cause of this thread,
If lngStyle And mcWSVISIBLE Then
I will have to have a good think about that, but much later. … I am going outside again…. and again.....
I may be some time…. its not the snow this time, but characteristically for a windy day this time of year, there is a lot of leaves from the forest that is my garden, to sweep away…
Alan
Edit: I had a wild dream after I laid down for a long kip after collecting leaves. I was in a new trendy pop group, 2 stunning lady singers up front and I was at the back on my drum kit. We were top of the charts doing really well. We called ourselves, "2’s flippin’ compliment + 1". Unfortunately I woke up just before the TV interview where they would ask me where the Band’s name originated. So at least you won’t get attacked by the Music Press Bots trying to find me….