Solved

mdiform interface

Posted on 2000-02-23
8
322 Views
Last Modified: 2010-05-02
I have a picture and I want this picture to be mdiform background like monitor wallpaper (display title or center). how can I do it?
0
Comment
Question by:firza
  • 6
  • 2
8 Comments
 

Author Comment

by:firza
ID: 2549669
Adjusted points to 200
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2549736
This code ought to work... see www.mvps.org/vbnet for other useful stuff

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2000 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub Form_Paint()

    Dim X As Integer, Y As Integer
    Dim ImgWidth As Integer
    Dim ImgHeight As Integer
    Dim FrmWidth As Integer
    Dim FrmHeight As Integer

   'use Image1 or Picture1, as appropriate.
   'use one of the following PaintPicture methods:
    ImgWidth = Image1.Width
    ImgHeight = Image1.Height
    FrmWidth = Form1.Width
    FrmHeight = Form1.Height
   
   'tile entire form (Method 1)
    For X = 0 To FrmWidth Step ImgWidth
       For Y = 0 To FrmHeight Step ImgHeight
          PaintPicture Image1, X, Y      
       Next Y
    Next X

   'tile left side (Method 2)
   'For Y = 0 To FrmHeight Step ImgHeight
   '   PaintPicture Image1, 0, Y
   'Next Y
   
End Sub
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2549745
To centre... replace the for..next loop with

paintpicture image1, frmwidth-imgwidth, frmheight-imgheight
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 3

Expert Comment

by:paulstamp
ID: 2549773
Sorry.. code above wont work with MDI Parent...

I did have some code somewhere to do it... I'll post if I can find it.
0
 
LVL 3

Accepted Solution

by:
paulstamp earned 200 total points
ID: 2549801
Actually... you can use the code I listed above to achieve what you want.

Create two forms... an MDI parent and a normal form. Add two picture boxes on the normal form and set their visible prop to false. Call 1 picSource and the other picTarget and put the bitmap you want to use in the picTarget.

Then place a button on the form and use the following code in its click event.

   Dim X As Integer, Y As Integer
    Dim ImgWidth As Integer
    Dim ImgHeight As Integer
    Dim FrmWidth As Integer
    Dim FrmHeight As Integer
   
    picTarget.Width = MDIForm1.ScaleWidth
    picTarget.Height = MDIForm1.ScaleHeight



   'use Image1 or picTarget, as appropriate.
   'use one of the following PaintPicture methods:
    ImgWidth = picSource.Width
    ImgHeight = picSource.Height
    FrmWidth = picTarget.Width
    FrmHeight = picTarget.Height
     
    For X = 0 To FrmWidth Step ImgWidth
       For Y = 0 To FrmHeight Step ImgHeight
          picTarget.PaintPicture picSource.Picture, X, Y
       Next Y
    Next X

    Set MDIForm1.Picture = picTarget.Image
    MDIForm1.Show

That ought to do the trick.
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2549803
Spot the delibrate mistake - you should put the source image in picSource, not picTarget !
0
 

Author Comment

by:firza
ID: 2553039
i use MDI Perent
so what height scale use for MDIForm1.Picture use?

i don't want a normal form appear at MDI Perent? when I put the source image in picSource not picture in MDIPerent


coding your give not answering my question.


0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2553481
Leave the scalemode of the MDI parent and the picture boxes as Twips.

Instead of using another normal form you could place both the picture box es directly onto the MDI parent and resize the target to fill the entire client area.This way you dont need another form, and also you dont need to copy the picture from a picture box onto the form's picture property either.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now