|
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
|
|
|
|
|
Hello,
I'm trying to implement an e-mail validation program for a large mailing list, and I've run into a few problems.
So far, I have code that correctly checks all the syntaxes, and I have code that will check if an address is valid when it is given a list of mail exchanges, however, I can't get my code that actually retrieves the MX servers to work.
Does anyone have any code for MX lookup? I found the code I'm currently using at: http://groups.google.com/groups?selm=eMOLVL2WDHA.652%40tk2msftngp13.phx.gbl&oe=UTF-8&output=gplain
I can't tell if there is something wrong with the code or if I am just not using it correctly. Here is how I am trying to intialize the DnsLite class:
<br />
ArrayList mxRecords = new ArrayList();<br />
<br />
IPHostEntry IPhst = Dns.Resolve(hostname);<br />
<br />
DnsLib.DnsLite dnsStruct = new DnsLib.DnsLite();<br />
<br />
ArrayList dnsList = new ArrayList();<br />
for(int j = 0; j < IPhst.AddressList.Length; j++)<br />
{<br />
dnsList.Add(IPhst.AddressList[j].ToString());<br />
}<br />
<br />
dnsStruct.setDnsServers(dnsList);<br />
mxRecords = dnsStruct.getMXRecords(hostname);
This doesn't seem to be working correctly. Does anyone know if this code looks like it should work, or if there is better code examples of MX lookups anywhere that I look at.
Thanks, Blake
|
|
|
|
|
I just covered this the other day. You might try searching this forum. There's also an article here about an email validator for ASP.NET that uses Managed C++. It has MX code in there as well (which I mentioned in that previous thread), similar to the same code I used and posted here a while back. See A Managed C++ Email Validator Control for ASP.NET[^]. It's a good article, and the managed code can be translated to any .NET language you like if you truly understand the nature of the .NET Framework (syntax is different, classes, etc. are the same).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a client form that uses a remote object 'RemoteDataManager ' as follows:
RemoteDataManager r = new RemoteDataManager();
r.Test();
This works correctly, Test is executed like it should. However, this method takes a while to complete, so I'd like to make it a asynchronous call. So I tried:
RemoteDataManager r = new RemoteDataManager();
AsyncCallback RemoteCallback = new AsyncCallback(OurRemoteAsyncCallBack);
TestDelegate RemoteDel = new TestDelegate(r.Test);
IAsyncResult iar = RemoteDel.BeginInvoke(RemoteCallback, null);
This runs, but the Test method is never executed!
I don't know where to look for... does anyone have a clue?
Kind regards,
Ludwig
|
|
|
|
|
If you're using .NET 1.1 and catching exceptions, it's possible you might have the same problem discussed earlier here[^]. Stepping through your code in the debugger might shed some light on your problem, too, because from what little you provided all I can say is that your code looks fine.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
After two days I found out why it didn't work. Originally my config file contained:
<channels>
<channel ref="http">
</channels>
I changed it into:
<channels>
<channel ref="tcp">
</channels>
and all of a sudden the methods was also called asynchronously. I still don't know why, but it works now.
For your information, I wanted to use asynchronous calls because my remote method lasted 10 minutes to complete. I ran into another issue however, and I want to mention it here because it took me a while to find a solution. After 2 minutes or so, the thread was aborted on the server and my callback method was never called (the method was executed correctly though). So it worked, but I never got callback because the server thread ended. I solved this by dynamically increasing the script timeout that IIS uses:
System.Web.HttpContext.Current.Server.ScriptTimeout = 1800;
Now it works... but it was hard to find the solution
|
|
|
|
|
You realize that when you put the < and > characters into an HTML input field that they won't show up, right? Your XML for your .config file isn't visible. Please click "modify" on the bottom of your message and either escape these characters or click the "Do not treat <'s as HTML tags" check box right below the posting textarea. Note that any tags you use (like the <code> tag you put your last line between) will be escaped as well, so you'd best remove them.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|