home *** CD-ROM | disk | FTP | other *** search
- {$M 1024,1024,R-,S-,D-,L-,N-,A-}
- Program Bye;
-
- (* BYE.PAS - Quick Exit For Windows
- * Written by Richard R. Sands in Turbo Pascal for Windows
- * Copyright ⌐ Richard R. Sands
- * All rights reserved
- *
- * Since this program goes around the Program Manager to quit, it will
- * not save your current Program Manager settings (group window size and
- * positions). If you want your Progman settings saved, you must exit
- * from the Program Manager.
- *
- * Version History
- * 1.01P - 04/10/91 - Initial Release
- * 1.02P - 05/04/91 - Added "Operating System" menu option
- * 1.03P - 07/11/91 - Takes less memory - reduced Heap/Stack
- *)
-
- {$R BYE}
-
- USES
- WinTypes, WinProcs, ByeCmds;
-
- CONST
- AppName = 'Bye';
-
- { -------------------------------------------------------------------------- }
- function WindowProc(Window: hWnd; Message, WParam: Word; LParam: Longint): Longint; export;
- begin
- WindowProc := 0;
- case Message of
- wm_SysCommand:
- case wParam of
- idm_About : begin
- DoAbout(Window);
- EXIT
- end;
- idm_Confirm: ToggleConfirm(Window);
- idm_OS : WinExec('Command.Com', sw_Normal);
- idm_Quit : Quit(Window);
- end;
- wm_QueryOpen: begin
- Quit(Window); { Double click on Icon }
- { If returns 0 then we cannot open - this
- suppresses the maximize functions }
- EXIT
- end;
- wm_Destroy:
- begin
- PostQuitMessage(0);
- EXIT;
- end;
- end;
- WindowProc := DefWindowProc(Window, Message, WParam, LParam)
- end;
-
- { -------------------------------------------------------------------------- }
- procedure WinMain;
- var Window : hWnd;
- Message: TMsg;
- const
- WindowClass: TWndClass = (
- style: 0;
- lpfnWndProc: @WindowProc;
- cbClsExtra: 0;
- cbWndExtra: 0;
- hInstance: 0;
- hIcon: 0;
- hCursor: 0;
- hbrBackground: 0;
- lpszMenuName: AppName;
- lpszClassName: AppName);
- begin
- if HPrevInst = 0 then
- begin
- WindowClass.hInstance := hInstance;
- WindowClass.hIcon := LoadIcon(hInstance, 'ICON');
- WindowClass.hCursor := LoadCursor(0, idc_Arrow);
- WindowClass.hbrBackground := GetStockObject(white_Brush);
- if not RegisterClass(WindowClass) then Halt(255);
- end
- else
- Halt(0); { Only One Instance Allowed }
- Window := CreateWindow(
- AppName, AppName,
- ws_OverlappedWindow,
- cw_UseDefault,
- cw_UseDefault,
- cw_UseDefault,
- cw_UseDefault,
- 0,
- 0,
- HInstance,
- nil);
-
- ModifySystemMenu(Window); { Add our commands to system menu }
-
- ShowWindow(Window, sw_Minimize); { This minimizes the window }
-
- while GetMessage(Message, 0, 0, 0) do { Main Message Loop }
- begin
- TranslateMessage(Message);
- DispatchMessage(Message)
- end;
- Halt(Message.wParam)
- end;
-
- { -------------------------------------------------------------------------- }
- begin
- WinMain
- end.
-