设置组件的一个属性,比如pen,本来是LOGPEN,应该改用那一种数据类型啊?
解决方案 »
- WinXP: Win32MFC程序,VS2005 CEdit不能多行显示问题
- 问个简单的问题: term does not evaluate to a function taking 1
- winsocket 获得客户端IP
- SDI问题, 如何在菜单与标题栏之间插入一个图片?
- 头次使用Timer,在设置Timer时,程序提示"没有找到重载的成员函数"是怎么回事
- 程序开始时候的线程数量
- VC 7.0的问题
- 为什么installshield中的scripts中的SetupFolders函数有错?
- 小虾米求教——怎样截获并删除消息?????急----在线等待(可再加分)
- vc采用LSP重定向问题,只有IE成功,为什么?
- Debug下一切正常,Release下程序异常结束.(sscanf的问题)(在线等待)
- 线程与定时器问题
CreateFontIndirect里的那个lpLogPen?你传结构的指针吧。
是这样的
我有一个已经存在的类,现在要为它加上COM接口
这样就要写接口函数
其中有一个函数是SetPen(LOGPEN &logpen),要把它写成COM接口,作为参数的LOGPEN应该用哪一种自动化数据类型代替?我有一种想法,就是SetPen(IDispatch*pObj),但是不知道把一个LOGPEN形式的结构体怎么封装成COM组件,这样行的通吗?如下:
Class CPenObj:public CCmdTarget
{
...............
public:
LOGPEN m_logpen;
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(ATOM_DATA)
afx_msg void SetlopnWidth(long newValue);
afx_msg long GetlopnWidth();
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
}在CPP中:
void CPenObj::SetlopnWidth(long newValue)
{
m_logpen.lopnWidth = newValue;
}
long CPenObj::GetlopnWidth()
{
return m_logpen.lopnWidth;
}
请大家指正!谢谢
void CMyIeDlg::putArrays()
{
HRESULT hr;
SAFEARRAY* psaStudent = NULL;
SAFEARRAYBOUND rgbounds = { 4, 0 };
studentsInfo *pStudentStruct = NULL; psaStudent = SafeArrayCreate(VT_VARIANT, 1, &rgbounds);
hr = SafeArrayAccessData(psaStudent, reinterpret_cast<PVOID*>(&pStudentStruct)); pStudentStruct[0].grade = 3;
pStudentStruct[0].name = SysAllocString(L"Shaun");
pStudentStruct[0].type = class_Clown;
pStudentStruct[1].grade = 8;
pStudentStruct[1].name = SysAllocString(L"Fred");
pStudentStruct[1].type = school_Bully;
pStudentStruct[2].grade = 12;
pStudentStruct[2].name = SysAllocString(L"Steve");
pStudentStruct[2].type = teachers_Favorite;
pStudentStruct[3].grade = 3;
pStudentStruct[3].name = SysAllocString(L"Linda");
pStudentStruct[3].type = teachers_Favorite; hr = SafeArrayUnaccessData(psaStudent);
m_array.vt = VT_ARRAY;
m_array.parray = psaStudent;}void CMyIeDlg::getArrays()
{
HRESULT hr;
SAFEARRAY* psaStudent = NULL;
studentsInfo *pStudentStruct = NULL;
studentsInfo students[4]; psaStudent = m_array.parray;
hr = SafeArrayAccessData(psaStudent, reinterpret_cast<PVOID*>(&pStudentStruct));
for(int i = 0; i<4;i++)
{
students[i].grade = pStudentStruct[i].grade ;
students[i].name = pStudentStruct[i].name ;
students[i].type = pStudentStruct[i].type ;
}
hr = SafeArrayUnaccessData(psaStudent);
}
我的接口最终要被用户用VBSCript语言调用,如果他要调用SetPen(arrays),他也不知道这个参数要怎么写啊,因为arrays是我内部的数组,除非也用COM封装,否则无法暴露给用户:(~~
VBScript中用Split等函数返回数组就可以了.