Click here to Skip to main content
16,017,037 members
Home / Discussions / COM
   

COM

 
GeneralRe: MIDL Compiler problem Pin
geo_m26-May-03 7:55
geo_m26-May-03 7:55 
GeneralRe: MIDL Compiler problem Pin
J. Dunlap26-May-03 8:32
J. Dunlap26-May-03 8:32 
QuestionError code 0x80010005 mean what and how to avoid it? Pin
i--19-May-03 22:07
i--19-May-03 22:07 
AnswerRe: Error code 0x80010005 mean what and how to avoid it? Pin
Anonymous27-May-03 22:19
Anonymous27-May-03 22:19 
Generalcreation of client of an EXE Com server . Pin
satishsilla19-May-03 18:14
satishsilla19-May-03 18:14 
GeneralRe: creation of client of an EXE Com server . Pin
valikac20-May-03 8:50
valikac20-May-03 8:50 
GeneralRe: creation of client of an EXE Com server . Pin
satishsilla21-May-03 23:34
satishsilla21-May-03 23:34 
GeneralProblems passing doubles in VB control to C++ Pin
mgreene16-May-03 2:43
mgreene16-May-03 2:43 
I created a simple activeX control in VB that has a single method that raises an event and passes back three params in the event. I have modded a c++ ATL client app that I found here (THANKS!) that processes the event. When the third event parameter is specified as type "SINGLE" in VB and float in c++, the printf works correctly (returns 302,429.0,460.0). When I change the third param to type "Double" in bothe the control and the C++ client, the values seem to be corrupted (302, -107374176.0, 5.6e-315) - even seems to corrupt the 2nd param (a single). Is there something different about passing doubles versus singles?

vb Code:
<br />
Public Event paramsback(ByVal x As Long, ByVal y As Single, ByVal z As Double)<br />
<br />
Public Sub PassItIn(ByVal x As Long, ByVal y As Single, ByVal z As Double)<br />
    <br />
    RaiseEvent paramsback(x, y, z)<br />
    <br />
End Sub<br />


C++ app:
<br />
#include "stdafx.h"<br />
#include <stdio.h><br />
<br />
// Importing the server's type library<br />
#import "ABIG_VBOCXTEST.ocx" no_namespace named_guids<br />
<br />
CComModule _Module;<br />
<br />
// Sink interface class. Using a reserved word "interface" instead of<br />
// "class" is purely more descriptive. Changing it to "class" won't<br />
// effect anything. The last two parameters are 1,0 - the server's<br />
// type library version.<br />
interface CSink:public IDispEventImpl<0, CSink, &DIID___mytestcontrol, &LIBID_ABIG_VBOCXTEST, 6, 0><br />
{<br />
public:<br />
<br />
// Where we pass 0x01 - is the ID of our event function,<br />
// can be anything, depending on the server implementation.<br />
BEGIN_SINK_MAP(CSink)<br />
	SINK_ENTRY_EX(0, DIID___mytestcontrol, 0x1, Onparamsback)<br />
END_SINK_MAP()<br />
<br />
// The only event handler we have. The standard of "HRESULT __stdcall"<br />
// is compulsory for the function to be treated correctly.<br />
	HRESULT __stdcall Onparamsback(long x, float y,double z)<br />
	{<br />
	   	printf("Event = %d,%6.2f,%6.2g",x,y,z);<br />
<br />
		return S_OK;<br />
	}<br />
};<br />
<br />
void main()<br />
{<br />
	// Entering primary STA<br />
	CoInitialize(NULL);<br />
<br />
	// Initializing ATL<br />
	_Module.Init(NULL, GetModuleHandle(NULL));<br />
<br />
	_mytestcontrolPtr server;<br />
	<br />
	// Creating an instance of the server<br />
	server.CreateInstance(CLSID_mytestcontrol);<br />
<br />
	CSink sink;<br />
	<br />
	// Connecting to the server's outgoing interface<br />
	sink.DispEventAdvise(server);<br />
<br />
	// Making the server fire the only event it has<br />
	server->PassItIn(302,429.0,460.0);<br />
<br />
	// Disconnecting from the server's outgoing interface<br />
	sink.DispEventUnadvise(server);<br />
	<br />
	// Releasing the server's instance<br />
	server.Release();<br />
<br />
	// These two invocations are optional, and will be called<br />
	// implicitly, if not specified. However, good manners<br />
	// suggest that they both be put in explicitly:<br />
	<br />
	// 1. Terminating ATL support<br />
	_Module.Term();<br />
	<br />
	// 2. Quitting primary STA<br />
	CoUninitialize();<br />
}<br />

