|
It's fairly simple, just pass the reference to the main form to the modeless form. Something like
class MainForm : Form
{
public void ShowForm()
{
ChildForm f = new ChildForm(this);
f.Show();
}
}
class ChildForm : Form
{
MainForm mainForm;
public ChildForm(MainForm f)
{
mainForm = f;
}
void SomeFunc() { int data = mainForm.data; }
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello,
I tried to uninstall an application.
However I still get the "The specified service already exists" error when I try to reinstall the
application.
How can I fix the problem?
Thanks in advance.
Regards,
Clifford
|
|
|
|
|
I wrote a plugin to internet explorer that requires internet explorer to be shutdown and restarted. I figured out a way to shut down IE using the MSI and to start it back up using VBScript.
I was wondering if there was a way to remember what webpage each internet explorer process was on and then open up internet explorer windows that open up to the URLs that the user was visiting previously.
Any insights?
|
|
|
|
|
What does your question have to do with C#?
Generally speaking, there is a way and you can do this in C#, but managed custom actions are not recommended because you have no control over runtime binding.
Through script, VB (6.0), managed code, and even native COM client implementation you could keep getting an InternetExplorer.Application object using GetObject in VB, or the Running Object Table (ROT) in other implementations; get its LocationURL property value; then call Quit . Do this until no more InternetExplorer instances are returned.
When you're done upgrading the machine and no reboots are required (don't forget to check that, calling MsiGetMode to check for MSIRUNMODE_REBOOTATEND | MSIRUNMODE_REBOOTNOW ), you should invoke iexplore.exe -nohome <url> for each URL in your list. Do not create new instances of InternetExplorer.Application , because successive calls after the first will most likely return the fist object and you'll just end up causing the last URL to be displayed only instead of all of them.
I would warn against this, however. If one of those instances was the resultant page of an online purchase that haphazardly uses HTTP GET (that would be seriously bad and hopefully no one does that) and you browse to it on the users' behalf, you just ended up forcing them to buy another car or pair of socks or whatever. Just don't do it, IMO.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I agree with Heath. IMHO, you should let the user know that IE needs to be restarted. Let the user take care of opening their websites.
Alex Korchemniy
|
|
|
|
|
gotcha... i'll look into it.
|
|
|
|
|
Hi,
I am trying to get the windowstate of a window based on its process id. I am not exactly able to get the window state as MINIMIZED when the window is minimized .. most times i returns NORMAL. I am unable to find a pattern.
Can anyone explain how the window state is maintained.
Thanks!
|
|
|
|
|
Updating the previous query -
Below is what I used to get the window state ----- what is wrong in this? Am i missing something?
-------------------------------------------------------------------------------------------------
FormWindowState GetWindowState(int processID)
{
FormWindowState formWindowState = FormWindowState.Normal;
WINDOWPLACEMENT windowPlacement = new WINDOWPLACEMENT();
//If there is not proces by this ID, then return Minimized.
uint processHandle = (uint)Process.GetProcessById(processID).Handle;
if ( processHandle.Equals(0) )
{
return FormWindowState.Minimized;
}
bool test = Win32Wrapper.GetWindowPlacement(processHandle,ref windowPlacement);
if ( windowPlacement.showCmd == SHOW_STATE.SW_SHOWMINIMIZED )
{
formWindowState = FormWindowState.Minimized;
}
else if ( windowPlacement.showCmd == SHOW_STATE.SW_SHOWMAXIMIZED )
{
formWindowState = FormWindowState.Maximized;
}
}
|
|
|
|
|
I admit it, I'm a newbie when it comes to regular expressions. I'm hoping one of the experts can give me a hand here. I have 3 regular expression calls and a standard string.Replace call (4 replace calls in all) that I'd like to combine into a single regular expression. Here's my code:
string returnValue = Regex.Replace(plainText, "(\\r\\n)|(\\n)", "<br />");
returnValue = Regex.Replace(plainText, @"\b(http://|https://|https://www.|http://www.|www.)[^\s]+\b", @"<a href=""$0"">$0</a>");
returnValue = Regex.Replace(plainText, "<a href=\"www.", "<a href=\"http://www.");
returnValue = returnValue.Replace("'", "'");
For performance's sake, I'd like to combine all those calls into a single regular expression. Possible?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
Hey!
I got a ArrayList that is readed and modified from diffrent methods in a class. Its inportant that there is not more thw one thread working against this arraylist at a time.
I have tryed
<br />
Method1()<br />
{<br />
lock(myArrayList)<br />
{<br />
}<br />
}<br />
Method2()<br />
{<br />
lock(myArrayList)<br />
{<br />
} <br />
}<br />
Method3()<br />
{<br />
lock(myArrayList)<br />
{<br />
} <br />
}<br />
this lock(myArrayList is used in all the methods that are working against the arraylist.
The strange thing is that the program freezes on the lock and cant get past it?
Maby i shold use ArrayList.SyncRoot or ArrayList.Synchronized ???
a exemple would be good
Best Regards
SnowJim
|
|
|
|
|
You should be locking on the object returned by SychRoot. Sychronized is just a property that says if access to the arraylist is synchronized or not.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No it's not. ArrayList has an IsSynchronized property that says whether the access to the array is synchronized. But Synchronized is a method that "returns a list wrapper that is synchronized (thread-safe).".
I'd suggest the OP to use the Synchronized method, as it takes care of all the locking by itself. All you have to do is
ArrayList arr = ArrayList.Synchronized(new ArrayList());
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Damn! I'm suckin' this week!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
I want to place all disks in a combo box, so how do I list them?
|
|
|
|
|
|
Hi,
I wanted to know how to get my C# application to have separate configuration files for each user on the same machine.
I have an application called 'myapp.exe' that needs to store user-specific configuration information, preferably in the 'ROOT:\\documents and settings\<user_name>\application data\myapp\useroptions.xml'. I know I can use ConfigurationSettings.Appsettings to read the 'myapp.exe.config' file and get application settings that way but that file must reside in the application folder.
Any ideas?
|
|
|
|
|
|
|
I remember seeing an article on replicating functionality that is avaliable in windows explorer, but cannot seem to find it. If you open up windows explorer, on the left side bar you can collapse and uncollapse areas of the bar such as system task and other places. The article explained how to do that. Any one know how to best find it?
|
|
|
|
|
|
Hey!
Why are the SerialPort freezing when closing?
Its offen no problem when it is a slow data flow, but if it fast then it Freezes?
I have tryed som diffrent things, ex
using Dispose insted
seting boudrate to 1
But this is not helping?
Do you got any ide?
Best Regards
SnowJim
|
|
|
|
|
this is how my close looks like
<br />
public bool closePort()<br />
{<br />
try<br />
{<br />
RUNNING = false;<br />
if (serialPort != null)<br />
{<br />
if (serialPort.IsOpen)<br />
{<br />
lock (serialPort)<br />
{<br />
Thread.Sleep(500);<br />
serialPort.Dispose();<br />
}<br />
}<br />
serialPort = null;<br />
}<br />
return true;<br />
}<br />
catch (Exception ex)<br />
{<br />
addError("Error in " + this.ToString() + " - closePort : " + ex.Message);<br />
serialPort = null;<br />
return false;<br />
}<br />
}<br />
Is this not right?
i forgot to say that i also have an event
<br />
RUNNING = true;<br />
serialPort.ReceivedEvent += new SerialReceivedEventHandler(serialPort_ReceivedEvent);<br />
But this shold not be the problem, i can see the dataflow but not closing the serialport
|
|
|
|
|
Hey again!
If i change to this code, the program is not Freezing but i get an error :
<br />
public bool closePort()<br />
{<br />
try<br />
{<br />
dataCollector.stopWrite();<br />
RUNNING = false;<br />
if (serialPort != null)<br />
{<br />
if (serialPort.IsOpen)<br />
{<br />
<br />
try<br />
{<br />
<br />
Thread.Sleep(500);<br />
serialPort.Close();<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
serialPort = null;<br />
MessageBox.Show(ex.Message);<br />
return true;<br />
}<br />
}<br />
serialPort = null;<br />
}<br />
return true;<br />
}<br />
catch (Exception ex)<br />
{<br />
addError("Error in " + this.ToString() + " - closePort : " + ex.Message);<br />
serialPort = null;<br />
return false;<br />
}<br />
}<br />
There is no siurce code available for the current location
And this error occurs when serialPort.close() is runned
If i press ok on this error i get the following error:
ArgumentNillException was unhandled
value can not be null.
Is there any nice way to close this serial port with out errors.
Best Regards
SnowJim
|
|
|
|
|
Hello,
I'm writing an application where I have to perform this long process, so I create a new thread to keep the UI responsive. I also create a progress form which I have on my main thread. The code looks like this:
void StartProcess()
{
ProgressForm form = new ProgressForm();
WorkerClass wc = new WorkerClass(progressForm, delegate and so on);
Thread t = new Thread(new ThreadStart(wc.Run));
t.IsBackgroundThread = true;
form.Show();
t.Start();
Application.Run(form);
return;
} My idea is to create the thread and the form, display the form, and then start the thread. Also, I want the StartProcess routine to block until the process is completed. I tried form.ShowDialog after calling t.Start , but then the progress dialog misses some progress updates.
I want to create the form as modeless, disabling the parent (not shown in the code) and then start the thread. After that, I want to run a secondary message loop until the dialog is closed, and then return to caller. But I get an exception about it being invalid to create a secondary message loop on a single thread, to use From.ShowDialog or Application.RunDialog instead. But Application.RunDialog doesn't exist (it does, but it's internal .)
So, how can I do it?
[EDIT: I just tried the following code and it seems to work fine:
progressForm.Owner = formParent;
formParent.Enabled = false;
progressForm.Show();
thread.Start();
while(progressForm.Visible)
Application.DoEvents();
progressForm.Close();
formParent.Activate();
formParent.Enabled = true; Any comments on it?]
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|