软件开发小王 2020-08-27 19:24 采纳率: 0%
浏览 183

如何在MFC和Win32程序下调用WPF写的窗口弹窗(封成类库)

思路:想在WPF建一些好看的WPF窗口弹窗,然后在MFC和win32的程序中调用,要如何实现? 目前 Win32的属性配置中公共语言是使用CLR的方式 和 .NET 4.5.1 ,WPF和Win32引用 已经都相同了,就是报SAT线程错误,要如何解决这个问题??**。

WPF的属性

图片说明

WPF的引用

图片说明

WinErr.xaml

<Window x:Class="WinBox.View.WinErr1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WinBox.View"
        mc:Ignorable="d"
        Height="310" Width="508">
    <Grid>
    </Grid>
</Window>

WinErr1.xaml.cs

namespace WinBox.View
{
    /// <summary>
    /// WinErr1.xaml 的交互逻辑
    /// </summary>
    public partial class WinErr1 : Window
    {
        public WinErr1()
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;//窗体显示在正中间
        }
    }
}

  • DLL名称:WinBox_20200826.dll
  • 工程输出类型:类库

win32:

#include <iostream>
#include <Windows.h>

#using "../Debug/WinBox_20200826.dll" //注意不要用#include 
using namespace WinBox::View;

int main()
{
    WinErr1^ win = gcnew WinErr1();//初始化---->报错:SAT线程错误
    win->ShowDialog();//显示弹窗

    getchar();

}

  • 写回答

2条回答 默认 最新

  • threenewbee 2020-08-27 22:23
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置