|
the form which you want to close. the deactivated() event of that form include code this.close();
|
|
|
|
|
I don't understand. What do you mean by deactivated event. Instead of using this.close() do you think I should use Form.ActiveForm.Close();
Sameer
|
|
|
|
|
it's a huge piece of code so I will try and explain it. The form that I am trying to close that is closing my application is:
1. visible=false
2. the part where I call this.close(), I am sending a print job upon which I call this.close().
So, when I call the close, my form is still invisible.
Sameer
Sameer
|
|
|
|
|
How you create this form?
|
|
|
|
|
|
Please,Show me code show/hide form.
Maybe
this.close replace by
visible=false
|
|
|
|
|
here is some code
here is my hide application code:
public void HideApp()
{
//this.WindowState = FormWindowState.Minimized;
Hide();
}
This is when I open the new form which upon closing is shutting down the whole application.
this.timer1.Enabled=false;
try
{
Payment frm = new Payment(m_pDBCnn, m_pDBUserId, m_pDBPassword, EmpId, TermNum, SiteId, TrnNum, LogId, SystemConfig);
if (frm.ShowDialog(this) == DialogResult.Cancel)
{
Status = frm.Status;
if (Status == 1)
{
this.timer1.Enabled = true;
this.PopulateInvoices();
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error in payment, contact Administrator\n" + ex.Message, "SelecSoftware POS™", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Sameer
|
|
|
|
|
The general pattern for this is to have the main form - the one that is hiding in the system tray - own a reference to the other form.
Then when that child form needs to close, either call this.Close() from inside the child form, or have it call an event. The parent form(the one that's hiding) will subscribe to that event, and call Dispose() on it's reference to the child form. That should kill the child form while leaving the parent form running in the system tray.
Just don't call Application.Exit() or it will kill all your forms.
|
|
|
|
|
Do I do this by using delegates?
Sameer
|
|
|
|
|
If you mean the second method with the events, then yes and no. Yes, events use delegates behind the scenes, but no you don't have to actually declare any delegates yourself.
Just declare an event on the child form using the basic EventHandler class, and then inside the parent form you create an instance of the child form, and subscribe to the event with the += syntax. The parent form then provides an event handler(just like button1_Click) and inside that method you can call Dispose() on the child form. Or set it to null, it's basically the same thing.
on the child form:
public event EventHandler CloseMe;
on the parent form:
ChildForm myChildForm = new ChildForm();<br />
myChildForm.CloseMe += new EventHandler(CloseMethod);<br />
and make sure the child form calls that event when it wants to be shut down.
Of course depending on what you're doing, it would probably be easier to just call this.Close() inside the child form, but then the parent form wouldn't know about it.
I haven't used these inline code blocks before, so hopefully that formats ok.
|
|
|
|
|
I am using this.close() in the child form and I believe that is what is shutting down my application. What I have noticed is it shutsdown around the time I send a print job. I have this.close() right after I send the print job.
I am using the same namespace in my child and parent form even though they are a part of a different project, would that cause the issue?
Sameer
|
|
|
|
|
That i'm not sure about. Maybe try handling the Closing event on the parent form, and then put in a breakpoint and look at the call stack. it'd be interesting to see what methods were called right before the main form closes.
|
|
|
|
|
Is there a simple way to do a ASCII to HEX conversion for Intel HEX files? I know how to convert a "3" to 0x33, I need to convert a "3" to "0x03" and a "F" to 0x0F. I am converting an Intel HEX file to binary and they do an ASCII representation of the file.
I need to make a string like "3F" equal to 0x35, two characters into one byte. I have used the following code but it only works with numeric characters, it throws an exception when an alpha character passes into it because of the Byte.Parse method. I have checked Convert class methods but none of them stuck out as a solution.
byte result = 0;
char hi = '3';
char lo = 'F';
byte bHi = Byte.Parse(hi.ToString());
byte bLo = Byte.Parse(lo.ToString());
result = (byte)(bHi * 16);
result = (byte)(bHi + bLo);
Any help is appreciated, Thanks!
modified on Friday, December 5, 2008 11:15 AM
|
|
|
|
|
Hi,
asquaredtech wrote: char hi = "3";
might not compile, since "3" is a string, not a char.
You can parse strings using Parse or better yet TryParse.
You can tell these methods the input is in hex, use an overload with
NumberStyles.AllowHexSpecifier as in byte hiAndLo = Byte.Parse("3F", NumberStyles.AllowHexSpecifier);
You will have to handle Intel hex in pairs of characters, since IIRC it is
little-endian, meaning the bytes in an address are the wrong way up.
modified on Friday, December 5, 2008 11:10 AM
|
|
|
|
|
That conversion worked. Thanks for your help Luc!
|
|
|
|
|
Hi
First off I would like to thank all the members who are a part of this team. Because of your samples we have done many work.
Right now I need to create a IE autofill toolbar using C#. Is there a possibility to do that? If so can you direct me to that link. I am trying hard to get this done. I am hoping that I will get a solution from your team. Please help me. I am in a desperate solution to complete this. It would be great if you can provide me the sample project.
Thanks
Janakiraman
jp
|
|
|
|
|
Google[^]...and the first result is a CodeProject link
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hi
Thanks a lot for your reference. I already have that. That links creates a toolbar for me. Thats fine. I need to add the AutoFill functionality to that toolbar. Is there a sample code to add the autofill functionality to the toolbar.
Please help me. Thanks in advance. I am trying hard to find one, but unfortunately I couldn't get it.
Thanks
Janakiraman
jp
|
|
|
|
|
hi all,
how can i detect if a (any) window is being dragged? Obviously with PInvoke, but I cannot find any C# examples. If anyone has any or could explain, could you please do so?
Thanks,
Maurice
|
|
|
|
|
|
Thanks for the reply,
I need to determine out of process windows being dragged and I need to know which window it is. i.e., get a handle to it.
Thanks,
Maurice
|
|
|
|
|
I am doing a project, which had a requirement of sending an sms message to a mobile from the c#.net.How can i do this.If i need to add any .dll files how can i add those file.
|
|
|
|
|
Can you use COM port and AT command
|
|
|
|
|
The client who install my software connects a bluetooth device. When some event occurs then this software should send an sms to the adjacent mobile through the bluetooth.For doing this, what should i do.
|
|
|
|
|