|
hmm... have you heard of Regular Experession... do check them out.. they really can help you in finding patterns... while making Living Hell a 'bit' better place
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
Hello,
I am trying to develope an SDI application that uses MDI to allow me to have lots of different types of child forms available, but only one is ever displayed.
Essentially my application has a common menu, toolbar and status bar. The parent window also has a tree control down the left side (like the folder view in Explorer). In the main body of this form I want to put an MDI child form, but disallow the Maximise, Minimise, etc. so that the child is always maximised inside the parent.
So far the best I've come up with for enforcing the rules I want are:
ChildA ca=new LessonA();<br />
ca.MaximizeBox=false;<br />
ca.MinimizeBox=false;<br />
ca.ControlBox=false;<br />
ca.WindowState=FormWindowState.Maximized;<br />
ca.MdiParent=this;<br />
ca.FormBorderStyle=FormBorderStyle.None;<br />
ca.Resize += new System.EventHandler(this.Child_Resize);<br />
ca.Show();
And the Child_Resize just sets the WindowState back to "Maximized".
However the problem with this is that the minimise and restore buttons exist and are clickable on the menu bar - The close button is also present, but not clickable. How do I get rid of these buttons?
Or does anyone have any other suggestions abount how to have lots of types of child forms sitting in the parent form and have it appear like they are a natural extension of the parent form and not a MDI-acting-as-SDI-Kludge?
One line of thought I have on an alternative is to have the children inherit from the parent form class - but I think that would cause more trouble than it is worth. I have a feeling the VS designer would get confused.
Any help is appreciated,
Colin.
|
|
|
|
|
I remember that in C++ it was no problem to use a pointer to a function to execute a function (or method), but is this doable in C#? What I'm thinking of doing is having an array of methods within a class and using a index to the array to select which function to execute. My next question would be what happens to my array of functions when I inherit from a base class, will I get the base class pointers or the derived class pointers?
Any thoughts?
|
|
|
|
|
Use delegates. They are essentially enhanced wrappers around function pointers.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Use delegates they are like safe, secure, object oriented functions pointers.
|
|
|
|
|
Thanks to you both for the advice. They even work just fine in a derived class too. So if a base class has a delagate pointing to a method in the base class and you then override the method in a derived class, the delagate from the derived class really does call the derived method. Excellent!
|
|
|
|
|
Not exactly.
Yes, delegates are the correct thing to use here, but they do not magically change to reference derived methods. That is a function of how you define your methods.
Here's a small example demonstrating this fact:
using System;
class Example {
static void Main() {
Base b = new Derived();
b.Test();
}
}
class Base {
protected delegate void D();
protected virtual void One() {Console.WriteLine("Base.One");}
protected void Two() {Console.WriteLine("Base.Two");}
public void Test() {
D[] methods = {new D(One), new D(Two)};
foreach(D method in methods) method();
}
}
class Derived : Base {
protected override void One() {Console.WriteLine("Derived.One");}
protected new void Two() {Console.WriteLine("Derived.Two");}
}
When executed it outputs:
Derived.One
Base.Two
Virtual dispatch is unrelated to delegates.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
So....so long as the base method is virtual and the derived method is set to override the base method everything should be cool right? I think that was what I was doing when I was playing with these and it seemed to work, or at least it behaved the way I wanted it too.
|
|
|
|
|
Yes, that's exactly correct. Delegates dispatch just like calling the method directly would. They won't make a non-virtual method dispatch in a virtual manner, but as long as the underlying method is virtual and the derived methods override it then everything works the way you want.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Does anyone know a good method of getting the size (i.e. kb) of a <c>Bitmap<c> object ?
I have found height and width, but no actual property that represents the size of bitmap on disk or memory.
Thanks in advance.
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
|
If it's on disk and you have the filepath you can create a FileInfo object and look at the FileInfo.Length property.
|
|
|
|
|
|
|
Neither will "w x h x bpp" exactly, as it doesn't account for padding or headers. To be fair, the original poster asked about both in memory and on disk, and the FileInfo answer was certainly correct for the on disk case.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Blake Coverett wrote:
as it doesn't account for padding or headers.
What is a couple of bytes between friends?
We are all friends here, arent we?
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I've noticed that Access has a neat text box embedded in the context menu that you can use to enter a filter for your records. I find this extremely swift and handy (shame they don't do the same for search as well) and I was wondering if there is any relatively easy way to incorporate this type on control in my C# project? I'm pretty sure the regular menu controls won't do it so I'm guess I'd have to write a custom control, but does anybody have a good idea of how much work would be involved so I can decide if it's really worth the effort for my application. I've never tried writting my own controls before!!
Thanks
|
|
|
|
|
The standard menu just does not work with embedded child controls. I tried this myself, and the menu class won't budge to display an embedded control --I guess this could be, at least in Windows XP, because the Windows is Layered and thus possible painted on a memory buffer. It's not even possible to spy on the Window menu because is protected by the system. Just setting up the hook for getting the handle to menu window is a task in itself too.
Most custom menu controls don't have support for this either. And yes, you need to write your own custom control and deal with alll the painting and handling of the keyboard to make the menu behave like a standard menu. If you have the time the it is a good learning excercise.
If you don't you can always check the SharpLibrary popup menu control which does offer that feature.
Regards,
Carlos
http://www.sharplibrary.com
|
|
|
|
|
Thanks for the advice. I guess I'll live without for the time being
|
|
|
|
|
The Fluid UI Toolkit[^] menu/commandbar will have this, but it does not exist yet. We are making progress on Fluid, and the commandbar system is high on our list. So bookmark our site, and check back periodically for downloads.
We will also be posting articles on CodeProject about each of our controls as they are completed.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I'll keep an eye on it. Thanks.
|
|
|
|
|
|
Hey Nish,
Sure, I love CodeProject. I just did not appreciate the geeks fighting me over my own code.
Regards,
Carlos.
|
|
|
|
|
|
To me, it's just a matter of having an implied license. Basically, you thought the license was one thing, we thought it was another, and it happens we were correct. But the best thing to do is to have the license be stated beforehand, which is what Chris is working on doing for future CP articles/code.
Good luck with your commercial product!
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|