How to group controls on form with bmp background

I have a form with a bmp backround that I need to center my controls on it when the screen is maximized or resized.

I can't center each control individually, as there are about 30 total, including text.

I wanted to group them in a frame, but the frame background can not be made transparent.

I found two messages on the exchange, one told me how to make the frame transparent, but it also make the controls inside it transparent.

The other mentioned MS Forms 2.0 Library.  Although there are some controls there that can be made transparent, none will accept pasting controls inside it and using the frame as a grouping tool.

How can I group my controls so all I need to do on form resize is center them ?

Thanks
supprogAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
Use a PictureBox as the container, set the .AutoRedraw True, and .BorderStyle to None. Then paint the background picture on the PictureBox to make it "seem" transparent.

Private Sub Form_Load()
    Picture1.AutoRedraw = True
End Sub

Private Sub Form_Resize()
    With Picture1
    .PaintPicture Form1.Picture, 0, 0, , , .Left, .Top
    End With
End Sub
0
supprogAuthor Commented:
Although this may work, the bmp I have is not the complete size of the form.

I have to use code to tile the bmp across the form.

Unless I would have to tile the bmp across the picture box.

But, then if the bmp inside picture box doesn't line up properly with the frame background, I do not know if it would look right.
0
Erick37Commented:
Try:

Form1.Picture = Form1.Image
With Picture1
..PaintPicture Form1.Picture, 0, 0, , , .Left, .Top
End With
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

supprogAuthor Commented:
All this does is make the background of the picture box, the same color as the underlying form, and does not use the tiled picture.

In this case, my form background, in design mode, is grey.  I placed a picture on it that I am using to tile.

All this does is make the picturebox grey.
0
Erick37Commented:
This works:

Option Explicit

Private pic As StdPicture
Private dx As Integer, dy As Integer

Private Sub Form_Load()
    Set pic = LoadPicture("c:\windows\bubbles.bmp")
    Form1.AutoRedraw = False
    Picture1.AutoRedraw = False
    dx = ScaleX(pic.Width, vbHimetric, vbTwips)
    dy = ScaleX(pic.Height, vbHimetric, vbTwips)
End Sub

Private Sub Form_Paint()
    'tile the image on form
    Dim h As Integer, w As Integer
   
    For w = 0 To Form1.Width Step dx
    For h = 0 To Form1.Height Step dy
    Form1.PaintPicture pic, w, h
    Next
    Next
End Sub

Private Sub Picture1_Paint()
    'tile the image on pic box
    Dim h As Integer, w As Integer
   
    For w = 0 To Form1.Width Step dx
    For h = 0 To Form1.Height Step dy
    Picture1.PaintPicture pic, w - Picture1.Left, h - Picture1.Top
    Next
    Next
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vbyuvalCommented:
Leave the frame :
If you want three objects in a row -

Dim ObjName as Object
Dim ObjNumber as Integer,intTop as Integer,intLeft as Integer
Dim ObjLeft as Integer

'With this values you can place the group
intTop=int(Me.height/2)
intLeft=int(Me.Width/2)

'Controls is the collection of all the object in the form
For each ObjName in Controls
  ObjNumber=ObjNumber +1
'Each 4th object will be in the next line
  If (ObjNumber Mod 4)=0 then
    intTop=intTop+ObjName.Height
    ObjLeft=intLeft
  Else
    ObjLeft=ObjLeft+ObjName.Width
  End If
  ObjNumber.Left=ObjLeft
  ObjNumber.Top=intTop
Next

I didn't checked it cause I don't have a VB on this computer
but I think it's OK .

                                                             Enjoy
                                                         Yuval Amir
0
supprogAuthor Commented:
This will not work as some rows contain more than other row's.

Plus, my program is constantly changing, and the control's may change position.

That is why I need to group them, so I can change their positionany time I need to.
0
supprogAuthor Commented:
Erick27:

Major problem with your idea.  When I paste command buttons inside a picture box, they no longer accept user input.

You can no longer click on them.
0
Erick37Commented:
This is not so in VB5; works fine for me.
0
supprogAuthor Commented:
This works great.  Although selecting items inside a picture box can be a pain.

Would have been nice if Microsoft added support for something like this.  Would make things a lot easier.

Thanks for the help
0
mcriderCommented:
Check out this question and answer:

http://www.experts-exchange.com/Q.10171899 


Cheers!
0
mcriderCommented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.