我用SetParent想把我的FORM显示在记事本的窗口里,如何的到记事本的句柄. 我这样可以FORM2显示到FORM1里SetParent Form1.hwnd, Form2.hwnd.现在我要把FORM1显示到记事本里怎么写呢.

解决方案 »

  1.   

        Dim lnghWnd As Long
        lnghWnd = FindWindow(vbNullString, "temp.txt - 记事本")
        
        SetParent Form2.hwnd, lnghWnd
      

  2.   

    一般都是findwindow
    不过不太准确
      

  3.   

    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Const WS_EX_LAYERED = &H80000
    Private Const GWL_EXSTYLE = (-20)
    Private Const LWA_ALPHA = &H2
    Private Const LWA_COLORKEY = &H1Private Sub Command1_Click()
    End
      End SubPrivate Sub Form_Load()
      Dim rtn As Long
      rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
      rtn = rtn Or WS_EX_LAYERED
      SetWindowLong hwnd, GWL_EXSTYLE, rtn
      SetLayeredWindowAttributes hwnd, 0, 200, LWA_ALPHA
        Dim lnghWnd As Long
      lnghWnd = FindWindow(vbNullString, "无标题.txt - 记事本")
       SetParent Form1.hwnd, lnghWnd
    End Sub