|
Hi!
Thx for the link. I found that one my self and I tried to modify the sample code to my needs but i failed.
I'll try to explain more what I'm trying to do.
So I have 3rd party OpenGL application written in C++ that is capable to show its output on another process window by passing a HWND pointer of that window (re-parenting).
If I create basic C++ Win32 aplication and pass its window HWND to that 3rd application I see output of that application in my application window.
Since I don't know C++ programming that well and I'm a little better at C#, I would like to create a WPF control that wraps C++ window in a dll that I can use in my WPF project.
Now the problem is that I can't figure out how to override WM_PAINT function so that WPF would be able to render that control correctly.
Because now I get that control instantiated and I get the HWND of that control (which is different of the WPF window hosting it) but when I pass it to that 3rd party application nothing happens.
My guess is that WM_PAINT is being called correctly but WPF window is not rendering that control because it knows nothing of WM_PAINT ?!
Now, the MSDN resource is a bit difficult for me to figure out how to solve my problem. Mostly because I need some easy reading on how to write managed c++/clr code.
Any suggestion on some websites or books that explain this subject (on elementary school level ) ?
Thx again!
|
|
|
|
|
You can get the native HWND of a WPF control / window. Wait for the SourceInitialized event and then:
HwndSource hWndSource = (HwndSource)PresentationSource.FromVisual(window);
the HWND is in hWndSource.Handle. WPF hides WM_PAINT from you so it can do all the double buffering, effects, transformations, etc.
|
|
|
|
|
So I have PInvoked BeginPaint() and EndPaint() funcrions also.
And I'm able to draw inside my win32 window from there.
But my 3rd party application still can't and I don't know what else do I need to override to make it work.
At this point there is no difference between win32 window hosted in WPF application and win32 window created by c++ win32 application or is there ?!
Maybe type of class inside CreateWindowEx function ("static") should be something different, or some of window parameters should be changed.
My guess is that WPF is preventing win32 window from communicating with 3rd party process. Response from 3rd party app is: "visual not possible"
Here is link to my project if anyone interested to look what I did so far.
http://sdrv.ms/10VSWbD[^]
Don't know if there is a way to simulate my situation by trying to redirect (reparent) some other application (that uses win32) window output to my app. I'm not in position to share that 3rd party application that I'm using.
|
|
|
|
|
Did you try passing the 3rd party app the HWND from:
HwndSource hWndSource = (HwndSource)PresentationSource.FromVisual(window);
The HWND in hWndSource.Handle and bypassing your C++ app entirely?
I don't think "visual not possible" is a WPF error, sounds like its coming from the 3rd party vendor. Have you tried contacting them if they support redirection?
|
|
|
|
|
Yes I tried your suggestion and still no success.
The 3rd party vendor don't consider this to be a valid customer API request as this is something they use internally (they have couple of apps that can do this and they have some interop wpf dll's for this but it is not exposed for others)
|
|
|
|
|
Hmmm... maybe its not possible then. If you can do it in C++, then you should be able to take that C++ window and host it on a WPF form. My only other suggestion would be to maybe package it as an ActiveX control and then host that on the WPF form natively. Not sure if it will work though...
|
|
|
|
|
Just as a note, this two methods return the same hwnd (I was using the later option).
Window www = App.Current.MainWindow;
HwndSource hwndS = (HwndSource)PresentationSource.FromVisual(www);
Console.WriteLine("hwndSource: " + hwndS.Handle);
IntPtr hwnd = new WindowInteropHelper(www).Handle;
Console.WriteLine("hwnd: " + hwnd);
I also thought it would be simple. Just create a c++ win32 window inside of wpf and all would work but somehow it is not that simple. I'll try some more options I found online.
My guess is that I need to somehow paste info from BeginPaint(IntPtr hwnd, PAINTSTRUCT ps) PAINTSTRUCT to overriden OnRender(DrawingContext dc) DrawingContext.
But that probably won't work either.
Anyway thx for help.
|
|
|
|
|
I just noticed it now in your previous response, but you said they have interop WPF dlls that are working? Why don't you just use those? Are those written in C# or C++? If they are written in C#, you can view the exact code by using ILSpy, .NET Reflector, etc. If they are written in C++, you can view the DLL exports easily using the dumpbin utility that comes with Visual Studio.
|
|
|
|
|
I believe they are written in C#, or maybe they are managed C++.
But they name says that they are _.Interop.Wpf.dll
Will try to examine it as you suggested.
|
|
|
|
|
Hi,
You're rather trying to do something that will break WPF!
WPF is rendered using DirectX. The whole thing, there is just a window wrapper for win32 environment. You cannot do anything by passing it an WM_PAINT message.
Here comes the fix. Set up a winforms host inside your app xaml. Put a label control (winforms equivalent of STATIC) inside the host . Set the text to empty. get it's HWND by getting its Handle property and pass it to your native library that does OpenGL stuff through P/Invoke.
Here is a MSDN Walkthrough to guide you. Just replace that MaskedTextBox code with a Label.
Good Luck!
|
|
|
|
|
How to create radio buttons dynamically as shown below in WPF
Group1 Group2 . . . . . GroupN
A 1
B 2
C 3 . . . . . N
|
|
|
|
|
Id proberbly use a DataTable or a ListView for this, but there are also other more cumbersome possibilities:
WPF-Drawing Canvas Control[^]
|
|
|
|
|
Host your groups and radio buttons in a collection control, datagrid, listview, treeview, itemscontainer and bind the itemssource to your underlying collection.
Limit n to a workable number.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I just moved to a new company. And they use this seemingly cool ORM: IdeaBlade, will let the developer do Linq2SQL on the client (Silverlight) side.
There are performance issue though...
Haven't work with real data yet (it's big) but just the ORM seems to have some down time (due to initialization and query parsing)
I wonder did anyone here used IdeaBlade (DevForce)? is it good?
How does it compare to WCFDataService?
|
|
|
|
|
Hi All,
Can anybody help me in wpf mvvm pattern.
I am facing an issue i.e., i created a login form and main window (after login, if login sucessfull). I implemented the application in mvvm pattern. I don't know how to call the main window after sucessful login using mvvm. Can anybody help me out from here.
Thanks
Kishore
|
|
|
|
|
There are plenty of navigation examples[^] around, it is not as simple as you may think but once you have set up the navigation framework it is a no brainer.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am asking in wpf i.e., navigation between windows.
|
|
|
|
|
My bad - try this nifty focus change wpf navigation example[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
didnt find any solution..
|
|
|
|
|
I generally override the OnStartup method on my App class and then call my Login View modally, which returns a bool indicating whether login was successful. Something like this (very simplified):-
LoginView login = new LoginView();
login.ShowDialog();
if(login.LoginSuccess)
{
Mainwindow window = new Mainwindow();
}
else
{
}
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Found the solution
|
|
|
|
|
Excellent! It is a good idea to link to the articles/resources that you found useful as they will help the next person when they search this forum.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello.
I would like to present in a flat area a tree like view.
Each item would be a non-movable panel with its own controls. Each child will have connected with a line (Also selectable). On top of it, some childs are going to have multiple parrents. The closest that i have seen to compare is code map in VS2012 Update 2.
Example: Panel 1 and 2 are parents of panel 3
Panel1 Panel2
| |
---------
|
Panel3
I would like some pointers where to go, or if there is a custom control as long as it is free and can redistribute with or without source code. When i finish my personal project i will release source. As i am hobbiest programmer, my understanding on WPF is limited, so thank you for your time and patience.
|
|
|
|
|
|
Thanks for suggestion, but i didn't knew what to search. I am currently reading a WPF book and in a book i saw word diagram in it. At that moment i found WPF Diagram Designer article that is perfect. Since my native language is not english i could not remeber word, that would help me search on google
|
|
|
|