Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _ ByVal hWndNewParent As Long) As Long Private Sub Command1_Click() Form2.Show SetParent Text1.hWnd, Form2.hWnd End Sub
问题依旧没有解决,不过谢谢zsj1101。
An edit, list box, or combo box control sends notifications to the original parent window even after SetParent has been used to change the control's parent. A button control sends notifications to the new parent after SetParent has been used to change its parent.
Edit, list box, and combo box controls keep a private copy of the window handle of the parent at the time of creation. This handle is not changed when SetParent is used to change the control's parent. Consequently, the notifications (EN_*, LBN_*, and CBN_* notifications) go to the original parent.
Note that WM_PARENTNOTIFY messages go to the new parent and GetParent() returns the new parent. If it is required that notifications go to the new parent window, code must be added to the old parent's window procedure to pass on the notifications to the new parent. 谁能翻译一下
textbox,listbox,combobox控件在使用SetParent改变控件的Parent属性时,把通知送至原来的父窗口,而commandbox控件把通知送至新的父窗口。 textbox,listbox,combobox控件在创建时保存了一个父窗口句柄的备份,使用SetParent是无法改变控件的Parent属性的,因此,通知(EN_*, LBN_*, and CBN_* notifications)被送到了原父窗口。 注释:送消息WM_PARENTNOTIFY 到新的父窗口,GetParent返回新的父窗口,假如你想要传递通知到新的父窗口,你必须给原来的父窗口添加代码以传递通知到新的父窗口。 唉!挣点分真不容易呀
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Form2.Show
SetParent Text1.hWnd, Form2.hWnd
End Sub
Edit, list box, and combo box controls keep a private copy of the window handle of the parent at the time of creation. This handle is not changed when SetParent is used to change the control's parent. Consequently, the notifications (EN_*, LBN_*, and CBN_* notifications) go to the original parent.
Note that WM_PARENTNOTIFY messages go to the new parent and GetParent() returns the new parent. If it is required that notifications go to the new parent window, code must be added to the old parent's window procedure to pass on the notifications to the new parent.
谁能翻译一下
textbox,listbox,combobox控件在创建时保存了一个父窗口句柄的备份,使用SetParent是无法改变控件的Parent属性的,因此,通知(EN_*, LBN_*, and CBN_* notifications)被送到了原父窗口。
注释:送消息WM_PARENTNOTIFY 到新的父窗口,GetParent返回新的父窗口,假如你想要传递通知到新的父窗口,你必须给原来的父窗口添加代码以传递通知到新的父窗口。
唉!挣点分真不容易呀