Проект -> TestForm -> Timer1 -> ниже код для формы (ну и контрролов накидай для наглядности.)
------------------------------------------------------------------------------
Option Explicit
'
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
'
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_CAPTION = &HC00000
'
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOREPOSITION = &H200
Private Const SWP_SHOWWINDOW = &H40
'
Private Type POINTAPI
x As Long
y As Long
End Type
'
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const NULL_VALUE As Long = 0&
Private Const STYLE_SET_ERROR As Long = NULL_VALUE
'
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
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 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 Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Sub ReleaseCapture Lib "user32" ()
'
Private mb_TitleView As Boolean
'
Private Function ShowFormTitle(hwndShow As Long) As Boolean
'
Dim lStyle As Long, lStyleSetComplete As Long
'
lStyle = GetWindowLong(hwndShow, GWL_STYLE)
'
lStyle = lStyle Or WS_CAPTION
lStyle = lStyle Or WS_MAXIMIZEBOX
lStyle = lStyle Or WS_MINIMIZEBOX
lStyle = lStyle Or WS_SYSMENU
'
lStyleSetComplete = SetWindowLong(hwndShow, GWL_STYLE, lStyle)
'
If lStyleSetComplete = STYLE_SET_ERROR Then
ShowFormTitle = False
Else
RedrawForm hwndShow
ShowFormTitle = True
End If
'
End Function
Private Function HideFormTitle(hwndHide As Long) As Boolean
'
Dim lStyle As Long, lStyleSetComplete As Long
'
lStyle = GetWindowLong(hwndHide, GWL_STYLE)
'
lStyle = lStyle And Not WS_CAPTION
lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle And Not WS_MINIMIZEBOX
lStyle = lStyle And Not WS_SYSMENU
'
lStyleSetComplete = SetWindowLong(hwndHide, GWL_STYLE, lStyle)
'
If lStyleSetComplete = STYLE_SET_ERROR Then
HideFormTitle = False
Else
RedrawForm hwndHide
HideFormTitle = True
End If
'
End Function
Private Sub RedrawForm(hWndRedraw As Long)
'
SetWindowPos hWndRedraw, _
NULL_VALUE, NULL_VALUE, _
NULL_VALUE, NULL_VALUE, NULL_VALUE, _
SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or _
SWP_NOREPOSITION Or SWP_FRAMECHANGED 'Or SWP_SHOWWINDOW
'
End Sub
Private Sub Command1_Click()
'
If Not mb_TitleView Then
mb_TitleView = HideFormTitle(Me.hwnd)
'
If Not mb_TitleView Then _
MsgBox "Cannot hide form title !!!", vbCritical, App.Title
Else
mb_TitleView = ShowFormTitle(Me.hwnd)
'
If Not mb_TitleView Then
MsgBox "Cannot show form title !!!", vbCritical, App.Title
Else
mb_TitleView = Not mb_TitleView
End If
End If
'
End Sub
Private Sub Form_Load()
'
mb_TitleView = HideFormTitle(Me.hwnd)
Timer1.Interval = 100
Timer1.Enabled = True
'
End Sub
Private Sub Form_Unload(Cancel As Integer)
'
Timer1.Enabled = False
'
End Sub
Private Sub Timer1_Timer()
'
Dim FP As POINTAPI
Dim CP As POINTAPI
'
ClientToScreen Me.hwnd, FP
GetCursorPos CP
'
If CompareArguments(FP, CP) Then
mb_TitleView = ShowFormTitle(Me.hwnd)
mb_TitleView = Not mb_TitleView
Else
mb_TitleView = HideFormTitle(Me.hwnd)
End If
'
End Sub
Private Function CompareArguments(arg1 As POINTAPI, arg2 As POINTAPI) As Boolean
'
If arg2.x < arg1.x And arg2.x > arg1.x + ScaleWidth \ Screen.TwipsPerPixelX Then
If arg2.y < arg1.y And arg2.y > arg1.y + ScaleHeight \ Screen.TwipsPerPixelY Then
CompareArguments = False
End If
End If
'
If arg2.x >= arg1.x And arg2.x <= arg1.x + ScaleWidth \ Screen.TwipsPerPixelX Then
If arg2.y >= arg1.y And arg2.y <= arg1.y + ScaleHeight \ Screen.TwipsPerPixelY Then
CompareArguments = True
End If
End If
'
End Function
--------------------------------------------------------
Где-то там завелся жук найдеш его ??? (я не специально)
Честно говоря я бросил этот тест так как он мне показался тупиковым вариантом. Я думаю ты догадаешся почему.
