VB API production is always in the forefront form

xiaoxiao2021-03-06  53

The first step is to open the project as shown in the second step in the project. Add the CHECK control in the form: Add module 1, add the following code in the external program to add the following code public declare function setWindowPos lib "user32" _ _Val hwnd as long, Byval Hwndinsertafter as long, _ byval x ask, BYVAL Y, _ BYVAL CY As Long, BYVAL WFLAGS AS Long As long 'over the API function declaration public const HWND_TOPMOST = -1Public Const SWP_NOMOVE = & H2Public Const SWP_NOSIZE = & H1Public Const SWP_FRAMECHANGED = & H20'The frame changed: send WM_NCCALCSIZEPublic Const SWP_DRAWFRAME = SWP_FRAMECHANGED 'used in the above procedure for the constants

Public Const HWND_BOTTOM = 1Public Const HWND_BROADCAST = & HFFFF & Public Const HWND_DESKTOP = 0Public Const HWND_NOTOPMOST = -2Public Const HWND_TOP = 0Public Const SWP_HIDEWINDOW = & H80Public Const SWP_NOACTIVATE = & H10Public Const SWP_NOCOPYBITS = & H100Public Const SWP_NOOWNERZORDER = & H200'Don't do owner Z orderingPublic Const SWP_NOREDRAW = & H8Public const SWP_NOREPOSITION = SWP_NOOWNERZORDERPublic const SWP_NOZORDER = & H4Public const SWP_SHOWWINDOW = & H40 'more constant declaration is not used in the program' may try to use these constants when calling SetWindowPos function or a combination thereof 'to obtain other effects Public const Flags = SWP_DRAWFRAME or SWP_NOMOVE or SWP_NOSIZE The fourth step is then added to the CHECK1 control, private sub check1_click () Dim Res rake if check1.value = 1 Then Res = setWindowPos (Me.hwnd, Hwnd_topmost, _ 0, 0, 0, 0, flags) ELSE Res = setwindowpos (me.hwnd, hwnd_notopmost, _ 0, 0, 0, 0, flags)

End ifnd Sub is used to control whether the form is always in front. Step 5: You can run, see if your luck is good.

转载请注明原文地址:https://www.9cbs.com/read-88284.html

New Post(0)