?
Solved

form inside picture box

Posted on 2003-02-28
11
Medium Priority
?
231 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 55

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

621 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