PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Andy Flowers on February 29, 2008, 12:50:30 AM

Title: Using the System Menu 'X' to Close a Form
Post by: Andy Flowers on February 29, 2008, 12:50:30 AM
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?
Title: Re: Using the System Menu 'X' to Close a Form
Post by: Rudolf Fürstauer on February 29, 2008, 03:12:10 AM
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