Questions tagged [hwndsource]

10 questions
10
votes
3 answers

PresentationSource.FromVisual(this) returns null value in WPF

I'm using the following code for my: protected override void OnSourceInitialized(EventArgs e) { ... .... HwndSource source = PresentationSource.FromVisual(this) as HwndSource; ... ... } In some systems the "source" value comes out to be null and i…
AsitK
  • 651
  • 1
  • 4
  • 14
4
votes
1 answer

WPF element hosted in ElementHost not redrawing correctly

I'm writing a program to implement COM component in C#. This component provides a UI component too. In the interest of making it easy to implement future additions to the component, I decided to write the UI in Xaml using WPF and wrapping it in an…
Tym Lipari
  • 41
  • 1
4
votes
1 answer

Hosting WPF UserControl in Win32 application using HwndSource

I need to host my WPF UserControl in other window by Handle. I've tried to use HwndSource: var userControl = new MyUserControl(); var parameters = new HwndSourceParameters(); parameters.WindowStyle = 0x10000000 |…
voidmain
  • 81
  • 6
1
vote
1 answer

Creating HwndSource directly

I'm trying to create a Window by creating HwndSource directly. At the moment I have an alternative solution - inheriting from Window class, but I'm just curious what's wrong with my HwndSource implementation. Since Window uses HwndSource in its…
nevermind
  • 2,300
  • 1
  • 20
  • 36
1
vote
1 answer

How do I get a WPF Window "from" an HwndSource I create directly?

If I create an HwndSource directly, have I then also created a WPF Window that I can now access from code? If so, how can I access it? Or do I now need to somehow "add" a WPF Window to that HwndSource? If so, how do I do this? I have studied the…
Cardinal Fang
  • 283
  • 2
  • 12
0
votes
0 answers

How to change HwndSource RootVisual

I have a HwndSource and I have two WPF user controls, I would like to set one of them the RootVisual of this HwndSource and sometimes switch between these two WPF user controls. Just wonder am I able to do that? My two WPF user controls are:…
0
votes
0 answers

WPF, Hook Window, Popup

In App.xaml.cs or in another starting class instance you need add: var field = typeof(PresentationSource).GetField("RootSourceProperty", BindingFlags.NonPublic | BindingFlags.Static); var property = (DependencyProperty)field.GetValue(null); …
Smagin Alexey
  • 305
  • 2
  • 6
0
votes
0 answers

How to do work on the WPF UI thread when hosted in unmanaged C++/CLI application

I have a WPF log viewer user control that receives log messages via named pipes. The pipe messages are received and processed on a thread pool thread and then I pass it to the UI for display with an Application.Current.Dispatcher.Invoke call. Works…
Gerhard Wessels
  • 681
  • 1
  • 9
  • 18
0
votes
0 answers

How to change HwndSource window size C#

I created a window as a child window of a C++ window handler in C#, the code is like: public void CreateHostHwnd(IntPtr parentHwnd) { // Set up the parameters for the host hwnd. parentHandle = parentHwnd; …
0
votes
1 answer

Send window message to WPF application from another WPF application

I used this code in the server side void Window_Loaded(object sender, RoutedEventArgs e) { HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); source.AddHook(new HwndSourceHook(WndProc)); } …
MElagder
  • 29
  • 2
  • 4