• 大小: 151KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-12
  • 语言: C#
  • 标签: Winform  WPF  

资源简介

Winform窗体嵌入WPF程序并发送消息

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.Diagnostics;
using System.Windows.Forms;

namespace WindowsFormsDemo
{
    public class AppContainer
    {
        #region 注册API函数
        [DllImport(“user32.dll“ EntryPoint = “GetWindowThreadProcessId“ SetLastError = true
             CharSet = CharSet.Unicode ExactSpelling = true CallingConvention = CallingConvention.StdCall)]
        private static extern long GetWindowThreadProcessId(long hWnd long lpdwProcessId);
        [DllImport(“user32.dll“)]
        private static extern IntPtr FindWindow(string lpClassName string lpWindowName);
        [DllImport(“user32.dll“ SetLastError = true)]
        public static extern IntPtr SetParent(IntPtr hWndChild IntPtr hWndNewParent);
        [DllImport(“user32.dll“ EntryPoint = “GetWindowLongA“ SetLastError = true)]
        private static extern long GetWindowLong(IntPtr hwnd int nIndex);
        [DllImport(“user32.dll“ EntryPoint = “SetWindowLong“ CharSet = CharSet.Auto)]
        private static extern IntPtr SetWindowLongPtr32(HandleRef hWnd int nIndex int dwNewLong);
        [DllImport(“user32.dll“ EntryPoint = “SetWindowLongPtr“ CharSet = CharSet.Auto)]
        internal static extern IntPtr SetWindowLongPtr64(HandleRef hWnd int nIndex int dwNewLong);
        [DllImport(“user32.dll“ SetLastError = true)]
        private static extern long SetWindowPos(IntPtr hwnd long hWndInsertAfter long x long y long cx long cy long wFlags);
        [DllImport(“user32.dll“ SetLastError = true)]
        private static extern bool MoveWindow(IntPtr hwnd int x int y int cx int cy bool repaint);
        [DllImport(“user32.dll“ EntryPoint = “PostMessageA“ SetLastError = true)]
        private static extern bool PostMessage(IntPtr hwnd uint Msg uint wParam uint lParam);
        [DllImport(“user32.dll“ SetLastError = true)]
        private static extern IntPtr GetParent(IntPtr hwnd);
        [DllImport(“user32.dll“ EntryPoint = “ShowWindow“ SetLastError = true)]
        static extern bool ShowWindow(IntPtr hWnd int nCmdShow);
        [DllImport(“user32.dll“)]
        private static extern int SendMessage(IntPtr hWnd uint Msg int wParam int lParam);



        private const int SWP_NOOWNERZORDER = 0x200;
        private const int SWP_NOREDRAW = 0x8;
        private const int SWP_NOZORDER = 0x4;
        private const int SWP_SHOWWINDOW = 0x0040;
        private const int WS_EX_MDICHILD = 0x40;
        private const int SWP_frameCHANGED = 0x20;
        private const int SWP_NOACTIVATE = 0x10;
        private const int SWP_ASYNCWINDOWPOS = 0x4000;
        private const int SWP_NOMOVE = 0x2;
        private const int SWP_NOSIZE = 0x1;
        private const int GWL_style = (-16);
        private const int WS_VISIBLE = 0x10000000;
        private const int WM_CLOSE = 0x10;
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-08-22 21:41  WindowsFormsDemo\
     目录           0  2016-08-19 22:33  WindowsFormsDemo\Bin\
     文件       12288  2016-08-19 23:32  WindowsFormsDemo\Bin\WindowsFormsDemo.exe
     文件       30208  2016-08-19 23:32  WindowsFormsDemo\Bin\WindowsFormsDemo.pdb
     文件       24224  2016-08-22 21:41  WindowsFormsDemo\Bin\WindowsFormsDemo.vshost.exe
     文件       12800  2016-08-22 22:15  WindowsFormsDemo\Bin\WpfApp.exe
     文件       40448  2016-08-22 22:15  WindowsFormsDemo\Bin\WpfApp.pdb
     文件       24224  2016-08-22 22:19  WindowsFormsDemo\Bin\WpfApp.vshost.exe
     文件         490  2015-10-30 15:19  WindowsFormsDemo\Bin\WpfApp.vshost.exe.manifest
     目录           0  2016-08-22 22:40  WindowsFormsDemo\WindowsFormsDemo\
     文件        5159  2016-08-19 21:50  WindowsFormsDemo\WindowsFormsDemo\AppContainer.cs
     文件        2060  2016-08-19 21:59  WindowsFormsDemo\WindowsFormsDemo\MainForm.Designer.cs
     文件        4196  2016-08-22 22:40  WindowsFormsDemo\WindowsFormsDemo\MainForm.cs
     文件        5817  2016-08-19 21:59  WindowsFormsDemo\WindowsFormsDemo\MainForm.resx
     文件         500  2016-08-19 21:21  WindowsFormsDemo\WindowsFormsDemo\Program.cs
     目录           0  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\Properties\
     文件        1364  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\Properties\AssemblyInfo.cs
     文件        2884  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\Properties\Resources.Designer.cs
     文件        5612  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\Properties\Resources.resx
     文件        1103  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\Properties\Settings.Designer.cs
     文件         249  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\Properties\Settings.settings
     文件        3830  2016-08-19 22:02  WindowsFormsDemo\WindowsFormsDemo\WindowsFormsDemo.csproj
     目录           0  2016-08-19 21:21  WindowsFormsDemo\WindowsFormsDemo\bin\
     目录           0  2016-08-19 22:02  WindowsFormsDemo\WindowsFormsDemo\bin\Debug\
     文件         490  2015-10-30 15:19  WindowsFormsDemo\WindowsFormsDemo\bin\Debug\WindowsFormsDemo.vshost.exe.manifest
     目录           0  2016-08-22 22:40  WindowsFormsDemo\WindowsFormsDemo\bin\Release\
     目录           0  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\obj\
     目录           0  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\obj\x86\
     目录           0  2016-08-19 23:32  WindowsFormsDemo\WindowsFormsDemo\obj\x86\Debug\
     文件        2867  2016-08-19 21:20  WindowsFormsDemo\WindowsFormsDemo\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7021  2016-08-22 21:41  WindowsFormsDemo\WindowsFormsDemo\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
............此处省略54个文件信息

评论

共有 条评论