Recalling the first knock on the computer room charges, I call the API function to implement the parent form and its sub-form to minimize the function, and now again encountered, they are thinking, can you continue to use the API function? The answer is of course the course!
Actually look at the two is not much difference, first see how to call in vb.net:
First, add a class module to encapsulate this API function:
<span style= "FONT-SIZE:14PX;" > Public Declare Function SetParent Lib "<span style=" color: #ff0000; " >user32</span> "(ByVal hwndchild As Integer, ByVal hwndnewparent as Integer) as integer</span>
And then call it directly in the form to meet your needs.
<span style= "FONT-SIZE:14PX;" >setparent (Frmregistercard.handle.toint<span style= "color: #ff0000;" >32</span>, Me.handle.toint<span style= "color: #ff0000;" >32</span>) </span>
Note: Although you have implemented the functionality that you want, the size of the self-sensing form also has to be more subforms from my modified:
<span style= "FONT-SIZE:14PX;" >frmregistercard.width = me.clientrectangle.width-800 frmregistercard.height = Me.ClientRectangle.Height- SetParent (FrmRegisterCard.Handle.ToInt32, Me.Handle.ToInt32) frmregistercard.show () </span>
below to talk about the difference between the API function declaration with VB:
1, one of the main difference is that the data type defined in VB is a long, and in vb.net use an integer to replace long, because in vb.net, the integer type is 32 bits, and the same as the long type.
2, to pay attention to the use ByVal and ByRef
- ByVal is a pass-through value, the source data is not modified, it can be used as its own local variable, (pass the parameter memory to the callee)
- ByRef is the delivery address, and the source data may be modified. (Pass the parameter address to the callee)
3, in the main form call API function to pay attention to the use of "Handel.toint32", he is equivalent to the VB call process. hwnd
H:handle; Wnd: Variable object description, so-called form, so handel.toint32 is the meaning of the so-called window handle!
here is also just their own understanding, first put the understanding of the API here, for the re-learning to play a foundation!