?
Solved

form inside picture box

Posted on 2003-02-28
11
Medium Priority
?
226 Views
Last Modified: 2010-05-01
how do u put a form inside a picture box?

i used this code

Private Sub Load_Click()
    Form2.Show
End Sub
0
Comment
Question by:Gamemaster328
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 1

Expert Comment

by:spiritwithin
ID: 8046047
A form is a window. A picturebox is a control. A control has to be set into a window. Therefore, a window can not be set into this control.
0
 
LVL 1

Expert Comment

by:spiritwithin
ID: 8046053
Another point is, that the mouse does not act in a picturebox as it acts in a form. You can not click something, and drag it - inside of a picturebox, without specialized coding. Which all brings me to the point, that you might mean you want to have a sceenshot of the form, inside of a picturebox ?? That's possible and easy. Cheers.
0
 

Author Comment

by:Gamemaster328
ID: 8046197
i really dont need to drag it to a picture box i just need to press buttons.  i dont need to a mouse either.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:spiritwithin
ID: 8046209
So in other words, you want the picture box to contain buttons. That's easy, go run Visual Basic and create buttons inside of your picture box, like you would do with a form. You will end up having your buttons in the picturebox. Maybe that's what you need?
0
 
LVL 7

Expert Comment

by:webJose
ID: 8046883
I don't know why you want to do it, but here you go:

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Public sub SetFormInsidePBox(byval hWndForm as long, byval hWndPBox as long)
    setparent hwndform, hwndpbox
end sub

You use the above like this:

setforminsidepbox form2.hwnd, form1.picture1

And remember to take it out before unloading form1:

Setparent form2.hwnd, getdesktopwindow
0
 

Expert Comment

by:igfp
ID: 8047048
I believe you want a picture in the background? Here's what to do. Make a form and the same size of the picture you have. Then set the properties of the form to:
picture = "your pic"
borderstyle = "None"

here you've got a picture with everything you want in it!
now make a button with the caption "Exit" or whatever and:

Private Sub Command1_Click()
     Unload Me
End Sub

Perfect!
0
 
LVL 1

Expert Comment

by:spiritwithin
ID: 8047075
Woa. What webJose provided here is very nice. I tested it without success, anyway, im new to the idea of putting a form into a picturebox. I should not have answered that fast. Sorry to guide you wrongly, Gamemaster. Cheers.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8047206
Instead of set the form's parent to picturebox, try set the form's parent to another form that contain picturebox. Use the Setparent API that webJose provided and it should works.

cheers
0
 
LVL 7

Accepted Solution

by:
webJose earned 200 total points
ID: 8048179
It DOES work.  I just tested it.  Add a new project, then add a second form to the project.  Also add a picturebox to form1.  Then add the following code:


Option Explicit

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub Form_Load()
    Load Form2
    SetParent Form2.hWnd, Picture1.hWnd
    Form2.Show
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Unload Form2
End Sub

If you don't see the form it may be because of its position.  If so, add

form2.move 0,0

before

form2.show

in the Form_Load event.
0
 

Author Comment

by:Gamemaster328
ID: 8048274
add that code to where?
0
 

Author Comment

by:Gamemaster328
ID: 8048318
IT WORKS!!! thanks guys i really appreciate this. i was trying to make a code like this for ever! :) thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses

770 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