Этот код позволяет сделать форму по верх всех окон и перемещать ее за любое место: Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Sub ReleaseCapture Lib "user32" () Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 Private Declare Function ReleaseDC _ Lib "user32" ( _ ByVal hwnd As Long, _ ByVal hdc As Long _ ) As Long Private Const SWP_NOSIZE = &H1 Private Const SWP_NOMOVE = &H2 Private Const SWP_NOZORDER = &H4 Private Const SWP_NOREDRAW = &H8 Private Const SWP_NOACTIVATE = &H10 Private Const SWP_FRAMECHANGED = &H20 Private Const SWP_SHOWWINDOW = &H40 Private Const SWP_HIDEWINDOW = &H80 Private Const SWP_NOCOPYBITS = &H100 Private Const SWP_NOOWNERZORDER = &H200 Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED Private Const SWP_NOREPOSITION = SWP_NOOWNERZORDER Private Const HWND_TOP = 0 Private Const HWND_BOTTOM = 1 Private Const HWND_TOPMOST = -1 Private Const HWND_NOTOPMOST = -2 Private Declare Function SetWindowPos _ Lib "user32" ( _ ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal X As Long, _ ByVal Y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long _ ) As Long Private mbOnTop As Boolean Private Sub Form_Load() SetWindowPos hwnd, HWND_TOPMOST, _ 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim ReturnValue As Long If Button = 1 Then Call ReleaseCapture ReturnValue = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0& End If End Sub
Ответить
|