I could not find no example on how to write a wpf control that wraps c++ win32 window. If some one could provide me with a link to a newbie-like tutorial/documentation (sample code would be good too) on how to create c# libraries that wrap c++ code I would be very thankful.
Thanks in advance.
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 ) ?
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.
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.
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...
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.
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.
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?
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.
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
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
Not quite sure an "e.Handled = true" concept in messenger makes sense since the messages are going to be propogated in a random/arbitrary/indeterminate order. Its really up to the subscriber to determine if the message should be handled. Your "e.Handled = true" concept might just mean that somebody handled it and its up to the subcriber to play nice and check the flag. A lot of messenger implementations fire & forget the notifications in async mode too. Then it makes even less sense.
Now that I'v had a few days to thin about it, the subscriber should pass in it's id to the control Init. Could be a PK or a guid. If there are 3 tabs open, each instance of control would be intiailized with a different id.
Then, each subsequent call would have that Id passed with it. Then control's methods would only act if the Id passed in the message matches that sent in the 'init' method.
That's about how I would do it - although pass a reference to the object rather than just an Id - you then have the advantage of being able to access the object in question from your consumer.
Send Message - "I've just updated this Customer"
Receive Message - do nothing - not interested in this customer
Receive Message - update my list of customers as the value in the CustomerType property matches my filtering criteria.
Receive Message - I'm displaying this actual customer - so I'll refresh myself
the 'handled' approach can be useful; my example is selecting a customer to edit from a list.
If an existing customer edit view is out there, in a 'clean' state, it can take over the job of editing the selected customer - but you don't want another view to do the same thing too!
I have a tab control with two tabs in it,in each tab i have text boxes, the data of the text boxes is being validated using the IDataErrorInfo interface.
If there is an invalid data i am rendering a red ellipsis and a tool tip box using this XAML code:
<!--The template which renders a TextBox when it contains invalid data.-->
<ControlTemplatex:Key="TextBoxErrorTemplate"><DockPanel><EllipseDockPanel.Dock="Right"Margin="2,0"ToolTip="Contains invalid data"Width="10"Height="10"><Ellipse.Fill><LinearGradientBrush><GradientStopColor="#11FF1111"Offset="0"/><GradientStopColor="#FFFF0000"Offset="1"/></LinearGradientBrush></Ellipse.Fill></Ellipse>
<!--This placeholder occupies where the TextBox will appear.-->
Text box XAML:
<!--ID text box-->
The problem is when i go to another tab and then come back again the red Ellipses are disappear.
On Tab selection change event, give the datacontext to the textboxes.
Say for example for first tab, you have 3 textboxes in a grid and you provide the class object to be bound as datacontext of the grid; when you select that tab, again give the same object as datacontext to the grid.
I have been looking for a way to extend the default printdialog in PresentationFramework. I need to filter the available printers some how. Does anyone know if it is possible either to filter the printer queue datasource or to extend the dialog to add such functionallity?
Thank you for your reply.
I have already found those articles and posts but they all work with the windows forms version of the printDialog. I cant figure out how to apply the technique to the presentationframework PrintDialog.
Hi i am writing an application that has WPF as its front end and a Windows service which is responsible for scheduling and executing the my operations.
At the moment i use WCF to send live progress messages to the client from the service and i add this message to a listbox on the WPF listbox using the items.add function from the code behind, But the performance is very poor. I need help or suggestions on the best way to display this messages efficiently.
and my Page does not have with and height set as i want to cater for different resolutions.
if i remove the stackPanel , my buttons bring big nicely , but i need then in a Stackpanel kind of control so that they will be aligned in order , but when i have the stack panel in the , the buttons become small, can anyone help regarding this, below is the example of the image
Why do you need to use a StackPanel? Generally if you have a fixed layout panel, go with Grid.
But anyways, I dont know exactly how KinectTileButton works, but if you specify same size for MaxWidth and MinWidth, or MaxHeight and MinHeight, everything will remain same irrespective of the container.
Do let me know if you are looking for something else.
Abhishek Sur Don't forget to click "Good Answer" if you like this Solution.Visit My Website-->