|
hi!
what should i do when i make use of the ReadFile function from the Packet Analyzer program(by floack), and i get an error saying that "a device attached to the system is not functioning". I am trying to integrate a ping feature to that program when i would send a ping request and wait for its reply. i am able to sucessfully send the request, however when i use the ReadFile to listen to the same port, i get the error stated above. can anyone help me with this problem?
Thanks!
Lots
|
|
|
|
|
Hi, I'm working on a small app that has a tab panel and I need to create a new tab with a few buttons and text boxes each time a text file is opened. My problem is how to create an identical tab each time with all of the same buttons and boxes with all the same code. Any ideas? Thanks.
-NF
|
|
|
|
|
The best way is to extend TabPage with your own class and add all your controls and default logic to that class. Whenever you need to add a new tab to your TabControl , simply instantiate a new instance of your custom TabPage class and add that to TabControl.TabPages .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok thanks for the help, I did what you instructed but the new TabPage will not show up on the form. I looked around for methods that seemed to help update Windows Forms controls. I found SuspendLayout() and ResumeLayout() and also Refresh(). I invoke SuspendLayout on the From, TabControl, and the TabPage before adding the controls to the TabPage, then to the TabControl. Then I do ResumeLayout(false) for all three objects after everything is done. That didn't work so I called Refresh() on everything that I logically could. Still no new tab? I made sure I added the TabPage to the TabControl and everything. Any ideas? Thanks again for your help.
-NF
|
|
|
|
|
Never mind I just had to much code mixed up all over the place, anyway, it works now. Thanks again for your help.
-Noah Fields
|
|
|
|
|
How do I make an input box in C#? Also, how do I make the null value of the text of a label control a condition for an if statement?
|
|
|
|
|
Eric Houser wrote:
how do I make the null value of the text of a label control a condition for an if statement?
if(label1.Text=="")
{...}
Eric Houser wrote:
How do I make an input box in C#?
TextBox Control.
Mazy
You're face to face,
With the man who sold the world - David Bowie
|
|
|
|
|
Actually, null and an empty string are two different things entirely. To check for null (to the original poster), simply use obj == null , where obj is an reference variable (value types cannot be null).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yah, null and emtpy are different but I think he meant that How can I check there is no string in label.
Mazy
You're face to face,
With the man who sold the world - David Bowie
|
|
|
|
|
Hi to all,
I have 3 dialogs which are Parent, Dialog and Child. When I press My Parent dialog's menu I come across with my dialog box. Everything ok for now. But when I press the button on dialog I want my child dialog inside the parent dlg box. I think I made something wrong the code runs without any errors but doesn't make what I want??? Might be a logic failure in somewhere. This trashed all my day (I brainstrom and checked lots of articles about forms...) But couldn't get a result. So any help would be greatly appreciated. I am posting all my 3 file(Sorry for the pollution)
Thank you,
Cem Louis
/////////////
//Parent.cs//
/////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Test1
{
/// <summary>
/// Summary description for Parent.
/// </summary>
public class Parent : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Parent()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "Show Dialog";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Show!";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// Parent
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Parent";
this.Text = "Parent";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Parent());
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Test1.Dialog Dialog = new Test1.Dialog();
Dialog.Show();
}
}
}
/////////////
//Dialog.cs//
/////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Test1
{
/// <summary>
/// Summary description for Dialog.
/// </summary>
public class Dialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Dialog()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(104, 104);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Show Child";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Dialog
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1});
this.Name = "Dialog";
this.Text = "Dialog";
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
Test1.Child chform = new Test1.Child();
Test1.Parent Parent = new Test1.Parent();
chform.MdiParent = Parent;
chform.Show();
}
}
}
////////////
//Child.cs//
////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Test1
{
/// <summary>
/// Summary description for Child.
/// </summary>
public class Child : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Child()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Child";
}
#endregion
}
}
|
|
|
|
|
Hi,
I think I know the problem.
When you launch the program, you create an instance of the class "parent". But since you do not pass the object to Dialog, you can't refer to it there.
Here's what I did that seemed to produce the effect you want:
1) modify Dialog.cs so that you can store the parent object somewhere. Add this on line 20 or so
<br />
public class Dialog : System.Windows.Forms.Form<br />
<br />
{<br />
private Form MainForm;
<br />
private System.Windows.Forms.Button button1;<br />
2) Modify the constructor for for Dialog so you can pass it a the parent.
<br />
public Dialog(Form frmMain)
{<br />
InitializeComponent();<br />
<br />
this.MainForm = frmMain;
}<br />
<br />
3) Pass the parent object when you instantiate the form...in Parent.cs
<br />
private void menuItem2_Click(object sender, System.EventArgs e)<br />
{<br />
Test1.Dialog Dialog = new Test1.Dialog(this);
Dialog.Show();<br />
}<br />
4) Then (finally!) set the mdiparent for the Child
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
Test1.Child chform = new Test1.Child();<br />
chform.MdiParent = this.MainForm;<br />
chform.Show ();<br />
}<br />
Hope this helps! I can send you the source code if this post doesn't get the message across...
Bill
|
|
|
|
|
//bill dean says kids, stay in school
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Hi Bill,
Thank you very much, I don't need the source, I got the idea...
Thank you again.
Cem Louis
|
|
|
|
|
Hello,
I am interested in creating a program to handle large a mailing list and help eliminated bounced messages by doing e-mail validation. I've looked at articles on this site and elsewhere on the web, and it appears that most of the validation approaches include validating the e-mail address syntax with regular expressions, then validating that the domain exists, then connecting to the smtp server and making sure that it will accept mail for a certain address. However, I have read that this will not work for some e-mail providers, such as aol, hotmail, servers based on ms outlook, etc. and that the only way to find out if an e-mail address is really valid for these is to wait and see if the message bounces back.
Does anyone know of a sure way to validate all e-mail addresses, or is it just not possible?
I guess if there is no 100% correct way, then I can try to combine the two approaches by first checking addresses by contacting the smtp server, and then also analyzing bounced messages.
Thanks for any input.
Blake
|
|
|
|
|
I did this for a large email list, and in the end, it was mostly a waste of time. You can forget getting anything from AOL. When I tried it, hotmail and msn actually did verify the addresses. I'm not sure if that's still true.
You end up creating a fairly complicated program to handle all of the conditions (couldn't find the MX record, couldn't connect to any of the given MX's, try again later? how many times?).
You'll get so many false positives (SMTP servers that say "sure, I'll send email to fred@... when fred doesn't exist). Depending on your connection, you'll also run into servers that won't even allow you to connect ("you're on a cable modem? you have no business trying to relay mail...").
Don't get me wrong, it's a pretty fun project. Just don't expect to get too much valuable information from it .
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
You can validate the actual email address string. There is an RFC that defines valid addresses. The regex string below is the most common:
^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$ As far as validating the MX records, the other poster was correct that it's not 100% effective, but it's at least worth a shot (while you may get false positives, you will get correct rejections). See http://www.codeproject.com/aspnet/emailvalidator.asp[^] for a good article on MX validation, although there are others. Just try this search[^] (watch the ratings to filter the bad ones).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
From what I understand, the RFC allows a LOT of crap that "nobody" uses. For instance, fred@123.123.123.123 (IP address) is supported in the RFC.
There's also a lot of people who try to check things like the length of the TLD (2 - 6 characters for the museum TLD).
I'm currently using the regular expression here. It's a pretty decent one. Also notice how many submissions there are on that site for email regular expressions. Some people stick to the RFC and some people realize the RFC is not quite restrictive enough for "real" usage.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Can I use that mx validator component in a C# program?
|
|
|
|
|
Unmodified, no. A validator in ASP.NET takes the name of a control which it finds in in the control collection of the container. This wouldn't work for Windows Forms. You can use the code, though. There's other code out there as well, including an MX validator I wrote a long time ago that I believe I posted in this C# forum over a year ago. Good luck finding it, though. In any case, DNS queries are a standard so the only real difference in code is how you do it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Blake,
Just my two cents. I had this same problem where I work with a list of over 2 million. The final solution that I implemented was to send all of the emails with a unique identifier in the return address. Like so: member_number@yourdomain.com.
Then when a bounce occurs, the email will come back to our server. I use exchange so I had to write an event sink to parse the email address that was coming in and get the member number from whence it bounced and then update that member's email valid in our database. Not sure if this will work for you depending on your setup.
It was tricky but we have it running perfectly now and we now bounce only 2% of our very large lists. One thing we had to keep in my mind was that there are different types of bounces, hard, soft, etc... Most mail servers will send this information back to you in the "bounce" email header and it is up to you to handle it accordingly. For us, we allow 3 soft bounces or one hard.
Like I said, it was a little tricky but we cut our bounces down DRAMATICALLY. If you are interested in the details and some sample code, just reply here and I will get it to you.
Thanks,
Troy G
|
|
|
|
|
Troy,
This is exactly what I have been thinking about doing (I read an article about it on this website), and I thought that I might even combine it with the MX checking that other people had posted about.
I would love to see some details and code if you want to send it to me. Maybe I can figure out a way to make it work for our purposes. You can send it to blakeb_1@hotmail.com
Thanks a lot
Blake
|
|
|
|
|
Troy,
Actually, I've just realized that this isn't going to work because the mailing list program we are using isn't going to allow to do any extra programming.
I think I might just stick to verifying through the smtp servers for now, and hopefully it will at least cut down on a little of the bounces. Thanks for offering to send some code though.
Blake
|
|
|
|
|
Hi Troy G,
I am working on a project where i need to track bounced mails and update the database with types of bounce. I am able to send a unique identifier in the return address. Each time there is abounce the mail with the unique identifier is there in the bounce box. Now, the problem is reading the Headers like the member_number in member_number@yourdomain.com and the bounce type and updating it to the database. If u have any idea or code that can do this, then it would really be a great help.
I am interested in getting the details. Thanking you in advance.
With Warm Regards,
Arvind
|
|
|
|
|
I created a control based on pictureBox with transparency. Worked great until I openned the Windows 2000 task manager. Blam, the transparency is gone! Fiddled for a while and got it back, tried the task manager again and blam, transparncy is gone again. The same executable still has transparency in XP.
Whazup?
Thanks in advance.
|
|
|
|
|
Are you using TransparentBackground style? If so, overrice CreateParams, so if the window does need to recreate it self, it will do so properly.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|