To prevent the user from closing a form you need to disable the close button in the title bar of a form and at the same time disable the "Close" menu item in the form's system menu. This is done by calling the EnableMenuItem API function (see the example below). To prevent the user from closing a form you need to disable the close button in the title bar of a form and at the same time disable the "Close" menu item in the form's system menu. This is done by calling the EnableMenuItem API function (see the example below). Nonetheless, the user can still close the form using the Alt+F4 key combination, so we have to set the KeyPreview form property to True and write an event handler for the OnKeyDown event to cancel out this hot key: procedure TForm1.FormCreate(Sender: TObject); var hSysMenu: HMENU; begin hSysMenu := GetSystemMenu(Self.Handle, False); if hSysMenu <> 0 then begin EnableMenuItem(hSysMenu, SC_CLOSE, MF_BYCOMMAND Or MF_GRA...
OOP, Tips, Trick, Free E-Book, Free Tutorial, Free Source Code, All About Delphi, Cerita Kehidupan, Technology