***************************************************************** * Neveprise Inc. Delphi FAQ * ***************************************************************** * Section: Desktop Topic: Handling other widows * * Created: July 27th, 1999 Revised: July 27th, 1999 * * Updates: www.neveprise.de Info: support@neveprise.de * ***************************************************************** Q: How can I close windows from other applications etc.? A: You can do everything with other windows, the problem is how to identify'em. That means: you must get a window's handle, but to retrieve it, you must specify properties the window has. The simpliest way is to do it by caption (but what, if it changes??? e.g. some show open files in caption): //closes any window that has a certain caption procedure ExitOtherWindowH(Caption: string); var WinHandle: THandle; begin WinHandle:=FindWindow(nil, PChar(Caption)); //get handle by caption //and tell Windows to close it if WinHandle<>0 then PostMessage(WinHandle,WM_Quit,0,0); end; //"disables" another window, so that you cannot enter its system- //menu (minimize, maximize, move, close...) procedure LockOtherWindowH(Caption: string); var WinHandle: THandle; MenuHandle: HMenu; begin WinHandle:=FindWindow(nil, PChar(Caption)); //same as above if WinHandle<>0 then begin MenuHandle:=GetSystemMenu(WinHandle,false); //get handle on form's menu //and remove it if MenuHandle<>0 then DeleteMenu(MenuHandle, SC_Close, MF_ByCommand); end; end; Blazko