|
It seems that it's not possible, to fit a Windows Form in a Control (such as a Panel, for instance). I can think of a few good reasons why that's true, but I'm just doublechecking. It'd be pretty handy for me if I could fit a Form in a Control, so I don't have to replicate many things; MDI Forms in a Control would be even nicer.
|
|
|
|
|
Here's very quick fix (one I remember Paul Watson enjoyed):
Let your form inherited from UserControl instead (mite need 1 or 2 changes). Then just drop that in a form with filled docking.
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
There are at least two ways to go about it, the first is the best way if you can modify the design which you have given above.
The second is what you'll have to do if you have no choice but to leave it as a Form. You won't get any design time support for it either, but something is better than nothing
Since the Form class inherits ultimately from the Control class it is possible for a Form to be added as a child control.
To do this, first create an instance of the Form (MyForm mf = new MyForm() ). Now set any properties you want on it, especially the Location , and Size properties. Now set the TopLevel property of the form to false (mf.TopLevel = false ). You may or may not see this property in the IntelliSense pop-up, don't worry it is there
Now add the form to the Controls collection, Controls.Add( mf ); . Lastly you need to make the form visible, mf.Visible = true .
All together now:
MyForm mf = new MyForm();
mf.Location = new Point( 8, 8 );
mf.Size = new Size( 150, 300 );
Controls.Add( mf );
mf.Visible = true;
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Just some dry, semi sober humor for you folks
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
|
Go unsafe
Also post some code and give an explanation of the unmanged function you are trying to use. Your bets are string and StringBuilder, depending on the situation.
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
see title
I see dumb people
|
|
|
|
|
See previous post
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
You probably don't need to since the marshaler does this as part of his job.
In case you are using .NET 1.0 and encounter marshaling limitations (there are a few bugs), you may do the marshaler's job by creating a block yourself : IntPtr pCharBlock = Marshal.AllocHGlobal(nSize); . More info here[^].
|
|
|
|
|
|
I have a varible that is declared in the main application form as public. How can I get at this varible from another form. I have tried accessing the forms varible via Form1.varible and this.ParentForm.varible and so forth. All to no avail and I need to have access to this varible from anywhere in the program. Any suggesttion would be greatly appreciated.
|
|
|
|
|
DId you cast it (the form) to your form before you tried to access it?
draco_iii wrote:
All to no avail and I need to have access to this varible from anywhere in the program.
I suggest making a "static" class then to hold these variables.
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Made the static class for the variable it look like this
<br />
using System;<br />
using Perpetual_Settings;<br />
namespace Brazen_Mail<br />
{<br />
public class Setting<br />
{<br />
public static Perpetual_Settings.PerpetualSettings test = new PerpetualSettings();<br />
static Setting()<br />
{<br />
test = new PerpetualSettings();<br />
}<br />
}<br />
}<br />
But when running the code I get this error.
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.windows.forms.dll
Additional information: File or assembly name Perpetual Settings, or one of its dependencies, was not found.
I can see the Properties and Methods from the class when trying access them via VS, but it craps out when I try and run the program.
|
|
|
|
|
Spaces in general is a BAD idea spawned from some VB coders on crack. NEVER use spaces. I assume your dll is called "Perpetual Settings.dll".
Spaces are used to space code elements, not making pretty names.
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Thanks. As soon as I got the space out of the name it worked perfectly. There needs to be a an article about making a static varible class. It is the best way I have seen to have global varibles.
|
|
|
|
|
this.ParentForm returns a System.Windows.Forms.Form class type, not your derived class.
In fact, this.ParentForm is mostly used for UI logic. For your application logic, it's better to either let the two forms know about each other existence or, better, share a property bag class (better in terms of decoupling).
|
|
|
|
|
How do you go about letting them know about each others existance or at least letting the child forms see full existance of the main running form? I need to be able keep one set of the varibles not multiple instances so that they can be written to or read from by any of the child forms. Doing so, would allow less overhead and insure that all of the child forms are working from the same set of "settings".
|
|
|
|
|
I'm not sure if this is the correct way of doing things, but I have been able to access properties and function in parent/child forms like this.
ChildForm child = new ChildForm();
child.Owner = this;
((ChildForm)child).PublicProperty = MyVal;
Then you can access the parents public properties like this
((ParentForm)Owner).PublicProperty = MyVal;
((ParentForm)Owner).PublicFunction();
I know that this works, but is it the correct way of doing things? And if there is a better way of this, any example code on this?
|
|
|
|
|
This may or may not be useful to others, but seems to be a bug that may be a source of frustration for web service developers.
I was going through the walkthrough in msdn entitled
"Walkthrough: Creating a Distributed Application"
Everything worked fine until I got to the web service part.
Whenever the test app called the GetAuthors method the
web service method is not invoked, instead, I get a timeout error.
I pulled my hair out for days on this one and after trolling through the google newsgroups found a single post from someone who had found a problem when running a background process at low priority.
Ref: http://groups.google.ca/groups?selm=TUgx9.78009%24wG.281797%40rwcrnsc51.ops.asp.att.net&oe=UTF-8&output=gplain[^]
I was also running a background process but a different one. It's like the distributed processing SETI app. only its for a distributed computing cancer research instead.
Ref: http://www.grid.org[^]
Here is what he wrote and exactly what I found as well:
Conclusion: The Web Service "Invoke" code on the WebClient side is
succeptible to being locked out of processing time by an active background
process. However, once successful, this invocation is "cached" for a limited
amount of time and subsequent calls do not exhibit the lockout. However^2,
after a delay between invocations of t seconds, where t is some value less
than 181 seconds, subsequent invocations are again locked out.
|
|
|
|
|
Hi,
I'm working on a multi-threaded application that has Windows Forms/controls.
I'd like to have some controls handle some non-UI events that are spawned in
background threads. Currently this is causing me trouble because those
event handlers may create new controls, and only the Windows Forms thread
can do that sort of thing.
Right now I'm using an EventManager or EventSet, as described by Richter's
Applied .NET Framework programming. Both controls and non-controls might
subscribe to these events. The controls' event handlers may create new
controls, so the controls' event handler should be Invoked. Is there a clean
way to fire off event handlers if I don't know a priori if the event handler
is in a control?
Are there known ways to fire events generally where the subscribed event
handlers may be in controls (and need to execute in the Forms thread) or
not?
Thanks,
Arun
|
|
|
|
|
if (control.InvokeRequired)
{
control.Invoke(control.SomeMethod, new object[] {"bah", "boo"});
}
else
control.SomeMethod("bah", "boo");
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Thanks, that'll do quite nicely! I had read about InvokeRequired a month ago and had forgotten about it.
|
|
|
|
|
I had this problem just as I started C# and it stumped me for 2 weeks (eventually JTJ came to the rescue), I will never forget it
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Hi everyone,
I was wondering if anyone might have some good resources for doing game development in C#, and also wanted to know your thoughts on doing games in C#, would C,C++,Java be better suited?
Thanks
|
|
|
|
|
The DirectX team recently released DX9, which has support for writing games in C#. I haven't looked at it in detail, but my first impression is that it will make writing DX code easier, but not easy, if that makes sense. You'll still need to learn about DX concepts.
If you choose to write in C#, there are a few disadvantages:
1) You need the .net runtime installed on the target machine
2) It will be slower than a C++ version, because you will be calling from C# code into native code. I don't know how much this slowdown is.
The advantages are that writing C# code is a lot easier than writing C++ code for most people.
|
|
|
|