Results 1 to 14 of 14

Thread: MDI BackGround (Is it changeable!?!?)

  1. #1

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200

    MDI BackGround (Is it changeable!?!?)

    Can you have your own back ground in an MDI parent form or does it have to be that dull gray color? I got a cool background image i want to tile in the background is there anyway to get around that dull background that is the default(and atleast for me unchangeable) background....Thanks Guys!

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You may be able to use the graphics object of the mdi parent form to paint the image on the background. You would probably do this in the OnPaint event.

  3. #3

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200
    Could you explain a little bit...maybe some example code or something thanks

  4. #4

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200
    bump

  5. #5
    Junior Member
    Join Date
    Sep 2001
    Location
    Pittsburgh
    Posts
    23
    This knowledge base article describes how to set the background color for the MDI application area. It also works for a background image, though that's not specified in the article.

    http://support.microsoft.com/default...b;en-us;319417

    Tom

  6. #6
    Junior Member
    Join Date
    Oct 2000
    Location
    California
    Posts
    17
    Set the backgroundimage property

    Probably something like this
    me.backgroundimage = "image file name"

  7. #7
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    You can also set the BackGroundImage property at design time.

    I wonder why this thread was unanswered for so long.

  8. #8
    Junior Member
    Join Date
    Sep 2001
    Location
    Pittsburgh
    Posts
    23
    Originally posted by Athley
    You can also set the BackGroundImage property at design time.
    Actually I tried that and it doesn't work. Both the BackColor and BackgroundImage properties of form with IsMdiContainer set to true are ignored in favor of the system color.

    The code in the knowledgebase article uses an odd casting syntax in a try...catch statement. This version is more concise and (I believe) perfectly safe:

    VB Code:
    1. Dim ctl As Control
    2.  
    3. For Each ctl In Me.Controls
    4.      If TypeOf ctl Is MdiClient Then ctl.BackColor = Me.BackColor
    5. Next
    That will use the BackColor AND BackgroundImage (if one is specified) of the form in the MDI container.

    Tom
    Last edited by tpope; Dec 17th, 2002 at 10:09 AM.

  9. #9
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Actually I tried that and it doesn't work. Both the BackColor and BackgroundImage properties of form with IsMdiContainer set to true are ignored in favor of the system color.
    Hmmmm, I have 2 applications With MDI functionality, I tried to set the Background Image of the form in both apps and I can sure se a background image. I dont see it in design time though, but runtime has to be what's intresting.

  10. #10
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    It is another story with the BackColor property though. Microsoft actually states the following "The BackColor for an MDI form will always be the default.".

    .....hmmmm as a matter of fact they also state "MDI forms in Visual Basic .NET cannot display pictures." so I wonder why BackGroundImage works with my sarent forms.

  11. #11
    Junior Member
    Join Date
    Sep 2001
    Location
    Pittsburgh
    Posts
    23
    Originally posted by Athley
    Hmmmm, I have 2 applications With MDI functionality, I tried to set the Background Image of the form in both apps and I can sure se a background image. I dont see it in design time though, but runtime has to be what's intresting.
    In VB.NET? Strange.

    I tried that and while it flashed the background image briefly, I could see the background image neither in design time nor in runtime until I used the trick from the knowledgebase article.

    I wonder what we are doing differently?

    Tom

  12. #12
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    I have no idea.....

    I just created a new windows application, set the IsMdiContainer to true, set the BackgroundImage and ran my application...

    Here is the result:
    Attached Images Attached Images  

  13. #13
    Junior Member
    Join Date
    Sep 2001
    Location
    Pittsburgh
    Posts
    23
    Originally posted by Athley
    I have no idea.....

    I just created a new windows application, set the IsMdiContainer to true, set the BackgroundImage and ran my application...

    Here is the result:
    Cute kittens!

    While I'm certain it didn't work before, I just tried it again and it's working now. I have no idea what I was doing wrong.

    Very odd...

    Tom

  14. #14
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Well at least its working.

    (For the record the thing about pictures that MS states was about the old VB6 property "Picture" not about BackgroundImage)
    Last edited by Athley; Dec 17th, 2002 at 02:19 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width