Browse Source

Merge pull request #5 from SuperJMN/title-for-window

Title property for Window
pull/10/head
Steven Kirk 11 years ago
parent
commit
d6fd795759
  1. 1
      TestApplication/Program.cs
  2. 5
      Windows/Perspex.Win32/Interop/UnmanagedMethods.cs
  3. 14
      Windows/Perspex.Win32/Window.cs

1
TestApplication/Program.cs

@ -101,6 +101,7 @@ namespace TestApplication
Window window = new Window
{
Title = "Perspex Test Application",
Content = new Grid
{
RowDefinitions = new RowDefinitions

5
Windows/Perspex.Win32/Interop/UnmanagedMethods.cs

@ -444,6 +444,9 @@ namespace Perspex.Win32.Interop
IntPtr hInstance,
IntPtr lpParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool SetWindowText(IntPtr hwnd, String lpString);
public struct MSG
{
public IntPtr hwnd;
@ -483,6 +486,6 @@ namespace Perspex.Win32.Interop
public string lpszMenuName;
public string lpszClassName;
public IntPtr hIconSm;
}
}
}
}

14
Windows/Perspex.Win32/Window.cs

@ -27,6 +27,8 @@ namespace Perspex.Win32
public class Window : ContentControl, ILayoutRoot, IRenderRoot, ICloseable
{
public static readonly PerspexProperty<string> TitleProperty = PerspexProperty.Register<Window, string>("Title");
private UnmanagedMethods.WndProc wndProcDelegate;
private string className;
@ -49,7 +51,7 @@ namespace Perspex.Win32
this.LayoutManager.LayoutNeeded.Subscribe(x =>
{
WindowsDispatcher.CurrentDispatcher.BeginInvoke(
Dispatcher.CurrentDispatcher.BeginInvoke(
DispatcherPriority.Render,
() =>
{
@ -59,11 +61,13 @@ namespace Perspex.Win32
});
});
this.GetObservable(TitleProperty).Subscribe(s => UnmanagedMethods.SetWindowText(Handle, s));
this.RenderManager.RenderNeeded
.Where(_ => !this.LayoutManager.LayoutQueued)
.Subscribe(x =>
{
WindowsDispatcher.CurrentDispatcher.BeginInvoke(
Dispatcher.CurrentDispatcher.BeginInvoke(
DispatcherPriority.Render,
() =>
{
@ -80,6 +84,12 @@ namespace Perspex.Win32
public event EventHandler Closed;
public string Title
{
get { return this.GetValue(TitleProperty); }
set { this.SetValue(TitleProperty, value); }
}
public Size ClientSize
{
get

Loading…
Cancel
Save