如何把一个窗体(form)放到picture内?

解决方案 »

  1.   

    SetParent picture1.hwnd,form1.hwnd
      

  2.   

    给你举个例子
    form1
    form2将form2放到form1.picture1中在form1里加入如下代码即可Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Sub Form_Load()
        SetParent Form2.Command1.hWnd, Picture1.hWnd
    End Sub
      

  3.   

    将form2中的command1放到form1.picture1中呵呵
      

  4.   

    函数的相关说明
    SetParent VB声明 
    Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long 
    说明 
    指定一个窗口的新父(在vb里使用:利用这个函数,vb可以多种形式支持子窗口。例如,可将控件从一个容器移至窗体中的另一个。用这个函数在窗体间移动控件是相当冒险的,但却不失为一个有效的办法。如真的这样做,请在关闭任何一个窗体之前,注意用SetParent将控件的父设回原来的那个) 
    返回值 
    Long,前一个父窗口的句柄 
    参数表 
    参数 类型及说明 
    hWndChild Long,子窗口的句柄 
    hWndNewParent Long,hWndChild的新父 
    注解 
    可用这个函数在运行期将vb控件置入容器控件内部(比如将一个按钮设成图象或窗体控件的子窗口),或者将控件从一个容器控件移至另一个。控件移至另一个父后,它的位置将由新父的坐标系统决定。这样一来,有必要重新规定控件的位置,使其能在目标位置显示出来