[cairo] Cario in Visual Basic

Daniel Amelang daniel.amelang at gmail.com
Wed Dec 13 12:22:50 PST 2006


On 12/13/06, Jelmer Baas <Baas at speerit.nl> wrote:
> Daniel,
>
> Thanks for your reply.
> ...
> No, I downloaded it from
> http://gladewin32.sourceforge.net/modules/news/, which is the link from
> the cairo site (which is, on a side note, a great place to get lost ...)

Yea, the site is actually a wiki, so feel free to step in and fix
whatever got you lost :)

Either way, what I said about the first dll goes for the one you
downloaded too. They may have minor differences, but they both get you
just vanilla C cairo functions on windows.

> My idea is to write a simple module which gives a VB programmer access
> to all the functions. Shouldn't be that hard, just a lot of work.

I see, so you're basically planning to convert cairo.h into a bunch of
VB declare statements, right? This makes it easier for you to create
the glue code, but more awkward to actually use from within VB
(compared to creating an ActiveX layer). Just want to emphasize the
tradeoffs.

>
> Only thing I haven't figured out is how to create the "cairo_t" object
> in VB ... Oh, and ofcourse try to understand the LGPL license, which is
> even harder for me...

Well, for certain structures, you'll have to use the VB Type construct
to make them "visible" to VB. But cairo_t is only passed around as a
pointer, so you don't have to even do that for cairo_t. Probably the
best thing for you to do now is to spend some time learning about C
dll - VB interoperation. There are tutorials and books you can find
about it (usually focusing on interop with Win32 functions and
structures, but it's all the same). Start by just trying to call
something simple, like cairo_version_string and popping up a MsgBox
with the result. Then, you can advance to calling
cairo_win32_surface_create, passing in the HDC of your VB form. Once
you're done that, you're just a couple steps away from drawing. Should
be pretty exciting once you get it working :)

About the LGPL, look over the wikipedia article on it, and feel free
to ask specific questions here describing how you expect to
use/distribute what you're working on. But I wouldn't worry too much
about it, as unless you plan to modify cairo, or distribute your own
cairo dll, then there's nothing to be concerned about.

Good luck, and keep us posted!

Dan


More information about the cairo mailing list