Oxygen Basic

Programming => Example Code => Topic started by: Peter on December 10, 2011, 01:44:38 PM

Title: NewWindowLibrary
Post by: Peter on December 10, 2011, 01:44:38 PM
Deleted
Title: Re: NewWindowLibrary
Post by: Charles Pegge on December 10, 2011, 11:20:26 PM

Thank you Peter,

I have put in bit masks for GetAsyncKeyState: 0x8001 as per MSDN spec.

There are quite a few changes. Is it safe to resynchronise all the examples to this new library?

Charles
Title: Re: NewWindowLibrary
Post by: Charles Pegge on December 11, 2011, 10:14:50 AM
Hi Peter in one program, I forget which, higher bits were set causing a false keypress.
Setting the return type of GetAsyncKeyState to short instead of integer may help
Title: Re: NewWindowLibrary
Post by: efgee on December 11, 2011, 03:30:17 PM
...WINXP hasn't  64 Bit, is too old therefor. ...     :D

Sorry, but this is not true: Microsoft released Windows XP in 64 bit.

Here more information:
http://en.wikipedia.org/wiki/Windows_XP_Professional_x64_Edition

bye
Title: Re: NewWindowLibrary
Post by: efgee on December 11, 2011, 03:48:26 PM
According to Microsoft GetAsyncKeyState returns SHORT.

Code: [Select]
SHORT WINAPI GetAsyncKeyState(
  __in  int vKey
);

Everything else is wrong!

Title: Re: NewWindowLibrary
Post by: Charles Pegge on December 11, 2011, 09:30:43 PM
Yes, I ran a number of tests and found various high bits were set in 64 bit mode (Vista 64bit).

If you change the return type for GetAsyncKeyState to short, the compiler will sign-extend the 16 bits to 64 bits as it should, and the high bits will be overwritten.

Then there is no need to apply a bitmask. (Still needed if using MinWin)

I checked this with 'FileTest' and without this modification the program locks into a loop

Charles



PS: This does not apply to your libraries  Peter but I had to make an adjustment for functions returning shorts or bytes, treated as booleans thus:


while GetAsyncKeyState(27)
wend

while not GetAsyncKeyState(27)
wend


On my latest update now, this mode of expression will work correctly for 64 bit binaries.

Title: Re: NewWindowLibrary
Post by: Charles Pegge on December 12, 2011, 07:55:02 AM
Hi Peter,

Discussing problem areas like this is beneficial from my point of view, as they often indicate where Oxygen needs further attention.
Title: Re: NewWindowLibrary
Post by: efgee on December 12, 2011, 12:07:27 PM
I do not know why we discuss about key usage, only we both got it. On the other side, no interest here!
The people expect OxygenBasic as divine ability, that makes their programs.

Peter,
Oxygen is young, so the objective must be to build a set of include files that work in conjunction with the OS-API.
(according to our best knowledge...)

Doing otherwise is just foolish and short sighted.

There is no reason to get mad about it...

Stay cool  8)