|
No because the clicks are sent to the active window. However if you look at using Windows Hooks (Google will find information) it may be possible to do what you want.
|
|
|
|
|
private void button1_Click_1(object sender, EventArgs e)
{
string formCode = "<form id=\"{0}\" name=\"{0}\" method=\"post\" action=\"{1}\">" +
"<input type=\"hidden\" name=\"txntype\" value=\"sale\">" +
"<input type=\"hidden\" name=\"timezone\" value=\"IST\"/>" +
"<input type=\"hidden\" name=\"txndatetime\" value=\"{2}\"/>" +
"<input type=\"hidden\" name=\"hash\" value=\"{3}\"/>" +
"<input type=\"hidden\" name=\"storename\" value=\"{4}\" />" +
"<input type=\"hidden\" name=\"mode\" value=\"payonly\"/>" +
"<input type=\"hidden\" name=\"currency\" value=\"{5}\" />" +
"<input type=\"hidden\" name=\"chargetotal\" value=\"{6}\"/>" +
"<input type=\"hidden\" name=\"language\" value=\"en_EN\"/>" +
"<input type=\"hidden\" name=\"authenticateTransaction\" value=\"true\"/>" +
"</form>";
string formScript = "<script language=\"javascript\" type=\"text/javascript\">" +
"document.getElementById('{0}').submit();" +
"</script>";
string formName = "form1";
string urlString = "https://test.ipg-online.com/connect/gateway/processing";
string storename = this.textBox1.Text;
string txndatetime = DateTime.Now.ToString(@"yyyy\:MM\:dd-HH\:mm\:ss");
string chargetotal = this.textBox2.Text;
string sharedsecret = this.textBox4.Text;
string currency = this.textBox3.Text;
string data = storename + txndatetime + chargetotal + currency + sharedsecret;
string hash = calculateHashFromString(new StringBuilder(data), "SHA1");
string postdata = string.Format(formCode, formName, urlString, txndatetime, hash, storename, currency, chargetotal + formScript + formName);
webBrowser1.Navigate(urlString, postdata);
}
|
|
|
|
|
|
I have a "parent" form in WPF and I would like to add a "child" form of type System.Windows.Forms.Form, which should have its own message pump. I tried the following, but it doesn't compile:
new System.Threading.Thread(delegate ()
{
System.Windows.Forms.Form childFormWithItsOwnMsgPump = new System.Windows.Forms.Form();
System.Windows.Application.Run((System.Windows.Window)childFormWithItsOwnMsgPump);
}).Start();
Does anybody know how to solve it?
|
|
|
|
|
What exactly are you trying to do? The question does not make a lot of sense.
|
|
|
|
|
The parent WPF Window is the main applicaition. The WinForm child form is a high-tech communications bus traffic monitor. Both are big and too much work to re-write in the other way.
|
|
|
|
|
Sorry but that does not really tell us anything.
|
|
|
|
|
When a communications packet is transmitted/received in the parent application, it queues it to the child application and then the child application decodes it and formats it into a user friendly format and displays it.
|
|
|
|
|
Well that makes everything clear.
|
|
|
|
|
First you referred to them as main window and child window.
Now you refer to the child as a child application.
There's a difference. Which is it?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Main application = main window = parent = WPF
Child applicaion = child window = child form = child = WinForm
|
|
|
|
|
Okay. Why can't you just do the following:
ChildForm F = new ChildForm();
F.Show();
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I tried it and I could see the form flashing for a fraction of a second and then it was gone.
|
|
|
|
|
|
Do I have to go in and make changes in the code that looks like some kind of XML or is there a way to accomplish this in the .cs-file alone?
|
|
|
|
|
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)
|
|
|
|