Here's another way to make the form immovable and imrestorable (TM).
'FORM CODE
-------------------------------------------
Option Explicit
Private Sub Form_Load()
'position form
Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 3
'nail form
If defWindowProc = 0 Then
Call SubClass(Me.hwnd)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If defWindowProc <> 0 Then
Call UnSubClass(Me.hwnd)
End If
End Sub
Private Sub Command1_Click() 'un-nail code
If defWindowProc <> 0 Then
Call UnSubClass(Me.hwnd)
End If
End Sub
'BAS MODULE CODE
-------------------------------------------
Option Explicit
Public Const GWL_WNDPROC As Long = (-4)
Public Const WM_NCHITTEST = &H84
Public defWindowProc As Long
Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" _
Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Sub SubClass(hwnd As Long)
'assign our own window message
'procedure (WindowProc)
On Local Error Resume Next
defWindowProc = SetWindowLong(hwnd, _
GWL_WNDPROC, _
AddressOf WindowProc)
End Sub
Public Sub UnSubClass(hwnd As Long)
'restore the default message
'handling before exiting
On Local Error Resume Next
If defWindowProc Then
SetWindowLong hwnd, GWL_WNDPROC, defWindowProc
defWindowProc = 0
End If
End Sub
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
On Local Error Resume Next
Select Case hwnd
Case frmMain.hwnd
Select Case uMsg
Case WM_NCHITTEST:
WindowProc = 1
Exit Function
Case Else
End Select
End Select
WindowProc = CallWindowProc(defWindowProc, _
hwnd, _
uMsg, _
wParam, _
lParam)
End Function
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------
"schmendrick" <sc*********@myway.com> wrote in message
news:3K*******************@tornado.ohiordc.rr.com. ..
: Does anyone know how to disable the dbl click on the title bar?
:
: I have a full screen progam that I dont want moved or closed or
: anything. Took care of everything except for the fact that if you
: double click on the title bar, the form sets itself to half size.
:
: Can we disable that somehow??
:
: Thanks!
: David