Hi,

I found the following code (restrict form re-size) curtesy "V(ery) Basic" on this forum.. The code works great but I want to modify it to allow me to enter Twips instead of Pixels..

Is this possible? If so, example code would be appreciated..

Code:
Option Explicit

Public MinWidth As Integer
Public MinHeight As Integer

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal ndx As Long, ByVal newValue As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, source As Any, ByVal numBytes As Long)


Type POINTAPI
    x As Long
    y As Long
End Type

Type MINMAXINFO
    ptReserved As POINTAPI
    ptMaxSize As POINTAPI
    ptMaxPosition As POINTAPI
    ptMinTrackSize As POINTAPI
    ptMaxTrackSize As POINTAPI
End Type


Const WM_GETMINMAXINFO = &H24
Const GWL_WNDPROC = -4

Dim saveHWnd As Long
Dim oldProcAddr As Long

Sub RestrictFormSize(ByVal hwnd As Long)
    saveHWnd = hwnd
    oldProcAddr = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndProc)
End Sub

Sub StopRestrictFormSize()
    SetWindowLong saveHWnd, GWL_WNDPROC, oldProcAddr
End Sub

Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, _
    ByVal wParam As Long, ByVal lParam As Long) As Long
    WndProc = CallWindowProc(oldProcAddr, hwnd, uMsg, wParam, lParam)

Dim mmInfo As MINMAXINFO
    
    Select Case uMsg
        Case WM_GETMINMAXINFO
            CopyMemory mmInfo, ByVal lParam, Len(mmInfo)
            With mmInfo

                .ptMinTrackSize.x = MinWidth 'Min Width In Pixels
                .ptMinTrackSize.y = MinHeight 'Min Height In Pixels
                .ptMaxTrackSize.Y = 600 'Max Height In Pixels
                .ptMaxTrackSize.X = 600 'Max Width In Pixels
                .ptMaxSize = .ptMaxTrackSize
  
            End With
            CopyMemory ByVal lParam, mmInfo, Len(mmInfo)
    End Select
End Function
Dan



[Edited by dbassettt74 on 10-02-2000 at 10:48 AM]