Hi Everyone,
So, I'm trying to create a win32 application with a nice UI, and after some research decided that WPF is probably the way to go (as I used to work with MFC based UIs in the past when doing win32 apps). I'm a C/C++ developer, so I prefer developing in Visual Studio 2012, as the 'BLEND' tool with VS2012 is quite easy to do WPF xaml style development for the UI.
Before doing anything creative, I wanted to make a quick 'test' app to see if what I wanted to do is even possible....
I started off with a super simple setup, just made a generic win32 application right from VS2012, then went into BLEND and made a real simple WPF control library, just a plain background with one single 'button'. I created the action for the 'button click', then compiled the C# code into a DLL (for .NET 3.5).
From following the Microsoft examples for including WPF into win32 apps, I was able to reference in the WPF dll fine, and doing the hwndsource setup, load the WPF window within the dialog box of the main win32 app.
My questions are these:
1) Is it even possible to hook an event handler in my win32 app, to the WPF event for that button 'click' action, when using the WPF DLL in this
particular setup? (where I'm importing the compiled DLL as a reference in my win32 app)
2) Or Do I need to setup message pumps between the two, to pass msgs back and forth?
3) Or, is my only option to write this WPF app in c code, and compile it directly into the win32app, so I can setup the event handlers that way?
(as Microsoft does in their 'win32 with WPF control example' (address book example) ???
My WPF xaml for the layout is this simple:
[code]
<UserControl x:Class="WpfControlLibrary1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Height="516" Width="616">
<UserControl.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF7FB2FB" Offset="1"/>
</LinearGradientBrush>
</UserControl.Background>
<Grid>
<Button x:Name="IDC_BUTTON" Content="Button" HorizontalAlignment="Left" Height="79" Margin="222,188,0,0" VerticalAlignment="Top" Width="185" Click="ButtonClick"/>
</Grid>
</UserControl>
[/code]
and the C# code is this simple:
[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfControlLibrary1
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void ButtonClick(object sender, System.Windows.RoutedEventArgs e)
{
}
}
}
[/code]
Thanks so much everyone in advance, for any help or advice you can provide!!
- Mike