|
Ooops, sorry, I didn't notice that you posted this in three different forums and already received a response.
Oh, and SQL questions should, by and large, be submitted in the SQL forum.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
Can C# Control Serial Port?
Which class in .NET Framework is for SerialPort Communicate Programming?
thanks a lot.
|
|
|
|
|
For low level communication you can write to the virtual file "COM1".
|
|
|
|
|
Dear Corinna John
Can you explain for detail how to write to the virtual file "COM1"
in c#?
Thanks a lot!
|
|
|
|
|
Usually you open a file with the name of the serial port (COM[x]). The file doesn't exist in the file system. Whatever you write to the "file" will be sent to the serial port, messages from the device can be read from that virtual file.
FileStream fs = new FileStream("COM1", FileMode.OpenOrCreate);<br />
fs.Write(...);<br />
fs.Flush();<br />
It worked with other languages, I think it should also work with .NET
|
|
|
|
|
Can you do that with (LPT1)?
/\ |_ E X E GG
|
|
|
|
|
As far as I know, you can do that with every port.
|
|
|
|
|
Hi there
I want to open a child form from a dialog form (.ShowDialog)
and after the child form shows i want to close the dialog form.
In the Dialog form there are 2 buttons:
1) btnclose which closes the dialog form
2) btnOpenChild which opens a child form and then closes itself (the dialog form)
What should i do to get my desired result?
I have included the codes to all the forms so that it may
become easier to understand what i want to do.
I am a total newbie, so plz do bare with me!
Any help will be gr8!
Thanks in Advance
VisionTec
******************************
Form1 ( Main MDI Parent Form )
******************************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnChild;
private System.Windows.Forms.Button btnDialog;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.btnChild = new System.Windows.Forms.Button();
this.btnDialog = new System.Windows.Forms.Button();
this.SuspendLayout();
this.btnChild.Location = new System.Drawing.Point(72, 112);
this.btnChild.Name = "btnChild";
this.btnChild.TabIndex = 1;
this.btnChild.Text = "open child";
this.btnChild.Click += new System.EventHandler(this.btnChild_Click);
this.btnDialog.Location = new System.Drawing.Point(208, 112);
this.btnDialog.Name = "btnDialog";
this.btnDialog.TabIndex = 2;
this.btnDialog.Text = "open dialog";
this.btnDialog.Click += new System.EventHandler(this.btnDialog_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(408, 413);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.btnDialog,
this.btnChild});
this.IsMdiContainer = true;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnChild_Click(object sender, System.EventArgs e)
{
WindowsApplication1.frmChild child = new WindowsApplication1.frmChild(this);
child.Show();
}
private void btnDialog_Click(object sender, System.EventArgs e)
{
WindowsApplication1.frmDialog dialog = new WindowsApplication1.frmDialog();
dialog.ShowDialog();
}
}
}
*************************
frmDialog ( Dialog Form )
*************************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
public class frmDialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnOpenChild;
private System.ComponentModel.Container components = null;
public frmDialog()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.btnClose = new System.Windows.Forms.Button();
this.btnOpenChild = new System.Windows.Forms.Button();
this.SuspendLayout();
this.btnClose.Location = new System.Drawing.Point(32, 96);
this.btnClose.Name = "btnClose";
this.btnClose.TabIndex = 0;
this.btnClose.Text = "Close";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
this.btnOpenChild.Location = new System.Drawing.Point(152, 96);
this.btnOpenChild.Name = "btnOpenChild";
this.btnOpenChild.TabIndex = 1;
this.btnOpenChild.Text = "open child";
this.btnOpenChild.Click += new System.EventHandler(this.btnOpenChild_Click);
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.btnOpenChild,
this.btnClose});
this.Name = "frmDialog";
this.Text = "frmDialog";
this.ResumeLayout(false);
}
#endregion
private void btnClose_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnOpenChild_Click(object sender, System.EventArgs e)
{
}
}
}
***********************
frmChild ( child form )
***********************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace WindowsApplication1
{
public class frmChild : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public frmChild(WindowsApplication1.Form1 parent)
{
InitializeComponent();
this.MdiParent = parent;
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "frmChild";
}
#endregion
}
}
}
|
|
|
|
|
Well...I could not get your stuff to run (I think you forgot to paste the InitializeComponent() methods), so take this all with a grain of salt.
You could just handle the closed event on your dialog form. Change / add this to form1
private void button2_Click(object sender, System.EventArgs e)
{
WindowsApplication1.frmDialog dialog = new WindowsApplication1.frmDialog();
dialog.Closed += new EventHandler (vShowChild);
dialog.ShowDialog();
}
private void vShowChild(object sender, EventArgs e)
{
WindowsApplication1.frmChild child = new WindowsApplication1.frmChild(this);
child.Show();
}
Then just close the dialog:
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
Hope this helps,
Bill
|
|
|
|
|
Hi there
Thanks for the help
but i actually want the child form to load
when the user wants it to.
so i have added another button to the Dialog form.
i have updated the code on the discussions board
and also uploaded the source code to my website:
http://www.geocities.com/talhatec/downloads/WindowsApplication1.cab[^]
the code is only 14K
plz help me once again!
VisionTec ( TEC )
|
|
|
|
|
|
i am using Linux and i want to ask how can i record the sound from sound card, say 5 seconds, by using C.
is there a major difference between C and C#
suki
|
|
|
|
|
Yes. Not only are they different languagues, they run on entirely different runtimes. Currently, C# (and all .NET, since all .NET languages compile down to Intermediate Language (IL)) is barely supported on linux through the Mono project.
For more information about .NET and what you can't do on linux, see http://msdn.microsoft.com/netframework/[^].
And if you tried this in Windows, you'd best try Managed DirectX and the Microsoft.DirectX.DirectSound.Capture class.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Eos is an aspect-oriented extension for C# similar to AspectJ for Java. The compiler support is in preliminary stage now. Eos version 0.2-Beta was released recently and more mature versions are expected soon. Eos is available from http://www.cs.virginia.edu/~eos [^]
|
|
|
|
|
We have an interesting, but perhaps not uncommon, system integration and architectural challenge, since our principle line-of-business application runs on a mainframe (“zSeries” it’s called these days) hosted, supported and controlled by our biggest vendor. So, we connect to the application using 3270 terminal emulation (“Rumba”) that connects through Microsoft SNA, er…, Host Integration Server. Plus, since it is 3270 through SNA, TN3270 isn’t an option, either. We have no direct control over things that run on the mainframe, i.e., we cannot run APPC programs or execute CICS jobs. We can only choose menu options and enter characters on existing screens. So, I want to be able to do that automatically.
And, I’ve been doing research. I’ve found stuff about HLLAPI and WinHLLAPI. Neither of these sounds very robust (Daniel Turini posted a response about those alternatives to someone else’s inquiry about screen scraping here on CP). I’ve found several vendors (SDI, ClientSoft, NetManage, Zephyr Corp) who offer expensive legacy application/host integration packages that sound like they’ll do the job, but the prices are pretty high.
So, what I’d like to know is: 1) if you confronted such a challenge on a project, what solution did you use? 2) how has that solution worked out? 3) if there is a low-cost, non-proprietry solution, what is it and are there code samples? Your insights and experience are appreciated.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
Hi Guys,
I have a problem regarding postback. I hid the <input type=file>
html control named myFileBrowser and simulated a click event to this
html control using javascript. After selecting a file in the Open
file dialog, i copied the contents of the file html control into
another input box named dummyfile. However, I noticed that I had to
click the <asp:Button> (named Button1) twice before I get a
load/postback event in my c# code. I placed a breakpoint in the
Page_Load method of my c# code to check this. I also tried
submitting the form (named Form1) in the javascript part right after
copying the contents of myFileBrowser to dummyfile, but it
complained of an error. The error was "Access Denied" with Code = 0.
Can anybody help me regarding this problem? Been stuck with this for
a long while now. The code is below for your reference.
Many thanks in advance.
-Chris
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<p>File Name: <input id="myFileBrowser"
style="DISPLAY: none" type="file" size="60" name="filAttachment"
runat="server">
<input id="dummyfile" type="text"
onchange="document.getElementById('myFileBrowser').value =
this.value;"
size="60"> <input
onclick="document.getElementById('myFileBrowser').click();
document.getElementById('dummyfile').value = document.getElementById
('myFileBrowser').value; return false;"
type="image" height="20"
width="40" src="file:///C:\Inetpub\wwwroot\_imgs\btn_off_cal.gif"
name="browse">
</p>
<input id="btnOk" title="Ok" type="button"
value="Ok" name="btnOk" runat="server">
<input id="btnCancel" title="Cancel"
onclick="doOnCancel()" type="button" value="Cancel"
name="btnCancel">
<asp:Button id="Button1" style="Z-INDEX:
101; LEFT: 344px; POSITION: absolute; TOP: 152px" runat="server"
Text="Post Back"></asp:Button></form>
</body>
|
|
|
|
|
c cochran wrote:
Can anybody help me regarding this problem?
Try the ASP.NET[^] forums.
- Nick Parker My Blog
|
|
|
|
|
Hi,
How do I add a "Minimize to tray" button in the title bar of a form?
Thanks,
Josef
|
|
|
|
|
The .NET Framework base class libraries do not contain functionality for working with the non-client areas of a window frame (other than setting the caption, setting the border style, and showing or hiding the control, minimize, maximize, adn restore buttons). In order to do this, you have to go back to Win32 practices of handling notification messages, so Win32 programming experience will help.
You can find an old discussion of the process here: http://www.dotnet247.com/247reference/msgs/35/178321.aspx[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
There are two alternatives to Heath's reply, but his suggestion is the best.
Alternative 1: Show absolutely none of the border area (there are properties in Windows Forms that you can use to hide them). Then, draw all the content you want on your own, putting normal buttons wherever you want them. The problem is that you must handle "hit testing" in order to let the user drag or resize the window, since Windows no longer does that work for you. There are several places to find information about that. Look to handle the WM_NCHITTEST message.
Alternative 2: Create a separate form that floats over your main window. It would contain only the button(s) that you desire, with no border or spacing. Once that window is created, you can manually position it to sit wherever you like. The problem is that the window is free-floating, so you need to reposition it every time your main form is moved or resized. This is the ugliest solution, since the users can see this button lagging while the rest of the window moves nicely.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Anyone have a suggestion on how I can manipulate file permissions? I'm referring to what you find if you right-click a file and choose Properties, and then the Security tab. I'd like to programmatically set the groups and names, etc., but I'm not seeing a way to access this.
-- James --
|
|
|
|
|
Win32Security[^], produced by Microsoft, should be what you need.
--
Russell Morris
"So, broccoli, mother says you're good for me... but I'm afraid I'm no good for you!" - Stewy
|
|
|
|
|
Thanks Russell. That's the ticket.
-- James --
|
|
|
|
|
So far, I've been able to parse an XML file a couple different way. The problem I've encountered is that I am not able to find a C# code example how to modify or add data to an existing XML file.
Where can I find sample C# code to accomplish this?
|
|
|
|
|
You can load the document into an XmlDocument class (Load method) and then start adding XmlDocumentFragment's as children to the various XmlNode's inside the XmlDocument. Once you've got the document modified, then you could save it out using the Save method.
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
|
|
|
|
|