Loading Windows Form before Showing - c#

I have a Parent Windows Form from which there are multiple Child forms. Almost every single one of these has the same background image, the parent is a MDIContainer.
It is working properly, my problem is that when I call the Form.Show() method, after selecting a MenuStrip item for a child Form, the form is already showing WHILE the background image is being set.
I think this would be solved by first loading the BackgroundImage and then, after a while, showing the form itself.
Any possible advice? Thanks in advance

Best fix I think would be to set the right background image for each child form at design time and simply call. show to display the form..

Setting BackgroundImageLayout to ImageLayout.Stretch seems to ease the transition, however it still looks a bit odd. I'll keep trying stuff

Related

WinForm Controls are transparent, and not displaying properly

When a form loads, I'd like it to show a loading image (within a Picture Box) and a standard Windows label with some text. However, all I see are white boxes, or sometimes I see another form underneath. How do I get the image and label to display properly.
I've tried setting AllowTransparency to false when the form loads, and also setting the Transparency Key of the form to some other colour, but nothing has worked.
The project is C# .Net v3.5 (also tried v4 and v4.5).
Any ideas?
First, you can't display an image, busy-wait, and then change the image - this will never redraw anything, leading to the symptoms you describe. To "wait" you will need to return control to your main application loop so it can continue to process messages (e.g. to handle redraw requests for your window). One way to do what you want is to display your initial state (splash screen) and then use a timer to call you back later to change the display to your second state.
The next problem you face is using forms controls with transparency. Most controls treat "transparent" as "fill your background with your parent controls color", which is not what you want. An easy way around this is to implement a Paint handler and draw the image and text for yourself - this gives you much more control of how your display looks, and will also allow you to get a cleaner redraw (no flicker or other problems caused by the display being built up but by bit in several controls)
Lastly, consider implementing your splash screen display as a separate control/form that you show above your main form during loading, as that makes it easy to "overlay" on your main form without having to change its design at all.
Just write formObjectName.Refresh() after formObjectName.Show()

How to send graphics to another form

I have 2 forms and in those 2 forms i have two board.
In the first form user put some object on the board. And then it clicks next. I want to send the exact graphics to the other form so i can draw the same things in second form.
I've tried to use Graphics.Save() and Restore() functions, but didn't work. Any suggestions ?
Thanks in advance.
You may need to call Invalidate() on your second form to make the picture appear after you have passed it? If you minimise and then maximise your second form and the image appears, then that will be the problem.

WPF Create Bitmap of Window that hasn't been shown

Is it possible to create a bitmap of a window that hasn't been shown without using screenshots?
What I want to do is start my application, and have a main window that displays other windows. I use visual brush to display them after they've been shown, and the image stays after the window is closed, but how do I show an image of the window prior to Window.Show()?
I would guess that the window isn't rendered until it is needed, so there would be no way to get the flattened bitmap of it. I wonder if you could somehow make it "show" without being shown? Can you use Window.Hide() to your advantage? Just throwing it out there.
Also makes me think--why would you want to get a bitmap of a Window? Windows are for presenting UI, not for displaying as an abstract representation of a UI choice. Maybe creating an abstract icon for each choice would be more usable?
No way to do this without creating the Window first, as it won't be in the visual tree until it is created. You may create it in an area outside your working area and generate the bitmap from there. You need it laid-out first also because of bindings, layout transforms, etc.
You should get everything you need here: http://www.west-wind.com/weblog/posts/150676.aspx and here: http://www.codeproject.com/KB/WPF/WPF-Image-to-WebPage.aspx
The key is the RenderTargetBitmap class

Sizing issue in MDIForms

iam having an MDI form,in which i placed a form.i have some issues while resizing
how to set the maximum for the the mdichild so that it cannot be resized to the entire
container if i selects maximize
is it possible to put anything apart from a form inside the container( i am using a third
party component dotnetmagic,i want to create a content using it and like to place it in the
mdicontainer)
Thnx in advance
Set the normal MaximumSize/MinimumSize property of the MDIChild Form, or see http://support.microsoft.com/default.aspx?scid=kb;en-us;327824 if it doesn't work.
No. Consider using WPF and Canvas, if you want to create a custom drawing environment.

How to disable click through on transparent control?

We have a mapping form in our application that needs a Google Earth background image, and as you can't use the Google Earth plugin in a browser that is under a panel, we use a second form to show the background image. We have a transparent panel on the mapping form that the drawing is done on while Google Earth is drawn on a form held in sync below.
We achieve transparency by giving the form a transparency key of 255, 250, 250 and setting the panel background to this color before drawing on it. Although now after looking at the information available online it appears that the panel shouldn't ever get cursor events.
This works perfectly in most cases, but on one or two customers machines (one is definatly Windows 7) the cursor will not work correctly on the panel where it is transparent. If the cursor is placed over a drawn area of the map then it all work fine.
I think the issue is due to transparancy click through but as it works in most cases I'm not sure what is exactly going on. We've updated all of the graphics drivers to see if there is a custom setting on the customers machine but this hasn't helped.
Does someone have a definative description of what the transparency key does? Is there a way to absolutly set that the panel should recieve the mouse events?
EDIT
Added detail about transparency key.
Try intercepting the WM_HITTEST message in the WndProc for the Form window and when you know it is over the client area return the appropriate HTCLIENT value. It could be that the default window processing is sometimes returning a different value.
Stevo - Have you ever figured out an answer to this? I had the same problem and figured out to change the transparency key of the main form to some odd color. May or may not help you. I had a custom control with transparency but the forms key color was also my drawing color, thus allowing it to click through (strangely). I changed it and it worked!

Categories