|
There is no way to run a Windows Forms form inside a WPF application.
That would be like the USS Enterprise from Star Trek suddenly appearing next to the Millennium Falcon from Star Wars. It would break the space-time continuum.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Is it possible to make them "siblings" instead of parent-child? As long the WPS-application can call delegates inside the WinForm-application it should still be useful to me.
Or could I perhaps start a new WPF-windows ( System.Windows.Application.Run(System.Windows.Window) ) that in turn contains the WinForm form (basically, make a WPF window wrap around the WinForm form)?
modified 5-May-20 3:27am.
|
|
|
|
|
I just tried the following, but I got a runtime exception (System.InvalidOperationException: 'Cannot create more than one System.Windows.Application instance in the same AppDomain.')
System.Threading.Thread myThread = new System.Threading.Thread(delegate ()
{
System.Windows.Forms.Form childFormWithItsOwnMsgPump = new System.Windows.Forms.Form();
childFormWithItsOwnMsgPump.TopLevel = false;
System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();
host.Child = childFormWithItsOwnMsgPump;
System.Windows.Window WPFwindow = new System.Windows.Window();
System.Windows.Application app = new System.Windows.Application();
app.Run(WPFwindow);
});
myThread.SetApartmentState(System.Threading.ApartmentState.STA);
myThread.Start(); Suggestions are still welcome and very much appreciated.
|
|
|
|
|
|
Afraid not. What you're trying to do is not possible.
WPF cannot host a WinForms window, nor vice versa.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I'm sorry but it looks like I misunderstood your question.
The link I gave shows how to host Windows Forms controls in a WPF form.
But you want to run a Windows Form inside a WPF application, correct?
Pretty sure there is no way to do that. They are distinct frameworks and you can't have an instance of one framework inside another.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
You can "load" / open a Windows Form / app "from" WPF, you just have to give up on the "in WPF". WPF does not support "child" / MDI windows, even natively. Easiest way is just to make calls into a "Forms" project from a "WPF" project, with compatible frameworks.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
The following works fine:
System.Threading.Thread myThread = new System.Threading.Thread(delegate ()
{
System.Windows.Forms.Form childFormWithItsOwnMsgPump = new System.Windows.Forms.Form();
System.Windows.Forms.Run(childFormWithItsOwnMsgPump);
});
myThread.SetApartmentState(System.Threading.ApartmentState.STA);
myThread.Start();
|
|
|
|
|
Need some guidance here -
Requirement-
I have 1000 SQL servers and I have a scheduled task running on all of those which updates a table with just an integer, let's call it X (its a sum of some numbers). Now the ask is to create some sort of ticker which updates every few mins with the sum of the total of all the X's from all the 1000 servers and display it either on a webpage or a console. So I will need a service that runs centrally and gets this data from all those 1000 servers or service which runs on all the 1000 servers which pushes this info on the central server. Can you please help with do I achieve this.
And remember if this runs centrally then it should be a multithreaded service.
modified 4-May-20 9:59am.
|
|
|
|
|
1000 instances of SQL Server? Or 1000 SQL Server Databases (they are not the same)
|
|
|
|
|
Repost of question on QA: [^]
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
You make your "central server" a web server to which you post your numbers. So, the server doesn't "get"; instead, the clients post / push.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi,
I am trying to add password protection to my excel file using c# which is generated and downloaded after closexml data loading
pls help in this problem as soon pls
|
|
|
|
|
Unless you have Excel installed, you can't "protect" it. Zip it and password protect that. You get what you pay for.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Can you add password protection via interop?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
"you can't "protect" it. Zip it and password protect that." This is what help me
Thank you for response
|
|
|
|
|
Password protection to enable/disable the opening of a file is not supported with OpenXML.
You can only lock the structure and windows of an OpenXML document and that is indeed what the wb.Protect() method does.
Sheet Protection · ClosedXML/ClosedXML Wiki · GitHub[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I Got my points,Thank you for your response.
|
|
|
|
|
Hello,
I am creating a immersive experience system for gaming and VR. Where the system controls LED light, seat vibration, gun recoil, depending on the feedback received from the game.
Sending data from the PC to the microcontroller over USB and control all these effects is done.
I am not able to get information on how to read these feedback data from game.
Thankyou
Harikrishna
|
|
|
|
|
Is this for a game you are developing? If so, you would send the appropriate "feedback" message yourself. If it's for other people's games, then you probably aren't going to be able to capture this.
|
|
|
|
|
Thank you for the replay.
I am not developing game, I wan to capture(read) feedback messages from game using C# or C++. This is to control external hardware like seat vibrate, LED light, gun recoil etc.
|
|
|
|
|
You can only capture what the game sends to you.
|
|
|
|
|
Feedback will depend on the hardware and software in use. Check the documentation for the game.
|
|
|
|
|
So you want to use "some" output from the game, so that you can generate e.g. seat vibration, gun recoil, flashing of LEDs etc - is that right?
If I get it right: You want to generate seat vibration, gun recoil etc., based on some other feedback from the game. What kind of game output do you want to capture to generate these effects? Text messages? Synthetic speech or other sounds generated by the game? Visual effects on the screen? Are you expecting to capture the image of a gun being fired, recognize it as such, and from that generate your recoil effect?
For a vintage text-only game (such as classical Adventure or MUD), text capture would be trivial and analyzing it reasonably simple. But if you want to generate additional effects triggred by sound or graphics, and do it in a general, game-independent way, then you are up for a huge task. You simply can't do it in any reasonable way. If text output is available only as graphic character images on the screen, you cannot even do text anlysis. (Well, you might try with some OCR functionality, but chances are that it would fail miserably.)
If you had access to the source code of the game, you could probably - as the game initiates sound/visible effects - write to a textual log an indication of the effect genereated, and route it to some output available to your recoil or vibration or whatever functions you want to add. It would require that you can modify the game source code, and it would be specific to that game.
If you are hoping to capture non-text output from an arbitrary game, without having to "get under the hood" of the game, I cannot see how you can make it.
|
|
|
|
|
Let me try a simple thing. Games send rumble (vibration) or FFB data to gamepad right? which gives information like how much vibration applied to which motor. Is there a way I can capture that messages?
|
|
|
|