Hi efgee,
I think this problem is specific to class libraries. I was able to use MessageBox within normal DLL
exported functions, but not classes. I am giving this area a thorough workout.
Charles
Hello Charles,
I'm still plugging along and trying different things with oxygen.
Here I changed the chatter.dll to utilize the MessageBox Win32 function (instead of the build in print function)
But it crashes#basic #file `chatter.dll` 'dim as long user32 = LoadLibrary "user32.dll" 'bind user32 ( ' MessageBox MessageBoxA : @16 ') declare function MessageBox lib `user32.dll` alias `MessageBoxA` (byval as long, byval as string, byval as string, byval as long) as long '------------------------------------- class greeting alias `greeting` export '===================================== method hello(n as string) method goodbye(n as string) / end class methods of greeting method hello(n as string) print ` Hello ` n end method method goodbye(n as string) dim txt as string txt = ` Goodbye ` 'print ` Good bye ` n MessageBox(0, n, txt, 0) end method end methods 'of greeting
Here the code to use the chatter.dll
Is this a limitation of oxygen's alpha state?#basic '------------------------------------------------ class greeting lib `chatter.dll` alias `greeting` '================================================ method hello(n as string) method goodbye(n as string) / end class dim g as greeting g.goodbye `moon` g.hello `earth` xit: terminate
Thanks
efgee
Hi efgee,
I think this problem is specific to class libraries. I was able to use MessageBox within normal DLL
exported functions, but not classes. I am giving this area a thorough workout.
Charles
The solution was to declare the class library as extern. I have tweaked the syntax to remove unnecessary flags / directives. (link below).
This pair should now work correctly. ThinBasic example in examples/OOP/ClassLibrary
[code=thinbasic]
'-------------
'CLASS LIBRARY
'=============
#basic
#file `chatter.dll`
extern
declare function MessageBox lib `user32.dll` alias `MessageBoxA` (byval as long,
byval as string, byval as string, byval as long) as long
'-------------------------------------
class greeting export 'alias "greeting" export
'=====================================
method hello(n as string)
method goodbye(n as string)
/
a as long
end class
methods of greeting
method hello(n as string)
print ` Hello ` n
end method
method goodbye(n as string)
messagebox 0,n,"Goodbye",0
end method
end methods 'of greeting
function foo (n as string) export
messagebox 0,n,"ms",0
end function
end extern
[/code]
[code=thinbasic]
#basic
extern lib "chatter.dll"
'------------------------------
class greeting 'alias "greeting"
'==============================
method hello(n as string)
method goodbye(n as string)
/
a as long
end class
declare function foo(n as string)
end extern
dim g as greeting
g.goodbye `moon`
g.hello `earth`
foo "Hi"
[/code]
Latest Oxygen
http://community.thinbasic.com/index.php?topic=2517
Charles,
works fine now.
Thank you for your fast response
efgee
Bookmarks