Home > Software engineering >  When, with SetParent, from other application window cut back the program and I need some twice befor
When, with SetParent, from other application window cut back the program and I need some twice befor

Time:11-01

I had a program has two Form, FatherWin and ChildWin FatherWin contains a PictureBox: FatherPicBox, ChildWin contains ChildPicBox, and again put a TextBox1 ChildPicBox, as shown in figure:

I use SetParent ChildWin. ChildPicBox. HWnd, Me. FatherPicBox. The hWnd ChildWin. The contents of the ChildPicBox display to FatherWin. FatherPicBox, then everything is normal, but when I go to click the mouse other arbitrary software window, then click on the window in the TextBox1 but not selected, the cursor can't stop input box, must check it again to input characters,
Everybody have any good?

ChildWin in no code, code in FatherWin as follows:
 Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long 

Private Sub Form_Load ()
SetParent ChildWin. ChildPicBox. HWnd, Me. FatherPicBox. The hWnd

End Sub

Private Sub Form_Unload (Cancel As Integer)
Unload ChildWin
End Sub

CodePudding user response:

Estimates are click to the parent window is the first time, second only to the child window controls, so you need to click twice, HOOK test under the window, click event is automatically add a click, (sendmessage BM_CLICK) I also encountered this problem

CodePudding user response:

I tried, I found can click ah, you pack the whole project RAR next, try send me email to 1085992075 @qq.com

CodePudding user response:

I really can't enter here, may be not very accurate, I described two window is maximized, also is to can see the window of the two programs at the same time, when some other application back point of the program (note is directly input box), the first point over the title bar of the window by the blue ash into a bright blue (XP), but the cursor is not in the input box, and then click input box will see a flashing cursor, then just can input characters

CodePudding user response:

Masters a gu is not sad? How to go unattended?

CodePudding user response:

Wonderful work there will be a wonderful work of design problems,
Improper application is beyond the rules of the design, can't guarantee with 100% of the solution,

Why not start the design in the parent form?

CodePudding user response:

This is probably the VB Forms design, in order to maintain the sake of ActiveControl, so you really want to use SetParent this way, if you don't want to subclass process messages, or at least response under the form of the MouseDown event handling,
This need, if you want to use VB Forms, or try to make into MDI or get a user controls or something,
  •  Tags:  
  • API
  • Related