|
It very difficult to decipher what question you are really asking but for what it's worth here is my interpretation.
1) By "addin" you mean an assembly containing the definition of a form.
2) By "launch" you mean display the form.
3) By "steal focus" you mean that the main form of the application is inaccessible until the addin's form is closed.
Based on (3) the addin's form has been displayed via ShowDialog and what you observe is the expected behaviour.
One part of the solution to your problem will be to display the addin form non-modally via the Show method.
However giving the user the ability to access both the addin and main forms will present new problems and you will need to decide what actions are allowable when the addin form is open. For example, will it be reasonable to let the user terminate the application?
Alan.
|
|
|
|
|
Hi Alan,
Thank you for the reply. I did us Form.Show(); instead of Form.ShowDialog(); and ironically enough I now have the exact opposite of my problem. My form is now non-modal, which is what I want, but I would like for it to be brought to the foreground.
1) It is an addin DLL that has a configuration form inside of it. The form configures some of the DLL settings, for when it is ran inside of the parent application.
2) Yes
3) Yes because of ShowDialog();
It is reasonable for the user to terminate the form and dialog, I would just like it to be brought to the foreground now when the form is displayed.
I just tried this code, and it seems to be working ... what do you think?
this.TopMost = true;
this.Focus();
this.BringToFront();
this.TopMost = false;
|
|
|
|
|
Yes, the TopMost trick would be a fix it but it's interesting to consider why it is needed.
Your observation of the configuration form behind the main form suggests that the main form is the last one to be shown. The desired order can probably be restored by deferring creation of the config form to the main form's Shown event.
An alternative would be to set the main form as the the owner of the config form, but then it would not be possible to bring the main form to the front, which may not be what you want.
Alan.
|
|
|
|
|
Hi Alan,
Thanks for the reply. I'm willing to give that a try, how do I set the main form as owner?
|
|
|
|
|
I figured out why the main form loaded last, and have corrected it. It works like it should now, thank you.
|
|
|
|
|
I just did some tests by starting notepad from a c# windows form, and yes notepad retains activated status. You can get round this by doing the
following;
(The test form has a textbox and a button)
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process p;
p = System.Diagnostics.Process.Start("notepad.exe");
p.WaitForInputIdle();
this.Activate();
textBox1.Focus();
}
Your form will now retain Activated status, and notepad will not be the current active window.
|
|
|
|
|
Thank you Dave, I will play around with that now.
|
|
|
|
|
I think part of the confusion about this question is that the term "add-in" has several possible meanings in .NET: it may mean a plug-in, which is a Dll dynamically loaded into a certain area of an Application's Window, and, usually, cannot be "dynamically unloaded."
More recently Microsoft's MEF has come on the scene to provide a high-level architecture for plug-in type scenarios.
Some responses to this question have assumed you want to launch another (non .NET) application and make it work with your application (specifically, NotePad).
But, from your later comments on the thread, it seems you are loading a DLL that has a Form ... and, while you never state it directly, one might assume it's a Windows Form from .NET.
If you are loading a DLL, and then showing a .NET Form defined in that DLL, please check out the possible use of setting the 'Owner property of that Form to your Application's main Form.
And, please try, if possible, to be very specific about exactly what it is you are loading, and how it will function/interact along/with your Application.
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
|
Is it possible to use one of the Stream classes to lock a portion of a disk file? How?
I think this might be better than using a mutex to control access to the entire file at once.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Yes that's it. I couldn't find that function in the docs prior to you showing me the link!
Thanks. I was hoping they supported that ability.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Nice, didn't know that was possible.
|
|
|
|
|
xmlDoc = new XmlDocument();
using (XmlWriter xmlWriter = xmlDoc.CreateNavigator().AppendChild())
{
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("INTERACTIONS", xmlns);
xmlWriter.WriteStartElement("CALL_STATUS");
xmlWriter.WriteString("open");
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("ARE_DOCS_REQUIRED");
xmlWriter.WriteString("No");
xmlWriter.WriteEndElement();
string ipxml =<Data>
<First_Name>Thomas</First_Name>
<Middle_Name>Alwa</Middle_Name>
<Last_Name>Edison</Last_Name>
</Data>
xmlWriter.WriteStartElement("MY_COMPLAINT");
xmlWriter.WriteString("ipxml");
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
}
xmlDoc.InnerXml.ToString();
I have created an xml document using xmlWriter and having xmlelement
my problem is XML element 'MY_COMPLAINT' contains another XML which is 'ipxml', when the xml file is created MY_COMPLAINT element contains ipxml as a string but i want it has to be its Child element
how can i convert ipxml string to be as child node of MY_COMPLAINT
as xmlwriter.WriteString accepts parameters as a string.
Help me out.
Thanks in advanced..
|
|
|
|
|
Don't ask for urgent help, its rude. This is a volunteer site and people will answer you on their time, not yours.
No comment
|
|
|
|
|
I'm also a huge fan of posts that end with "Thanks in advance!" which basically means you'll never see or hear from the OP again unless they couldn't figure out your answer .
|
|
|
|
|
|
Then don't write it with xmlWriter.WriteString ; create an element for it.
|
|
|
|
|
This is what happens if you just copy-paste code without applying your mind to it. If you put a little thought, you will realize that you can create another element using a WriteStartElement and WriteEndElement pair instead of a WriteString .
NOTE: This is a volunteer site where people try to help others for free in their spare time. So do not use phrases like "it's urgent", etc., it's considered rude here. Read the posting guidelines before making any post.
|
|
|
|
|
Hi guys,
I am looking for the best ways to create an api which will monitor the database table row version.
if this api found any row update manually (i.e., directly login to SQL server) than it will send an acknowledgement with the following information:
(1) LogIn detail of the data server.
(2) Access database name with datatime.
(3) Affected table name, row version and row number as well.
I will be glad for your any suggestion / ides on that.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Md. Marufuzzaman wrote: I will be glad for your any suggestion
I suggest you don't cross-post: ask your question once, in a single forum. You should know that by now.
|
|
|
|
|
Hi,
Yes, you are right, actually this can be done from database end or may C# application end as well,
that's way I post. anyway; I sincerely apology & thanks for your response.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Univote countered.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
|
Md. Marufuzzaman wrote: I am looking for the best ways to create an api which will monitor the database table row version.
if this api found any row update manually (i.e., directly login to SQL server) than it will send an acknowledgement with the following information:
(1) LogIn detail of the data server.
(2) Access database name with datatime.
(3) Affected table name, row version and row number as well.
I question the requirement.
If you have a small application/database then it is pointless.
If you have a large application/database (and volume) then any such notification system would be worthless because it would overwhelm all other work.
Further one doesn't identify a row in the database by "row number". For example if there are three users in the database and I change the last name of one of them I would not send a notification for "row 2" but rather that the user "jdoe" last name has changed to "Smith".
Conversely you might have this sort of requirement.
1. You are displaying a list of users
2. You want to update that list if anyone else changes it
That requires monitoring one table, not all. And then the client, not the database, polls the database as some small, but not real small interval, to check for changes.
However even those sort of requirements are often pointless because they are often the result of made up requirements rather than real business need.
For example - the admin claims that they need the above functionality. Then one asks the admin exactly how many admins are going to be updating the user table on a minute by minute basis. The answer will often be that such updates only seldom and that they are down via a admin process/task. As such there is no possibility that other admins would even be impacted by such an update because only one admin would be doing it at a time.
Another example - consumer order entry system where someone claims that the customer address might change. The question then is what sort of customer calls up on a different phone to update their address at the same time that they are placing an order on another line? Conversely for business customers what sort of business is going to update their address at the same time and use two different values (excluding legal disputes between competing partners which no technological solution is going to fix.)
|
|
|
|
|
It all really depends on the OPs real requirements and design. Polling is not a very elegant solution and will bog down your database server if you have more then a few clients.
* are there multiple clients from outside your firewall? if so, its unlikely they'll even be able to connect to the database directly anyways
* do you really need instant real time sync'ed up data between clients?
* there *IS* a built in mechanism for *PUSH* called SqlDependency, but it needs your design to be one where only a single instance server piece is connecting to the DB and clients connect to the server piece and the server piece pushes out the notifications itself
* is the client application display only, or will clients be updating data? if so, you need to decide on your write policy because that will effect design as well. Does last writer always win? Probably not.
Lets say User A grabs a row which is A B C D. User B grabs the same row and gets A B C D. Now User A changes B -> E, so the row in the DB is A E C D. User B still has A B C D and changes D to F. Now should the database contain A E C D, A B C F or A E C F. In most scenarios, its going to be A E C F.
Honestly, at first glance, from the OPs question, I suspect he is getting concurrency exceptions and is going about it the wrong way to fix them .
|
|
|
|