你是在调试状态下运行的吧
别忘了它们的头上还有一个父呢,VB IDE

解决方案 »

  1.   

    顶层窗口SetParent会导致Windows窗口管理混乱平时玩玩可以
    编应用程序的时候千万别用
      

  2.   

    “顶层窗口SetParent会导致Windows窗口管理混乱”
     
    --我想再探讨一下:如果一定要在Form1中建立一个子窗体,
    是不是只能用CreateWindowEx函数?具体的语句应该怎么写?
      

  3.   

    建议你去学VC
    别找MFC的,找SDK编程的
    上面说的很详细
      

  4.   

    “建议你去学VC
    别找MFC的,找SDK编程的
    上面说的很详细”---  可否给一个连接或例程,哪怕是其他语言的例程。
            虽然我只会VB,但是用其他语言写的程式与用VB
            写的程式原理上是大体相同的
      VB.....脱离了入门级水平之后,好像觉得越来越力不从心了
      呵呵,各位别见笑
      

  5.   

    you can create a New MDI'Project---(MFC)
      

  6.   

    look and study the  SampleProject(module)
    Ok,---You can find all question-----Nothing.
      

  7.   

    'Form1上放一个PictureBox,Form2上放一个TextBoxOption ExplicitPrivate Declare Function SetWindowLong Lib "user32" _
        Alias "SetWindowLongA" _
       (ByVal hwnd As Long, _
        ByVal nIndex As Long, _
        ByVal dwNewLong As Long) As Long
        
    Private Declare Function SetWindowPos Lib "user32" _
       (ByVal hwnd As Long, _
        ByVal hWndInsertAfter As Long, _
        ByVal x As Long, _
        ByVal y As Long, _
        ByVal cx As Long, _
        ByVal cy As Long, _
        ByVal wFlags As Long) As Long
        
    Private Declare Function SetParent Lib "user32" _
       (ByVal hWndChild As Long, _
        ByVal hWndNewParent As Long) As Long
        
    Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As LongPrivate Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOZORDER = &H4
    Private Const GWL_STYLE = (-16)
    Private Const WS_CHILD = &H40000000
    Private Const WS_VISIBLE = &H10000000
    Private Const WS_TABSTOP = &H10000Private Sub Command1_Click()
        Form2.Show
        
        SetParent Form2.hwnd, Picture1.hwnd
        SetWindowLong Form2.hwnd, GWL_STYLE, WS_CHILD Or WS_VISIBLE Or WS_TABSTOP
        SetWindowPos Form2.hwnd, _
                     0, _
                     0, _
                     0, _
                     Picture1.ScaleWidth / Screen.TwipsPerPixelX, _
                     Picture1.ScaleHeight / Screen.TwipsPerPixelY, _
                     SWP_NOZORDER
        Form2.Text1.SetFocus '要先在Form2上放一个TextBox
        Debug.Print Picture1.hwnd = GetParent(Form2.hwnd)
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        Unload Form2
    End Sub
      

  8.   

    good
    谢谢 junwhj(junwhj.myrice.com)
    我先研究一下代码,稍后再对各位热情的大大详细致谢^^
      

  9.   

    谢谢各位,尤其感谢junwhj以下是我对上述例子的理解:
    1>> 语句 SetWindowLong Form2.hwnd, GWL_STYLE, WS_CHILD Or _ 
             WS_VISIBLE Or WS_TABSTOP 可以省略
    2>> 语句 SetWindowPos Form2.hwnd, _
                0, _
                0, _
                0, _
                Picture1.ScaleWidth / Screen.TwipsPerPixelX, _
                Picture1.ScaleHeight / Screen.TwipsPerPixelY, _
                SWP_NOZORDER
            可以改为 Form2.Move 0, 0, Picture1.Width - 60, _ 
                     Picture1.Height - 60
    3>>  语句 Form2.Text1.SetFocus 可以说是治疗VB的一个BUG的
         偏方:在SetParent语句后,如果不在Form2中设置焦点,则
         关闭Form2前,Form1不能响应用户操作另外尚有一些疑问:
    1>>  Private Const WS_CHILD = &H40000000
         Private Const WS_VISIBLE = &H10000000
         Private Const WS_TABSTOP = &H10000
         以上3个常数在SetWindowLong的具体含义是什么?
    2>>  还有就是,为什么要把From2设置为Picture1的子窗体才能成功