|
WPF系ライブラリを利用して、ごりごりイチから記述するという手もあります。
(参照として、「PretentationCore, PresentationFramework, System.Windows, Wind
owsBase」の4つが必要です。
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace HmWPFTest
{
public class HmWPFTestClass : System.Windows.Window
{
public HmWPFTestClass()
{
SetForm();
SetButton();
}
Canvas c;
void SetForm()
{
this.Title = "秀丸マクロ hmPyによるWPFに組み込むWPF";
this.FontSize = 22;
this.Width = 1000;
this.Height = 500;
c = new Canvas();
this.Content = c;
}
Button btn;
void SetButton()
{
var ef = new System.Windows.Media.Effects.DropShadowEffect
{
BlurRadius = 5,
ShadowDepth = 1
};
btn = new Button()
{
Content = "秀丸",
Padding = new System.Windows.Thickness(2),
Effect = ef,
Foreground = Brushes.White,
Background = Brushes.Black
};
btn.Click += Btn_Click;
c.Children.Add(btn);
Canvas.SetLeft(btn, 30);
Canvas.SetTop(btn, 100);
}
private void Btn_Click(object sender, RoutedEventArgs e)
{
// 未実装なので例外処理が走る
throw new NotImplementedException();
}
}
public class MyEntry
{
public static System.Windows.Window form;
public static IntPtr CreateForm()
{
if (form == null || form.Visibility == Visibility.Hidden)
{
form = new HmWPFTestClass();
}
form.Show();
return (IntPtr)1;
}
public static IntPtr OnDetathMethod()
{
if (form != null)
{
form.Close();
form = null;
}
return (IntPtr)1;
}
}
}
//-------------------------- callmytest.mac --------------------
#HMNET = loaddll( hidemarudir + @"\hm.NET.dll" );
#r = dllfuncw( #HMNET, "SetDetachMethod", currentmacrodirectory + @"\HmWPFTe
st.dll", "HmWPFTest.MyEntry", "OnDetathMethod" );
#r = dllfuncw( #HMNET, "CallMethod", currentmacrodirectory + @"\HmWPFTest.dl
l", "HmWPFTest.MyEntry", "CreateForm" );
|
|