我曾经找到过源码的,可惜弄丢了。
不知道哪为高手知道怎么改变控件的宿主?
就是把我的窗口的一个控件,比如按钮等移动到别人的窗体上面去?

解决方案 »

  1.   

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

  2.   

    SetParent 控件.hwnd,父窗体.hwnd
      

  3.   

    新建一个工程,在窗体上加上一个Command控件~加入下面的代码!把你的按钮移动到桌面上去!!!!!!!Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Sub Command1_Click()
        Dim hWindow As Long
        hWindow = FindWindow("Progman", "Program Manager")
        hWindow = FindWindowEx(hWindow, 0, "SHELLDLL_DefView", "")
        hWindow = FindWindowEx(hWindow, 0, "SysListView32", "")
        SetParent Command1.hWnd, hWindow
    End Sub
      

  4.   

    //可以改变宿主,但是通过什么方式能对控件进行操作呢?通过hWnd!!!(按钮的句柄)
      

  5.   

    ////可以改变宿主,但是通过什么方式能对控件进行操作呢?//通过hWnd!!!(按钮的句柄)具体一点好吗?比如通过什么API函数.我所知道的是SENDMSSAGE函数可以对诸如文本框的操作,但要对MSFLEXGRID控件该如何操作,我想通过API函数给MSFLEXGRID控件赋值.谢谢!!!
      

  6.   

    TO:lifsy(漫天飞舞)
    虽然改变了宿主!但控件你还可以通过你程序的代码来控制的!
    对于用API来给一个有N个子控件的控件赋值.那可是非常麻烦的~
    我不会了~~呵呵
      

  7.   

    楼上已经说过了,要改变他的位置,比如你把它的left,top都设为0,就可以看到了,以此类推
      

  8.   


    SetParent Command1.hWnd, hWindow
    后加上
    command1.move 0,0