Results 1 to 4 of 4

Thread: Detect a ResizeForm click (Not Just RESIZE!!)

  1. #1
    Guest
    I need to be able to detect when the user simply clicks on the border of my form. (Like when you reach the end of a window and it turns into the resize mouse icon).

    Simply clicking the border does not activate the form's resize event, so I need to know what kind of message is sent when you just click on the border so I can subclass it.

    Any Suggestions?

  2. #2
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    you can get the cursor position when the person click the form in the mousedown event
    then you just use simple mathematical calculations to find out
    YC Sim
    Teenage Programmer
    UIN 37903254



  3. #3
    Guest
    Not bad, but not exactly what I'm looking for. There must be a windows message of some sort that is sent to the form when the edges are clicked to resize. Thanks for the idea though.

    Anyone else have any suggestions?

  4. #4
    Guest
    You can Subclass your Window.

    Code for Module
    Code:
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
    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
    
    Const WM_COMMAND = &H111
    Const WM_CLOSE = &H10
    Const GWL_WNDPROC = (-4)
    Const WM_ENTERSIZEMOVE = &H231
    
    Global WndProcOld As Long
    
    Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wparam As Long, ByVal lparam As Long) As Long
    
        If wMsg& = WM_ENTERSIZEMOVE Then
            '***Place code here***
            MsgBox "Resize"
        End If
        
        WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wparam&, lparam&)
        
    End Function
    
    Sub Subclass(hwnd As Long)
        WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
    End Sub
    
    Sub UnSubclass(hwnd)
        SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
        WndProcOld& = 0
    End Sub
    Code for Form
    Code:
    Private Sub Form_Load()
        Subclass Me.hwnd
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        UnSubclass Me.hwnd
    End Sub

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