Does 'extern' allow me to access Win32API?

BlitzMax Forums/BlitzMax Programming/Does 'extern' allow me to access Win32API?

Russell(Posted 2005) [#1]
I see some sample code using 'extern Win32' and so on but no concrete "Yes, you can do it!" info concerning this.

Birdie did a lot of work typing all those function names and arguments into the TWin32 mod. But how do I use it to, say, open a native Windows window, for example?

Since I haven't seen or heard of anyone doing this, maybe it isn't possible yet?

Russell

p.s. Of course, this would render such a program non-cross platform...But I'm just curious.


EOF(Posted 2005) [#2]
I say 100% yes. Quick example:

Extern "win32"
	Function GetKeyboardState%(pbKeyState:Byte Ptr)
End Extern

Const VK_CAPITAL = $14
Const VK_NUMLOCK = $90
Const VK_SCROLL = $91
Const VK_INSERT = $2d

Global kbstate:Byte[256]

Graphics 640,480,0

Repeat
	Cls
	
	GetKeyboardState kbstate
	DrawText "Caps Lock = "+kbstate[VK_CAPITAL] , 10,20
	DrawText "Num Lock = "+kbstate[VK_NUMLOCK] , 10,40
	DrawText "Scroll Lock = "+kbstate[VK_SCROLL] , 10,60
	DrawText "Insert = "+kbstate[VK_INSERT] , 10,80
	
	Delay 5
	Flip
Until KeyHit(KEY_ESCAPE)

End



Russell(Posted 2005) [#3]
Ah! Great! A "proper" Win32 program needs an event loop, though, which would require a callback, which would require a function pointer, which... we don't have yet.. :(

Should be easy to add, since we already have VarPtr!

Russell


Picklesworth(Posted 2005) [#4]
Woah! What the?! Why didn't I know about that??
Excuse the n00b who doesn't actually even have a demo question, but you're probably used to them by now... Anyway, does this Extern thing allow you to immeadiately access any dlls?

BTW: Windows api guide here: http://www.mentalis.org/index2.shtml
I'm not finding the download page, but as I recall it's pretty easy to find.


Perturbatio(Posted 2005) [#5]
which would require a function pointer, which... we don't have yet.. :(

ummm...

Type test
	Field myFunc(a:Int)
End Type

Function testf(anInt:Int)
	Print anInt
End Function


Local t:test = New Test
	t.myFunc = testf

t.myFunc(45)


Isn't this a function pointer?

If you want to find out what win32 functions you can use, there's some info here:
http://www.blitzbasic.com/Community/posts.php?topic=42011


Russell(Posted 2005) [#6]
Wow, had no idea I could assign a new address to an instance's member, nor that a field can be something other than a variable. AAGHH! This all needs to be in the manual!

Thanks for the tip, though. I'll check out the link as well.
I guess not coming from a C\C++ background has hurt me in this area... :(

Thanks,
Russell


Zenith(Posted 2005) [#7]
It is in the manual, lol.


Wiebo(Posted 2005) [#8]
Yeah. Somewhere. Buried in a place you least expect it to. sigh. I've spend half an hour trying to find the escape characters, only to find they are in.... now, where did i find them? I forgot, damnit.


skn3(Posted 2005) [#9]
http://www.blitzbasic.com/Community/posts.php?topic=43346

The module has advanced since :)