VB.NET/VB Declaration API function Implements parent window function

Source: Internet
Author: User

Tag: Get public declares IDT track to call space by default

recall the first time to knock the computer room charges. I call the API function to implement the function of minimizing the parent window and its child window . Now again, you are thinking, can you continue to use the API function? The answer is of course the course!

In fact, a careful look at the two is not much different. First look at how to invoke in vb.net:

First, a class module is added 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 window 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>

Then change the parent window's WindowState property to maximized.

The result of the implementation is that by clicking on the other window, the window is minimized to the lower-left corner of the parent window,


Note: Although the desired function is implemented, the Self-sensing window is also more child-window from my changes:

             <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 most basic difference is that the data type defined in VB is long, and in vb.net the integer is used instead of 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 the pass-through value, and the source data is not altered. Ability to use this value as a local variable; (pass the parameter memory to the callee)
    • ByRef is the delivery address. The source data may be altered. (Pass the parameter address to the callee)

3, in the main Window 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, also known as the window, so Handel.toint32 is the so-called window handle meaning it.


here is also just their own understanding. First put the understanding of the API here, to re-learn to lay a foundation for it.

VB.NET/VB Declaration API function Implements parent window function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.