Results 1 to 3 of 3

Thread: help with code modification..

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    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]

  2. #2
    Lively Member
    Join Date
    May 2000
    Location
    Norway
    Posts
    112
    I'm not sure, but I think to have seen an API for converting to and from twips and pixels. This might help you if no one else posts a reply.

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    You can do the conversion yourself

    1 twip = .0667 pixel

    (thanx Dennis )
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width