delphi 中 findwindow('c# childform Thandle');
好像可以。
找到句柄,不过你的C#子窗口要先实例化。
好像可以。
找到句柄,不过你的C#子窗口要先实例化。
解决方案 »
- wpf做的图片左右滑动效果 问题请教
- “应用”这个按钮功能如何实现,在线等
- winform中的动画显示。
- NAnt中如何判断soulution任务是否成功
- C# 获取键盘shift+鼠标滚轮事件
- WPF,为什么说PathGeometry不是元素呢?
- DataGrid(winform) 如何修改Header Text 的???
- 急急急--我在DataGrid1模板里面又放了一个DataGrid2,怎样响应DataGrid2的索引改变事件以及其他事件! (这是我第二次问这个问题了,问题
- 關於DataGrid數據導航問題
- [请教]数据访问层设计基础问题
- 字节的前位为224,是什么字符??
- 一个关于DataGridView控件的问题~~
2. 用C#创建DLL类库。 New->Project->Visual C#->Class Library
3. 定义一个接口IA,并且公开为COM接口。这个接口作为Delphi调用子画面的COM接口 Sample
[ComVisible(true)]
[Guid("51929553-A1A9-49cf-B438-FDFA16FABCA5")]
public interface IA
{ ....}
4. 定义一个接口IB,并且公开为COM接口。这个接口由Delphi主程序实现。
5. 根据需要增加画面,并且实现IA,可以通过IB接口访问主程序。
6. 注册COM组件
7. Delphi创建该COM对象实例,并且将IB实现类传递给子画面8. 主程序通过IA接口访问子画面
步骤1:首先用C#开发一个托管类:
namespace Test
{
public class ClassHello
{
public ClassHello()
{
return;
}
public string GetText()
{
return "Hello word";
}
}
}
-------------------------------------------------------------------------------- 步骤2:使用VC2005开发动态链接库:
1)选择新建MFC DLL;
2)在属性页中 属性配置->常规->公共运行语言库支持->公共语言运行库支持(/clr)
3)在属性页中 属性配置->常规->MFC使用->在共享 DLL 中使用 MFC
4)在此项目中引用 步骤1开发的C#项目
5)添加接口函数如下:
int WINAPI GetHello(wchar_t* r)
{
//声明托管类型
Test::ClassHello^ c=gcnew Tone::Class1();
//从托管类型中获取数据
CString s= c->GetText();
wcscpy(r,s.GetBuffer());
delete c;
return s.GetLength(); }
-------------------------------------------------------------------------------- 步骤3在delphi7中调用步骤2开发的dll
function GetHello(r:pwchar):integer ;stdcall;External 'VCTest.dll'; //声明
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
a:pWchar;
begin
try
getmem(a,256);
gets(a);
Application.MessageBox(a,'从C#中传来的",MB_OK);
freemem(a);
except end;
end; end.