C++语法翻译成c#的 c++c# 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GetHQExeHWND应该是自定义的,应该是获取一个exe的句柄,你可以通过api的findwindow找到SetWindowPos是api函数,设置窗口位置GetClientRect也是api函数,你通过dllimport引入dll就行了 我写了如下 private const uint WM_USER = 0x0400; private const uint WM_CODE_CHANGE = WM_USER + 100; [DllImport("RecvDll.dll",EntryPoint="GetHQExeHWND",CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr GetHQExeHWND(); [DllImport("RecvDll.dll", EntryPoint = "Stock_Quit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] private static extern int Stock_Quit(IntPtr hWnd); [DllImport("RecvDll.dll", EntryPoint = "Stock_Init", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] private static extern int Stock_Init(IntPtr hWnd, uint uMsg, string pszExePath);[DllImport("user32.dll")] public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", EntryPoint = "SetWindowPos")] public static extern int SetWindowPos( int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags ); uint uMsg = WM_USER + 100;private void button1_Click(object sender, EventArgs e) { // int ret = Stock_Init(this.Handle, uMsg, "经易贵金属行情分析系统"); if (ret == 1) { IntPtr hWndChild = GetHQExeHWND(); IntPtr hWndNewParent = panel1.Handle; SetWindowPos((int)hWndChild, 0, panel1.ClientRectangle.X, panel1.ClientRectangle.Y, panel1.Width, panel1.Height, 0); SetParent(hWndChild, hWndNewParent); SetWindowPos((int)hWndChild, 0, panel1.ClientRectangle.X, panel1.ClientRectangle.Y, panel1.Width, panel1.Height, 0); //SetWindowPos((int)hWndChild, 0, panel1.ClientRectangle.X, panel1.ClientRectangle.Y, panel1.Width, panel1.Height, 0); //panel1.Controls.Add(); MessageBox.Show("成功加载咯!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }但是问题在于红色字体部分完全不起作用啊! 另外的疑问是,c++写的嵌入exe的程序在win7下运行的时候不提示安全警告,但是c#编写的嵌入exe的程序打开就收到组策略的影响,提示安全警告,打开文件安全警告对话框,如何解决?! 控制台背景色 设置 .NET版本支持的操作系统 求一正则表达式,在线等 原来能运行得代码突然不能运行了,请教(在线等待) 给软件添加序列号的功能的实现? dataview赋值的疑惑! 打开一个新窗口的语句 读取access数据库中的ole对象 怎么能删除字符串中重复的空格阿 C# 将xml文件导入sql数据库表中 winform用串口对MC52i的操作连接成功之后为什么打开连接通道总是返回错误 一个DataGridViewLinkColumn单元格里可以有2个Link吗?
SetWindowPos是api函数,设置窗口位置
GetClientRect也是api函数,
你通过dllimport引入dll就行了
private const uint WM_USER = 0x0400;
private const uint WM_CODE_CHANGE = WM_USER + 100; [DllImport("RecvDll.dll",EntryPoint="GetHQExeHWND",CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
private static extern IntPtr GetHQExeHWND(); [DllImport("RecvDll.dll", EntryPoint = "Stock_Quit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
private static extern int Stock_Quit(IntPtr hWnd); [DllImport("RecvDll.dll", EntryPoint = "Stock_Init", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
private static extern int Stock_Init(IntPtr hWnd, uint uMsg, string pszExePath);[DllImport("user32.dll")]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern int SetWindowPos(
int hwnd,
int hWndInsertAfter,
int x,
int y,
int cx,
int cy,
int wFlags
);
uint uMsg = WM_USER + 100;
private void button1_Click(object sender, EventArgs e)
{
//
int ret = Stock_Init(this.Handle, uMsg, "经易贵金属行情分析系统");
if (ret == 1)
{
IntPtr hWndChild = GetHQExeHWND();
IntPtr hWndNewParent = panel1.Handle;
SetWindowPos((int)hWndChild, 0, panel1.ClientRectangle.X, panel1.ClientRectangle.Y, panel1.Width, panel1.Height, 0);
SetParent(hWndChild, hWndNewParent);
SetWindowPos((int)hWndChild, 0, panel1.ClientRectangle.X, panel1.ClientRectangle.Y, panel1.Width, panel1.Height, 0);
//SetWindowPos((int)hWndChild, 0, panel1.ClientRectangle.X, panel1.ClientRectangle.Y, panel1.Width, panel1.Height, 0); //panel1.Controls.Add();
MessageBox.Show("成功加载咯!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
但是问题在于红色字体部分完全不起作用啊!