Using an OCX file in a C++ project?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Obsidian
Posts: 17
Joined: Fri Feb 17, 2006 10:42 pm

Using an OCX file in a C++ project?

Post by Obsidian »

Alright, is it possible to use an OSX file created in VB, in a C++ program (if the program was designed to run on Linux)? I've been searching google, but i can't find a straight answer.

Basically, what i'm looking at is using a socket that is already written instead of rewriting it myself, but i don't know if you can include them in C++ projects or not.


I also have another quick question while i'm on subject (another VB thing). What would a line like this is VB6 translate to in C++?

Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Stuff like that, i have an old VB project that i want to convert over to C++, and i want to use irrlicht to do the openGL stuff, but i'm hitting some snags in those areas for right now...


[Edit]
One last VB to C++ question. In VB, there were a lot of instances of things like...

Variable(1 To WHATEVER) As SOMETHING

What is the way to do the same thing with C++? Is that not just an array? would it look like...

SOMETHING Variable[WHATEVER];

?
Legality is a horrible barometer for morality.
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

function declaration:
You just need the right header files telling the compiler how those functions "look" (so it's basically the same but without naming the dll file). The linker later on uses the dll's lib file to "link" to it.
VB does runtime linking only - something you can do using "LoadLibrary()" etc.

Don't think it's that easy to use OCX files (it should be possible to include your own activex server etc. but the work to do it... :P ) but most of those interfaces are also available as dll files or even plain c/c++ (i.e. microsofts internet controls as "urlmon.h"). And using them on linux? Agh think best solution is to redo the controls/libs or search for alternatives. :)

For things like keyboard input etc. irrlicht has its own classes so you won't need to call any API functions yourself.


VB: NAME(scope) As TYPE
C/C++: TYPE NAME[scope];
(The lower bound is always zero using the default arrays.)
Depending on your TYPE it may be better to use an array of pointers etc. Especially for things you'd have to use "SET" and "NEW" in VB (objects, etc.).

I'd suggest you first try to get some c/c++ tutorial and/or book (think there are even those specifically designed for those switching from vb to c) and convert your program later on.
Obsidian
Posts: 17
Joined: Fri Feb 17, 2006 10:42 pm

Post by Obsidian »

Thanks for the info. My question though, about the scopes of arrays, was not how to declare arrays. But more of how you would translate the scopes themselves.

if you have (2 to 100) (in visual basic), how does that translate to c++? is the word 'to' still understood by the ide/compilier?
Legality is a horrible barometer for morality.
JonLT
Posts: 152
Joined: Thu Mar 15, 2007 5:47 pm
Location: Denmark

Post by JonLT »

sorry, misunderstood (removed to post)
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

Basic arrays in C/C++ always start at index 0.

VB: DIM myarray(2 to 10) as Integer

C (alternative 1):
int myarray[10];
then only using indizes 2 - 10

C (alternative 2):
int myarray[8];
then using indizes 0 - 8

There is no "to" however you can define multidimensional arrays where you access whole columns or rows at once - something afaik not possible in VB. ;)
int myarray[10][10][10]);
Then calling i.e.
myarray[2][3] to get all 10 elements (last index) at once.

Just make sure you have enough free stack space to hold the array or create it on the heap using new or malloc(). ( Ignore this as long as you don't have more than some thousand items :) )
Obsidian
Posts: 17
Joined: Fri Feb 17, 2006 10:42 pm

Post by Obsidian »

Okay, that's what i thought. I thought i'd just have to just adjust since it didn't have a way of setting scope sizes up like that. Thanks for all the help.
Legality is a horrible barometer for morality.
Post Reply