Results 1 to 11 of 11

Thread: detecting and disabling click on titlebar

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Talking

    Kinda going back to my original question.

    How can you detect that the user has doubleclicked on the titlebar of a mdiform? I need to disable the resizing...


    Please help !!!

    I have used on the resize event of the MDIform:

    windowstate=vbmaximized

    but it kinda look crappy.

    Any suggestions?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Cool Anyone Please?

    Does anyone have any ideas?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    No takers?

    Gurus, anyone, please?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  4. #4
    Guest
    This will disable everything
    Code:
    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    Private Const MF_BYPOSITION = &H400&
    
    Private Sub Form_Load()
        For I = 0 To 7
            RemoveMenu GetSystemMenu(hwnd, 0), 0, MF_BYPOSITION
        Next I
    End Sub

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    OK, if you just don't want the form to be maximized when the user double clicks on the title bar you have to sub class the form.
    Code:
    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 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 Const GWL_WNDPROC = (-4)
    Private Const WM_NCLBUTTONDBLCLK = &HA3
    Private Const WM_LBUTTONUP = &H202
    Private Const HTCAPTION = 2
    Private Const WM_DESTROY = &H2
    
    Private lngHwnd As Long
    Private lngPrevWndProc As Long
    
    Public Sub HookForm(frm As Form)
        lngHwnd = frm.hwnd
        lngPrevWndProc = SetWindowLong(lngHwnd, GWL_WNDPROC, AddressOf WinProc)
    End Sub
    
    Public Sub UnhookForm()
        SetWindowLong lngHwnd, GWL_WNDPROC, lngPrevWndProc
    End Sub
    
    Public Function WinProc( _
     ByVal hw As Long, _
     ByVal uMsg As Long, _
     ByVal wParam As Long, _
     ByVal lParam As Long) As Long
        Select Case uMsg
            Case WM_NCLBUTTONDBLCLK
                If wParam = HTCAPTION Then
                    uMsg = WM_LBUTTONUP
                End If
            Case WM_DESTROY
                'the window has been closed
                UnhookForm
        End Select
        WinProc = CallWindowProc(lngPrevWndProc, hw, uMsg, wParam, lParam)
    End Function
    To enable this from your form add the following code in the MDIForm_Load event
    Code:
    Private Sub MDIForm_Load()
        HookForm Me
    End Sub
    Good luck!

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    WELL

    MAN, I know this is old, but I never have gotten it to work. Anybody have any suggestions?

    I have the min, max and close button disbaled, but user can still resize if the double-click on the titlebar of the form...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  7. #7
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    You can do this with the EventVB.dll thus:

    VB Code:
    1. Option Explicit
    2.  
    3. Dim WithEvents vbLink As EventVB.APIFunctions
    4. Dim WithEvents vbWnd As EventVB.ApiWindow
    5.  
    6. Private Sub Form_Load()
    7.  
    8. Set vbLink = New EventVB.APIFunctions
    9.  
    10. Set vbWnd = New EventVB.ApiWindow
    11. vbWnd.hWnd = Me.hWnd
    12. '\\ Subclass this form....
    13. vbLink.SubclassedWindows.Add vbWnd
    14.  
    15. End Sub
    16.  
    17. Private Sub vbWnd_MinMaxSize(MaxHeight As Long, MaxWidth As Long, MaxPositionTop As Long, MaxPositionLeft As Long, MinTrackWidth As Long, MinTrackheight As Long, MaxTrackWidth As Long, MaxTrackHeight As Long)
    18.  
    19. If Me.WindowState <> vbMinimized Then
    20.     With vbWnd.RECT
    21.         MaxHeight = .Bottom - .Top
    22.         MaxWidth = .Right - .Left
    23.         MaxPositionLeft = .Left
    24.         MaxPositionTop = .Top
    25.     End With
    26. End If
    27.  
    28. End Sub

    Hope this helps,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    MerrionComputin : Thanks for your reply. I will try out the dll and see if I cn get it to work. Thansk for the reply to such an old post...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well - I'll be damned

    MerrionComputin : It work exactly the way I wanted it to...

    Bad ass dll. Your design?
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  10. #10
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Bad ass dll. Your design?
    My magnum opus - cruelly cut short by the rest of the world moving to VB.Net
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Let move to NET. Right now 6.0 works for me...
    Thanks again.
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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