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
Hi,

You can use forms internally in the VB ActiveX and pass input to VC++.
Working with ActiveX which display forms is just the same as with any VB
ActiveX.

WBR,
Igor


Quote:
> 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
Dear WBR,Igor

    I do such steps.
1 Make a VB exe project.
2 Use form and run it.
3 Make a vb activex dll project.
4 Add the form in project
5 Add inport function which load form .
6 Compile as dll
7 Use it in a vc project.

But it did not work ,why ?
Can you give me some sample?
Thank you very much

                                yours liu

Quote:

>You can use forms internally in the VB ActiveX and pass input to VC++.
>Working with ActiveX which display forms is just the same as with any VB
>ActiveX.

>WBR,
>Igor



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

Quote:

>But it did not work ,why ?
>Can you give me some sample?
>Thank you very much

Are you trying to show the form non-modal?

You can't do that from a VB app. Show the
form modally.



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

Quote:

>Are you trying to show the form non-modal?

>You can't do that from a VB app. Show the
>form modally.

Make that "VC app". A VB app can do it.
It's technically possible, but it isn't documented,
and so far no one seems to know how.


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

    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:

>Make that "VC app". A VB app can do it.
>It's technically possible, but it isn't documented,
>and so far no one seems to know how.



Mon, 08 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

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
> BSTR bstrDesc;
> BSTR aaa;
>char cFile[256];

> aaa=(char*)&cFile;

OK, this is a problem to start, You are not permitted
to cast a char array to a BSTR; BSTR are allocated by
calling one of the SysAllocXxxx functions. Check the
documentation.

Quote:
> 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"

This causes a problem. In order to assign a value to the BSTR,
VB is first calling SysFreeString, which doesn't work because
you never properly allocated it, then reallocating the string using
SysAllocString.

Now sourceFile points to a whole new location. If you want to
receive the value of the string back in C++, you'll have to pass
it ByRef, and send &aaa in the call.

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

If you expect VB to have the identical address for the string
pass the address of the BSTR (allocated properly), and
accept it ByRef in VB.

Get this from Microsoft:

http://support.microsoft.com/download/support/mslfiles/Vb4dll.exe

Its a self extracting archive sontaining the details on using
C++ with VB.



Mon, 08 Jul 2002 03:00:00 GMT  
 
 [ 8 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