Solved

mdiform interface

Posted on 2000-02-23
8
313 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 47
Adding to a VBA? 6 49
Run code from text file in vb 1 33
Add a task in Outlook from access 11 32
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 …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

18 Experts available now in Live!

Get 1:1 Help Now