有时候在c++调用wpf控件的时候,wpf控件想自己显示窗体,但需要设置owner属性.迂回解决办法是设置wpf的window窗体的父窗体为进程的句柄. 1.获取当前进程id int id = Process.GetCurrentProcess().Id; 2.根据进程id获取进程主句柄 public static class ProcessHelper { private static class Win32 { internal const uint GwOwner = 4; interna
原文:WPF 获取鼠标屏幕位置.窗口位置.控件位置 public struct POINT { public int X; public int Y; public POINT(int x, int y) { this.X = x; this.Y = y; } } [DllImport("user32.dll")] public static extern bool GetCursorPos(out POINT lpPoint); //e.GetPosition(this); //(e
子窗体(Win_Set): MainWindow m; m = (MainWindow)this.Owner; m.showText("获取文件成功\r\n"); 主窗体(MainWindow): Win_Set ws= new Win_Set(); ws.Owner = this; ws.Show(); 要调用的函数: public void sho