|
Try this. I added 2 lines of code, one in the "Owner" form (btnGo_Click), and one in the "Owned" form (btn1_Click). Good Luck!
class MainForm : Form
{
 Button btnGo = new Button();
 public MainForm()
 {
  Text = "Main Form";
  btnGo.Location = new Point(100,100);
  btnGo.Name = "btnGo";
  btnGo.Text = "Go";
  btnGo.Click += new EventHandler(btnGo_Click);
  Controls.Add(btnGo);
  Opacity = 80;
 }
 public static void Main(string[] args)
 {
  Application.Run(new MainForm());
 }
 private void btnGo_Click( object sender, EventArgs e)
 {
  Form2 x = new Form2();
  x.Owner = this;
  x.ShowDialog();
 }
}
class Form2 : Form
{
 Button btn1 = new Button();
 public Form2()
 {
  Text = "This is the second form";
  btn1.Text = "Do it";
  btn1.Location = new Point(100,100);
  btn1.Click += new EventHandler(btn1_Click);
  btn1.Name = "btn1";
  Controls.Add(btn1);
 }
 private void btn1_Click(object sender, EventArgs e)
 {
  //Here is where I want to modify the main form.
  // How would I go about changing, let's say, the Title?
  this.Owner.Text = "HOWDY";
 }
}
Andy Gaskell, MCSD
|
|
|
|
|
Perfect! Except for the fact I didn't add the control.
Thanks...
|
|
|
|
|
In Java, you can create an instance of an object by name by getting the Class object by name, and then calling createInstance() - or something like that.
Is this possible in C#? It looks like I might be able to do it through assemblies, but I'm not sure.
Application: I want to be able to provide a configuration file that lists the class names of add-ins to load. The app would loop through these names, create instances and use them.
I know I can do it with COM, but I'd rather not subject the authors of add-ins to writing COM servers.
Anyways, is this possible?
J
|
|
|
|
|
You can use the Assembly class to load assemblies at runtime, the GetType function to get an object's type, and the Activator.CreateInstance static function to create an object of that type:
Assembly a = Assembly.Load("MyLibrary");
Type t = a.GetType("MyLibrary.MyClass");
object obj = Activator.CreateInstance(t);
cheers,
Chris Maunder (CodeProject)
|
|
|
|
|
How to search for files/folders and adding all the found filenames to a collection.
For exemple :
Search all "*.url" files on "C:"
Thanks
|
|
|
|
|
The things you need is located in the namespace System.IO... I would do it like this:
using System.IO;
public void FindFiles (string path)
{
if (Directory.Exists (path))
{
DirectoryInfo thisDir = new DirectoryInfo (path);
FileInfo [] files = thisDir.GetFiles ("*url");
DirectoryInfo [] subDirs = thisDir.GetDirectories ();
foreach (FileInfo f in files)
{
}
foreach (DirectoryInfo d in subDirs)
{
FindFiles (d.FullName);
}
}
}
Andreas Philipson
|
|
|
|
|
My boss says...
I need to create MS Word 97/2000 documents using C#.
In other words, we want to use MS Word to display the output from a C# program.
Things will change in the Word document like address, date, From, To and some accounting data pulled from our Oracle database.
Of course, I'm a 3 month newbie to .NET & C# programming.
Can anyone kick start me with some examples/code/book recommendations?
I've got my "Learn C# in 21 Days" book ordered...
-Larry
|
|
|
|
|
Basically, what you'll need to do is use the Word OLE interface from COM interop.
As a first step, in VS you add a reference to the word exe (I think) to your project, and that will give you a managed wrapper around the COM interfaces.
You can also do this from the command line with tlbimp.
|
|
|
|
|
Hi,
Does anyone know how to write a COM server in .Net?
// Christian
|
|
|
|
|
Create your .NET dll first
Now use regasm on it.
Now you can use this component using late binding
if you want early binding use tlbexp in it to generate a type library file
Nish
|
|
|
|
|
I'm looking for an example to create a out-of process local com server (.exe file)
// christian
|
|
|
|
|
I am programming using C# && .netframework(beta 2). now i have some problems about mdi application:
1: I create mdi child window based on System.Windows.Form. I want to show the child window with the main window. it have been created at Mainface.Mainface(); but i don't know where to load the Show() procedure;
2: I need to modify the system menu of child window, but how to get it's handle. In Win32, can use GetSystemMenu(), but in .netFramework there are no method like that.
3: Only set the Dock property of Form, the Form cannot dock properly in the main window. The phenomena is that when i create another mdi child window and maximize it , this window will cover the docked window. Why ?
The Internet Give a Chance to Learn. I Do!
|
|
|
|
|
hi, i just started to learn c++ at school. so this is a very newbie question...but how do u convert a char into an int??
|
|
|
|
|
This is the C# forum, not the C++. You should try and ask questions in the right place.
A char *is* an int, you can do this
char a = 65;
int i = 'A';
int z = 5;
z += a;
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Ok, it depends on what you want to do though. Are you talking about having a character such as '4' which you want the value 4? Or are you talking about what the Graus-man said and want the ASCII value of the character?
Here is an example:
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
char c = 'A';
char d = '4';
int i = 0;
printf( "Character '%c' is %d in ascii.\n", c, c );
printf( "Character '%c' is %d in ascii.\n", d, d );
printf( "Character '%c' is %d as an integer.\n", d, atoi( &d ) );
}
That yields the output :
Character 'A' is 65 in ascii.
Character '4' is 52 in ascii.
Character '4' is 4 as an integer.
I hope that helps you out!
----
Xian - www.hollowmedia.net
|
|
|
|
|
If is a char to int use that Christian Graus said but if String to int, you only need to use the atoi function...
Cheers
Carlos Antollini.
|
|
|
|
|
I've been playing with .NET quite a bit in my spare time just writing WinForm apps, playing with the new controls, classes and of course, learning C#. I started thinking about real world uses for .NET and my first instinct was how it might work at my company. Here's what I'm up against.
I have a ton of 16-bit C++ MFC code here. I was hired in to get this code moved over to 32-bit and begin enhancing on the 32-bit side. We also have a "webmaster" here who's using Java to take bits and pieces and "webify" it.
What I'm curious about is that the application we have is a fairly standard client/server application with an Informix database on the back end. We have a bunch of clients with special conditions that need to be accounted for as well.
I guess my question is, is it going to be possible for me to take a client/server (in the old sense of the word) and make it something where I can have a Win32 (WinForm) application and use the same DLLs or modules and also build a web interface? How do I go about doing something like this. I'm thinking about putting together a proof of concept application together for my boss.
Thanks.
http://www.ratebeer.com
|
|
|
|
|
Hi,
Your DLLs will be able to be used in both Winforms and Webforms. The efficiency of the implementation depends on the how you use the DLLs. If you want to talk about it some more, I would need to know a little more about the application (client and server side) architecture.
Cheers!
Colin
|
|
|
|
|
I think .NET will be great for IT departments, consulting firms, service providers, and the likes. From their press releases, I also think that MS develop .NET with these people in mind.
However, I haven't heard their views on .NET for commercial application development.
Personally, I don't think .NET haven't much to offer on this area except improve time-to-market. However, .NET runtime will surely penalize apps runtime performance.
Any views on this one?
|
|
|
|
|
.net runtime is the child of Pcode. Pcode is semi-compiled thingy whatsit (dam sh*t I've forgotten the word for it). Any way this Pcode can in many cercumstances run faster or be smaller than its local machine specific counterpart.
I bet you want me to explain how don't you?
Darn it man, its been a million years since I read this in Program Now (do you remember that one, sigh, memories).
Its something to do with the way Pcode can share functions at a level very close but not quite at machine level. Oh bugrit I can't remember. It just is ok!?
We do it for the joy of seeing the users struggle.
|
|
|
|
|
I know how to change a control's border style -- as in BorderStyle.FixedSingle or BorderStyle.Fixed3D, this is just a property of a control that can be set. How do I actually change the color of a BorderStyle.FixedSingle border though? The default black, but I want light gray borders like the caption and tool window borders in Visual Studio.NET
Thanks.
|
|
|
|
|
I have an application that allows users to, using the mouse, click and hold a control and move it to another location on the form.
How do I draw that un-filled drag rectangle that shows the user that they are moving something around. I need to be able to draw this drag rectangle anywhere on the screen (on the app, over other controls, on the desktop) not just on the application itself.
Your help is appreciated.
|
|
|
|
|
The class 'System.ControlPaint' has some methods with the name 'Reversible' in them that draw onto the screen. If you use FillReversibleRectangle then you could draw four of them to get the drag rectangle you are looking for. There is only one problem with this though, you have to give a Color and so it will be a solid border around your control and not the stipled effect you want.
|
|
|
|
|
Write a program that inputs ONE 2-digit number (%d) ,
output the number by separating the number into its individual digits by a new line.
eg. input 76 output 7
6
eg. input 99 output 9
9
how to write ?
thx~~
RR
|
|
|
|
|
int inputnr;
int ten;
int one;
ten = (int) inputnr / 10;
one = inputnr % 10;
cout << ten << "\n" << one;
think this should work... at least i hope so..
bernhard....
"Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|