|
The question and topic I want to ask is...
How can I interface my VC++ application with a VB application so that I can pass data between the two?
I have looked at some concepts like DLLs, COM, COM+, DCOM, ATL, ... but all text that I skimmed at the local bookstore have left me puzzled and said a lot without saying anything.
Specifically, I have a list class in my VC++ application that contains a linked list of data elements. I want to be able to pass this to my VB application so that I can do work on this data in VB (display, manipulate, "rewrite the list"). While in VB application, I will probably work with the data in an array structure. Then, send a modified version of the data back to my VC++ application so that it can work with the data as if it were in its original state (linked list with new links.)
Could someone please point me to what I should read/study or the topic under which this interfacing falls under? Thanks for the answers and guidence in advance.
Johnny
|
|
|
|
|
I've worked a lot with VB - VC coupling, and I found two good ways to interoperate:
1) Make a COM bridge for every C++ class you want to use from VB. You can do it pretty nice with ATL, but of course, you can use "bare bone" COM, if you wish.
2) For every C++ class, make a corresponding VB class, and make a DLL that will "glue" them. In every VB class you will have a long private member that will hold the memory address of the corresponding C++ class.
If I were you, I would take the first route, although the second one also works fine.
I vote pro drink
|
|
|
|
|
I don't know anything about VB, and I don't know what versions of Windows you need to support.
But, I have made a lot of communication between programs using Named Pipes.
The "server" (listening) application needs Windows NT/2000/XP, so I don't know if you can use that...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I can trade help if you like..
I can solve this for you if you can solve my question
email me if you are interested
|
|
|
|
|
Hi fellas!
I have a technical questiom:
Does Windows NT 4 support SSE instructions? and if it originally does not from which SoftWare pack it supports SSE instructions.
Thanks in Advance
Damon
|
|
|
|
|
I'm having a very bizarre problem with a Visual C++ program I'm working on. The program seems to crash with an access violation when one of 3 certain string variables are accessed. I know it's 3 because for some reason switching the order of the variable declaration seems to switch the crash to one of the other 2 variables. I have no idea why this is happening or what do do about it. It just started all of the sudden in a part of the code I hadn't even changed. It only happens in Debug mode, only on my machine, and only with this project(I've never seen this before in any other project). I've since upgraded my RAM by 128MBs and reinstalled Visual C++ 6. This didn't fix the problem. Has anyone else ever encountered this before? How did you fix it?
Why not throw away a dime,
I throw away ten pennies all the time...
|
|
|
|
|
Hi Kevin,
The program seems to crash with an access violation when one of 3 certain string
variables are accessed. I know it's 3 because for some reason switching the order of
the variable declaration seems to switch the crash to one of the other 2 variables
How about posting some code.
It is Illogical to define an inventor by his invention
|
|
|
|
|
That just screams stack corruption. Are all your stack arrays large enough? Are you passing in a variable by pointer when it shouldn't be (type checking usually catches this unless you have to cast to (void **) with such things as QueryInterface.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Do you have multithreading client/server code that you can give to me?
I need example code! because I think its to big for you to explain it here and now!
/*
BETA
*/
|
|
|
|
|
see
http://www.codeproject.com/internet/chessserver.asp
It is Illogical to define an inventor by his invention
|
|
|
|
|
Hello,
I am trying to establish a connection and I think I am missing something very basic. I get an "Invalid Pointer" error when the Open() is called. I am importing msado15.dll in StdAfx.h which is included in the file that contains the code below.
My code:
_ConnectionPtr pConn;
HRESULT hr;
try{
hr = pConn.CreateInstance(__uuidof(Connection));
_bstr_t bstrDSN = "DSN=test_db;UID=gstewart;PWD=gstewart";
pConn->Open(bstrDSN,"","", -1);
}
catch (_com_error e){
MessageBox(e.ErrorMessage());
}
|
|
|
|
|
try catch (_com_error &e)
|
|
|
|
|
The catch block shouldn't be executing in the first place. For some reason my connection pointer isn't valid after
hr = pConn.CreateInstance(__uuidof(Connection));
is executed. Any ideas what I'm missing? I think I'm missing a header file or something. It comiles just fine though....????
|
|
|
|
|
This is the code I use to create an ADO connection, the only difference I can see is that I pass cast my empty strings to _bstr_t first.
Are you getting a compile error or a runtime error
_ConnectionPtr m_pConnection
HRESULT CAdoConnection::Connect(std::string sConnectionStr)
{
HRESULT hr = S_OK;
try
{
hr = m_pConnection.CreateInstance(__uuidof(Connection));
if(hr == S_OK)
{
hr = m_pConnection->Open(_bstr_t(sConnectionStr.data()), _bstr_t(""), _bstr_t(""), adConnectUnspecified);
}
}
catch (_com_error &e)
{
}
return hr;
}
Michael
|
|
|
|
|
Michael,
I tried the casting and also added the adConnectUnspecified argument. My error occurs at runtime on the Open(...).
Thanks,
Glen
|
|
|
|
|
What error number does the try and catch get for the open?
Michael
|
|
|
|
|
After hr = pConn.CreateInstance(__uuidof(Connection));
the value of hr is -2147221008. I can't seem to get anything more from the _com_error object that is thrown except that the errormessage says "Invalid Pointer". I wonder if there could be something wrong with my compile options?
|
|
|
|
|
Did you use the CoInitialize()?
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Hi,
I have an SDI application that uses a CFormView. I have a third party graphics ActiveX control on the CFormView. I need to be able to scroll the CFormView because I want to make the ActiveX control bigger than the viewable area. Can someone help me with the steps to be able to scroll a CFormView?
Thanks for any help you can provide,
Craig
|
|
|
|
|
Use CScrollView::ScrollToPosition. CFormView is derived from CScrollView.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz, thanks for the response. I'm trying to rubberband the image and I have a callback function that get's this message. Once I get this message, I find out the size of the zoomed view, if it's bigger than the current client area I need to use the scrollbars. Currently, I can't figure out how to make the scroll bars show up. If I try CSrollView::ScrollToPosition it throws an exception because there aren't any scroll bars visible.
Do you know how I can make the scroll bars show up?
Thanks again,
Craig
|
|
|
|
|
|
That's excellent, thanks again for all your help.
Have a great day,
Craig
|
|
|
|
|
Hi, I have a Home-Made control who post a message. This control can be placed anywhere. All of this stuff run very well but something is not like I wan't it to be and it's the first time I use Message queuing
void MyHomeMadeControl::AMethod(void)
{
PostMessage(GetParent(),
(UINT)this,
(long)&m_Var);
}
class CBoopView : public CView
{
//some stuff
MyHomeMadeControl m_Ctrl_1;
MyHomeMadeControl m_Ctrl_2;
//everything else
}
void CBoopView::OnZoomScroll(MyHomeMadeControl* WParam,MyHomeMadeParam* lParam)
{
if(&m_Ctrl_1 == WParam)
{
}
else
{
}
}
I don't think it's a very good way to do so...
It is possible in my PostMessage to do something like
PostMessage(GetParent(),
GetCurrentId(),
(long)&m_Var);
so that way I will used Id number instead of pointers...
thanks
(by the way if there is a "standart way to identify the Object who Post the message tell me)
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
Wrong, wrong, wrong. You're trying to use a parent window pointer as message identifier. This will not work.
#define WM_MY_MESSAGE (WM_USER + 1)
...
GetParent()->PostMessage(WM_MY_MESSAGE, someWparam, someLparam);
You can pass object pointer as wParam or lParam, as long as window that's going to process the message is in the same process. In your case it's true. There's another caveat: PostMessage places message in the queue. Receiving window will not get this message immediately - and depending on application, the object that you passed as message parameter may no longer exist. In such case, use SendMessage instead of PostMessage.
One final note: when you are using your controls only within this program, you may establish communication between windows without messages. Just cast the pointer returned by GetParent() to correct type and call whatever method you need:
CBoopView *pView = (CBoopView*)GetParent();
pView->Foo(param1, param2, param3);
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|