stdafx.h:
<br />
// stdafx.h : include file for standard system include files,<br />
//  or project specific include files that are used frequently, but<br />
//      are changed infrequently<br />
//<br />
<br />
#if !defined(AFX_STDAFX_H__70227B2B_B9C9_4FC9_A100_2619AB307158__INCLUDED_)<br />
#define AFX_STDAFX_H__70227B2B_B9C9_4FC9_A100_2619AB307158__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#define _ATL_MAX_VARTYPES 16<br />
<br />
#include <atlbase.h><br />
//You may derive a class from CComModule and use it if you want to override<br />
//something, but do not change the name of _Module<br />
extern CComModule _Module;<br />
#include <atlcom.h><br />
<br />
// TODO: reference additional headers your program requires here<br />
<br />
//{{AFX_INSERT_LOCATION}}<br />
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.<br />
<br />
#endif // !defined(AFX_STDAFX_H__70227B2B_B9C9_4FC9_A100_2619AB307158__INCLUDED_)<br />


stdafx.cpp
<br />
#include "stdafx.h"<br />

General[Message Deleted] Pin
imdx8016-May-03 0:43
imdx8016-May-03 0:43 
GeneralRe: Connection Points and [out] parameters Pin
geo_m26-May-03 7:41
geo_m26-May-03 7:41 
GeneralCOM Client problem Pin
YSRao14-May-03 1:15
YSRao14-May-03 1:15 
GeneralRe: COM Client problem Pin
valikac14-May-03 8:27
valikac14-May-03 8:27 
GeneralRe: COM Client problem Pin
Anonymous14-May-03 19:07
Anonymous14-May-03 19:07 
GeneralRe: COM Client problem Pin
balcn14-May-03 8:51
balcn14-May-03 8:51 
GeneralRe: COM Client problem Pin
Anonymous14-May-03 18:42
Anonymous14-May-03 18:42 
GeneralRe: COM Client problem Pin
valikac14-May-03 19:55
valikac14-May-03 19:55 
GeneralRe: COM Client problem Pin
balcn16-May-03 8:05
balcn16-May-03 8:05 
GeneralRe: COM Client problem Pin
Dudi Avramov18-May-03 23:11
Dudi Avramov18-May-03 23:11 
GeneralHelp : About Active Document Pin
twinkle_star13-May-03 16:59
twinkle_star13-May-03 16:59 
QuestionDifference between Webbrowser contorl and InternetExplorer object ? Pin
GriffonRL13-May-03 3:51
GriffonRL13-May-03 3:51 
QuestionCan a method of COM-server return a string pointer Pin
Bash12-May-03 19:52
Bash12-May-03 19:52 
AnswerRe: Can a method of COM-server return a string pointer Pin
justanotherprogrammer12-May-03 21:13
justanotherprogrammer12-May-03 21:13 
GeneralRe: Can a method of COM-server return a string pointer Pin
valikac13-May-03 16:01
valikac13-May-03 16:01 
GeneralRe: Can a method of COM-server return a string pointer Pin
Renjith Ramachandran15-May-03 5:57
Renjith Ramachandran15-May-03 5:57 
Generalactivex parent Pin
Shotgun12-May-03 15:28
Shotgun12-May-03 15:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.