Using the System Menu 'X' to Close a Form

Started by Andy Flowers, February 29, 2008, 12:50:30 AM

Previous topic - Next topic

Andy Flowers

How do I get my code to respond to closing the form using the System menu - "The X in the right top corner" WM_DESTROY seem to not be triggered?

Rudolf Fürstauer

Hi Andy,
you can use %SC_CLOSE:


'------------------------------------------------------------------------------------------------------------------------
'
'------------------------------------------------------------------------------------------------------------------------
Function FRMBEWERTUNG_CUSTOM (hWndForm As Dword, wMsg As Long, wParam As Dword, lParam As Long) As Long

'--------------------------------------

'--------------------------------------------
' Message?
'--------------------------------------------
Select Case wMsg

'SYSCOMMAND
'--------------------------------------------
        Case %WM_SYSCOMMAND
            Select Case LoWrd(wParam)

                'MINIMIZE
                '-------------------------------------------
            Case %SC_MINIMIZE


                'CLOSE
                '-------------------------------------------
                Case %SC_CLOSE

                  FF_CloseForm hWndForm, 1
  End Select

        Case %WM_TRAYICON

        Case %WM_NOTIFY


Fürstauer Rudolf