|
|
|
@ -13,26 +13,43 @@ namespace Perspex.Designer.AppHost |
|
|
|
{ |
|
|
|
public WindowHost() |
|
|
|
{ |
|
|
|
SetStyle(ControlStyles.AllPaintingInWmPaint, true); |
|
|
|
BackColor = Color.AliceBlue; |
|
|
|
_textBox = new TextBox {Dock = DockStyle.Fill, ReadOnly = true, Multiline = true, Visible = false}; |
|
|
|
Controls.Add(_textBox); |
|
|
|
} |
|
|
|
|
|
|
|
private IntPtr _hWnd; |
|
|
|
private TextBox _textBox; |
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e) |
|
|
|
public string PlaceholderText |
|
|
|
{ |
|
|
|
e.Graphics.FillRectangle(Brushes.AliceBlue, ClientRectangle); |
|
|
|
get { return _textBox.Text; } |
|
|
|
set |
|
|
|
{ |
|
|
|
_textBox.Text = value; |
|
|
|
FixWindow(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private IntPtr _hWnd; |
|
|
|
|
|
|
|
|
|
|
|
public void SetWindow(IntPtr hWnd) |
|
|
|
{ |
|
|
|
if (_hWnd != IntPtr.Zero) |
|
|
|
WinApi.SendMessage(_hWnd, WinApi.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); |
|
|
|
_hWnd = hWnd; |
|
|
|
WinApi.SetParent(hWnd, Handle); |
|
|
|
FixWindow(); |
|
|
|
if (_hWnd != IntPtr.Zero) |
|
|
|
{ |
|
|
|
WinApi.SetParent(hWnd, Handle); |
|
|
|
FixWindow(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void FixWindow() |
|
|
|
{ |
|
|
|
WinApi.MoveWindow(_hWnd, 0, 0, Width, Height, true); |
|
|
|
if (_hWnd != IntPtr.Zero) |
|
|
|
WinApi.MoveWindow(_hWnd, 0, 0, Width, Height, true); |
|
|
|
_textBox.Visible = _hWnd == IntPtr.Zero && !string.IsNullOrWhiteSpace(_textBox.Text); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnResize(EventArgs e) |
|
|
|
|