|
Hi,
OK, I'm trying to create a background image on an MDI parent form. Here are my problems:
1) If I use a PictureBox, whenever I open a child form, the PictureBox stays in front of the child instead of behind it.
2) I have tried using the Graphics.DrawImage with no avail (e.g. the image doesn't appear).
I would like to have an image that appears on an MDI parent form and stays behind any children forms that are opened. What am I doing wrong?? Thanks in advance.
Agent 86
|
|
|
|
|
Agent 86 wrote:
2) I have tried using the Graphics.DrawImage with no avail (e.g. the image doesn't appear).
Where and how do you do it? You must do it in paint event of parent form in a way like this:
e.Graphics.DrawImage(...);
Mazy
No sig. available now.
|
|
|
|
|
Yes, I've tried it in the paint event like so:
e.Graphics.DrawImage(Image.FromFile(Application.StartupPath + "\\Img.bmp"));
You would think that it wouldn't be so hard to add an image to an MDI container.
Agent 86
|
|
|
|
|
I tried to override OnPaintBackground() but had no luck with that either.
There is a BackgroundImage property that you can set at design time or runtime. This works but tiles the image. I have not yet found a way to place the image, and tiling it is not what I wanted. But maybe it is some use to you?
The image is drawn quite slowly on my 550MHz machine with 400 MB RAM. On my 2GHz machine it's quite good, but uses 100% processor time. I assume that this is because of JIT and all that stuff, and it really annoys me. I wonder whether I should switch back to C++/MFC.
Please let me know if you ever find out how to place the image and prevent it from tiling.
--
Robert
|
|
|
|
|
I think this may be what you want:
http://vbaccelerator.com/home/NET/Code/Libraries/Windows/MDI_Client_Area_Painting/article.asp
I bet you never guessed it was going to be this hard. I sure didn't.
|
|
|
|
|
Holy cow!
What a lot of code! No, I certainly didn't expect it to be that hard. Thanks for the answer, though. Now I need to write some letters to MS to figure out why you need to go to such trouble to add an image to an MDI client
Agent 86
|
|
|
|
|
using System;
namespace afs
{
class Class1
{
string asdf;
[STAThread]
static void Main(string[] args)
{
asdf="USER ";
}
}
}
OH MY GOD. Have I gone nuts or something??? WHat that hell! Why won't this compile?
/\ |_ E X E GG
|
|
|
|
|
You can not access a instance field
from a static function. You will need
a object referance just like the compiler
tells you when you try to compile it.
Thank You
Bo Hunter
|
|
|
|
|
Complier didn't say anything... I now realize what I did though.
/\ |_ E X E GG
|
|
|
|
|
Because you declared asdf as an instance field and are trying to assign it from a static method without even instantiating Class1 yet. Try adding static before string asdf; .
The compiler error actually should've made this clear.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Complier didn't say anything... I now realize what I did though.
/\ |_ E X E GG
|
|
|
|
|
Mine said, "An object reference is required for the nonstatic field, method, or property 'WindowsApplication1.Form1.asdf'", both in VS.NET 2002, 2003, and the command-line compiler csc.exe (which VS.NET uses).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I swear, it wasn't saying anything... I tried VS and the csc.exe also... However, it seems after I restared... everything is back to normal and the complier is giving me
"An object reference is required for the nonstatic field, method, or property 'WindowsApplication1.Form1.asdf'"
So, I guess that's good. Oh well, whatever.
/\ |_ E X E GG
|
|
|
|
|
I need same help if you could help me!I have to windows aplications one is the Client and the other is the server but i can't change information between them, now i'm using sockets, if sameone could help-me!:].
i don't know if is possibel this way, right now i don't know the right direction for my application, what i want is:
One server that receives a msg from a client application testBox into a label that is in the server
Mario Santos
|
|
|
|
|
|
Object-based collections may be fine for reference types, but I'm looking for a high-performance collection to store only value types without the boxing/unboxing overhead. Is there anything available to me in the .Net BCL? Or anything on this site that might help me? (already did a search, but might've missed something)
The graveyards are filled with indispensible men.
|
|
|
|
|
Not in the BCL, not until .NET 2.0 when they will be introducing generics in .NET.
For now, you can implement something yourself. Almost all collection-like classes in .NET use an ArrayList because it can grow but it does take an Object which requires boxing value types. ArrayList uses arrays internally, and creates new arrays when necessary and copies elements to the new array. Do the same yourself, but using the value types that you need to collect. Methods like Array.CopyTo make copying elements to the new array easy, and of course creating a new array that's large enough isn't hard. For example, ArrayList.Capacity is the initial capacity (size of the array). When more elements need to be stored, Capacity is doubled and a new array of that size is created. Elements are copied and the old array is disposed (if necessary). You wouldn't have to double, though, it just what the BCL does. You could implement more predictive algorithms if you need to.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
As always, Heath, your answers are very informative and helpful, thanks. I'll see if I can throw together a home-rolled solution then.
The graveyards are filled with indispensible men.
|
|
|
|
|
i want to respond to keyboard event while the window of my project is inactive
thanks
|
|
|
|
|
|
Actually, this is conditional...
If you mean your entire application is not the active Window, then using a system hook is best.
If you mean that a dialog in your application has lot focus, but your application still has focus, then you should use an IMessageFilter and register it with Application.AddMessageFilter .
Using system hooks slows down the speed of the entire window manager because your program has to filter and process the necessary data. If you don't NEED to, don't do it.
Also, if you do use a system hook, make sure you unregister it before exiting your application, like in your main window's (i.e., the Form that was run with Application.Run ) Close event handler, or better yet in the Dispose override, or before youe application's entry point (i.e., Main ) exits.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
Has someone print in .Net a custom papersize?. I have tried, and the only size that print is the standard size, 8.5" x 11". What do I need to do to change the papersize?
Carlos Eduardo Hernandez P.
|
|
|
|
|
I don't know how to change it. But, was this not answered in the last 24 hours? Click "Search comments" above, i'm pretty sure your answer is there. Good Luck.
/\ |_ E X E GG
|
|
|
|
|
it dindnt. I am just trying to open a new thread so other people can comment on this. It has not work yet.
Carlos Eduardo Hernandez P.
|
|
|
|