how to use a VB active dll which include Form at a c++ program 
Author Message
 how to use a VB active dll which include Form at a c++ program

hi ,everyone

    I want to make a project which is use c and vc++.
But the is a lots of parameter should be input.I want
to use VB to get the parameter and make a beautiful
visible.But I do not know how to use a VB active dll which include Form at a
c++ program.Some of body tell
me that vc can not use form because form is a special
varible only in VB.Can I use it?

    Please help me.

                                           yours liu



Fri, 05 Jul 2002 03:00:00 GMT  
 how to use a VB active dll which include Form at a c++ program
Liu,

Quote:
>     I want to make a project which is use c and vc++.
> But the is a lots of parameter should be input.I want
> to use VB to get the parameter and make a beautiful
> visible.But I do not know how to use a VB active dll which include Form at
a
> c++ program.Some of body tell
> me that vc can not use form because form is a special
> varible only in VB.Can I use it?

You can use the dll as long as the from is modal (nonmodal forms won't
work). As for how to use it, just use it like a normal COM inproc server
(i.e. read up on #import).

--
Tomas Restrepo
http://members.xoom.com/trestrep/



Fri, 05 Jul 2002 03:00:00 GMT  
 how to use a VB active dll which include Form at a c++ program
Dear Tomas Restrepo:

    I am a new user of vb, I make the dll function
as this

Function ParameterInput(x As Integer) As Integer
    frmMain.Show vbModal, Me
End Function

but it can not work .I load it at vc project,
There is a error message tell me that the
form can not use.Can you tell me how to do it ,
or give me a sample?

    thanks for your help.

                                          yours liu

Quote:
>You can use the dll as long as the from is modal (nonmodal forms won't
>work). As for how to use it, just use it like a normal COM inproc server
>(i.e. read up on #import).

>http://members.xoom.com/trestrep/



Sun, 07 Jul 2002 03:00:00 GMT  
 how to use a VB active dll which include Form at a c++ program
You are right . I make a mistake .
But there is an other question.
Do you know how to get a string parameter
from a vb activeX dll.I use this  code in vc

 short  bitInt,misInt;
 int st1;
 BSTR bstrDesc;
 BSTR aaa;
char cFile[256];

 aaa=(char*)&cFile;
 sourceFile= (LPCTSTR)(&sFile);
 comparedFile= (LPCTSTR)(&cFile);
 try
 {
  CoInitialize(NULL);
  _ParameterInputPtr ptr;
 ptr.CreateInstance(_uuidof(ParameterInput));
 st1 = ptr->ParameterInput(aaa,&bitInt,&misInt);
 }
 catch(_com_error &e)
 {
  bstrDesc = e.Description();
 }
CoUninitialize();

the fuction in vb is write as

Public Function ParameterInput(ByVal sourceFile As String, bitInt As
Integer, misInt As Integer) As Long
    sourceFile = "aaaa"
    bitInt = 1
    misInt = 2
    ParameterInput = 3
End Function

but get a wrong address ,where did I make a mistake?
thank you very much.

                                                  your liu



Mon, 08 Jul 2002 03:00:00 GMT  
 how to use a VB active dll which include Form at a c++ program
Liuszhen,

Quote:
> You are right . I make a mistake .
> But there is an other question.
> Do you know how to get a string parameter
> from a vb activeX dll.I use this  code in vc

>  short  bitInt,misInt;
>  int st1;
>  BSTR bstrDesc;
>  BSTR aaa;
> char cFile[256];

>  aaa=(char*)&cFile;
>  sourceFile= (LPCTSTR)(&sFile);
>  comparedFile= (LPCTSTR)(&cFile);
>  try
>  {
>   CoInitialize(NULL);
>   _ParameterInputPtr ptr;
>  ptr.CreateInstance(_uuidof(ParameterInput));
>  st1 = ptr->ParameterInput(aaa,&bitInt,&misInt);
>  }
>  catch(_com_error &e)
>  {
>   bstrDesc = e.Description();
>  }
> CoUninitialize();

> the fuction in vb is write as

> Public Function ParameterInput(ByVal sourceFile As String, bitInt As
> Integer, misInt As Integer) As Long
>     sourceFile = "aaaa"
>     bitInt = 1
>     misInt = 2
>     ParameterInput = 3
> End Function

> but get a wrong address ,where did I make a mistake?

Several things
1- You can't create a BSTR by simply casting as you are doing now.  BSTRs
have to be allocated and deallocated using SysAllocString() and
SysFreeString() and related functions.
2- If you want to change the value of sourceFile in your VB code, and
retrieve it from yout VC++ code, I think you should declare it ByRef, not
ByVal (but I'm not of  VB guy, so I might be wrong).
3- The line aaa = (char*)&cFIle; is obviously incorrect, as you are taking
the address of the variable itself, not the address the array is stored at.
3- You are doing too many ugly casts  in your C++ code, trying to get things
to compile. Most of them are incorrect, and other will simply break if you
try to compile your code for uincode.

--
Tomas Restrepo
http://members.xoom.com/trestrep/



Mon, 08 Jul 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. how to use a VB active dll which include Form at a c++ program

2. Using a VB Active X DLL's functions in C++

3. Show modeless form in VB ActiveX DLL from C++ MFC DLL

4. HELP: Identifying DLLs used by a program to include in a Setup.Exe program

5. Calling an VB Active X DLL from a C++ executable

6. call a VB COM dll thru a C++ COM dll from a C program

7. call a VB COM dll thru a C++ COM dll from a C program

8. Using NON-VB-Controls in a vb form ?

9. Using NON-VB-Controls in a vb form ?

10. Debugging a DLL using a VB program

11. Using VB-created Activex DLLs in a VC program

12. Mixed language programming DLL , C++, VB/VBA, Fortran

 

 
Powered by phpBB® Forum Software