Results 1 to 6 of 6

Thread: Picture in MDI Form Background

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Question Picture in MDI Form Background

    Hi ,

    Friends is there anyway to make background picture in MDI Form Without Using Subclassing .
    i tried to using Picture property but picture is not coming in Full Screen . let me know please .

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Picture in MDI Form Background

    MDI Parent Forms have a Picture property. Works fine here.

    Name:  sshot.jpg
Views: 1189
Size:  23.0 KB

    If you want it scaled to follow resizing you'll have to do that yourself though.

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Picture in MDI Form Background

    Quote Originally Posted by firoz.raj View Post
    Hi ,

    Friends is there anyway to make background picture in MDI Form Without Using Subclassing .
    i tried to using Picture property but picture is not coming in Full Screen . let me know please .
    Well I think that depends on the picture. If memory serves there is no stretch/tile option so the image will only fill the screen if the image is large enough to fill the screen.
    The one exception is if you use a vector image as it will scale to the size of the form automatically but as near as I can remember jpgs/bmps/gifs will not do so.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Picture in MDI Form Background

    That's a good point. EMF/WMF images can auto-scale by nature. However these tend to be more "clipart-like" and I get the impression few people even have a graphics editor supporting their creation these days.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Picture in MDI Form Background

    Here's one approach that resizes/redraws in the MDIForm_Resize handler. Effort was made to preserve the original image aspect ratio yet make sure we cover the entire resized MDIForm client area.

    Seems to deal with the well known DWM/Desktop Composition vs. InvalidateRect problem in its substitute for Refresh (which doesn't exist for MDIForms).

    A better quality image gives better results than the small highly compressed sample JPEG included here.

    The archive is big because the sample image file is in there twice, once embedded in Project1.res and once as a file. At runtime the separate file isn't needed.
    Attached Files Attached Files

  6. #6
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Picture in MDI Form Background

    Usind a cDibsection it is easy to draw. The method is simple. You don't use hdc of Mdiform. Only you set picture property. All the work done with 2 bitmap in memory. One for loaded (or created) picture and the other as a canvas that we copy in stdpicture and then putting to Mdi Form picture. Because those pictures are objects, when we give a new, the old one destroyed. All objects destroyed when last reference to that lost.
    I use that program basicform.zip and change MDIFORM as code as follow:

    Code:
    Dim AA As New cDIBSection
    Dim canvas As New cDIBSection
    Dim Stretch As Boolean
    Private Sub MDIForm_Load()
    canvas.Create Screen.width / Screen.TwipsPerPixelX, Screen.height / Screen.TwipsPerPixelY
    ' WE MAKE A BITMAP...LARGE
    ' AA.Create 3000, 2000
    ' OR SMALL
    AA.Create 600, 400
    AA.backcolor = "FF00FF"   ' THIS IS TEXT COLOR...ALSO
    AA.square 0, 0, width - 1, height - 1, "00FF77"
    AA.Fontsize = 32
    AA.Text "THIS IS MY PICTURE", 0, 0
    ' LET SAY THAT THIS IS LOADED AS AN IMAGE
    
    Stretch = False
    End Sub
    
    Private Sub MDIForm_Resize()
    ' STRETCH TO WINDOW
    If Stretch Then
            If width > 1000 Then
            canvas.needHDC
            AA.StretchPicture canvas.hdc1, 0, 0, width / Screen.TwipsPerPixelX, height / Screen.TwipsPerPixelY
            canvas.FreeHDC
            Set Me.Picture = canvas.Picture
            End If
    Else ' CENTERED
            canvas.WhiteBits
            canvas.needHDC
            AA.StretchPicture canvas.hdc1, (width / Screen.TwipsPerPixelX - AA.width) / 2, (height / Screen.TwipsPerPixelY - AA.height) / 2
            canvas.FreeHDC
            Set Me.Picture = canvas.Picture
    End If
    
    End Sub

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