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 .
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.
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.
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.
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